Skip to content

A fix about a problem with apt and dpkg lock #720

Open
@ufukty

Description

@ufukty

Checklist

  • I read the README
  • I read the FAQ
  • I searched the issues
  • 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

Footnotes

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions