package-system-locked 358 B

12345678910111213141516
  1. #!/bin/sh
  2. # check if package system is locked
  3. # return 0 if unlocked, 2 if locked, 1 on error
  4. set -e
  5. for f in /var/lib/dpkg/lock /var/cache/apt/archives/lock \
  6. /var/lib/apt/lists/lock /run/unattended-upgrades.lock; do
  7. [ -e $f ] || continue
  8. # fuser succeeds if there is at least one user
  9. if fuser $f; then
  10. exit 2
  11. fi
  12. done
  13. exit 0