openvpn-install icon indicating copy to clipboard operation
openvpn-install copied to clipboard

A fix about a problem with apt and dpkg lock

Open ufukty opened this issue 4 years ago • 2 comments

Checklist

  • [x] I read the README
  • [x] I read the FAQ
  • [x] I searched the issues
  • [x] My issue is about the script, and not OpenVPN itself

Problem

When Ubuntu starts, it triggers the apt for checking latest security patches. Since apt has no mechanism to keep sequent calls on-hold, they are ending up with error. Script can not install required packages and tries to continue without them.

This issue more likely belongs to apt-get than this repo, but seems like there are issues reported about apt at bugs.debian.org [^1] [^2] none of them resolves the apt-get's problem.

Fix

Fast fix could be wrapping apt calls with until and sleep:

until apt-get install openvpn; do sleep 1; done

I will make a pull request to resolve issue.

Symptoms

  1. VPN connection can not be established.

  2. <tls-crypt> section of .ovpn file remains empty

  3. Packages may not be installed at all (openvpn, easy-rsa etc.) Related error for that:

    E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1502 (apt-get)
    N: Be aware that removing the lock file is not a solution and may break your system.
    E: Unable to lock directory /var/lib/apt/lists/
    
  4. Error messages caused by commands at the line 931

    cp: cannot stat '/lib/systemd/system/[email protected]': No such file or directory
    sed: can't read /etc/systemd/system/[email protected]: No such file or directory
    sed: can't read /etc/systemd/system/[email protected]: No such file or directory
    Failed to enable unit: Unit file [email protected] does not exist.
    Failed to restart [email protected]: Unit [email protected] not found.
    

Server Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-42-generic x86_64)

Client Mac — Viscosity iOS — Official OpenVPN client

References [^1]: Bug report: (apt: support option to wait for lockfile)
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754103 [^2]: Feature request: (apt/aptitude finer grained locking)
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=478961

ufukty avatar Aug 25 '20 16:08 ufukty

Probably the same answer as checking the $PATH variable https://github.com/angristan/openvpn-install/issues/593#issuecomment-606007954

This is not a bug in this script.

randshell avatar Aug 27 '20 13:08 randshell

I can say, on ubuntu after starts (user logon)... Do a automatic apt update.. maybe was that causing your problem on lock.. just need wait a little..

hellresistor avatar Aug 31 '20 18:08 hellresistor