tang-common.postinst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. set -eu
  3. db_dir_old='/var/db/tang'
  4. db_dir='/var/lib/tang'
  5. case "$1" in
  6. configure)
  7. if ! getent passwd _tang >/dev/null; then
  8. adduser --quiet --system --group --no-create-home --home /nonexistent --force-badname _tang
  9. fi
  10. # Migrate tang db:
  11. # * Change location
  12. # * Give it to _tang user
  13. # This cannot be anchored to a version since the initial setup used
  14. # to be in the tang package.
  15. # (Retire after bookworm release)
  16. if
  17. [ -d "$db_dir_old" ] &&
  18. [ ! -d "$db_dir" ]
  19. then
  20. echo 'I: Migrating tang db'
  21. mv "$db_dir_old" "$db_dir"
  22. chown -R _tang:_tang "$db_dir"
  23. fi
  24. # Possibly remove /var/db/
  25. # (Retire after bookworm release)
  26. if [ -d /var/db/ ]; then
  27. rmdir /var/db/ >/dev/null 2>&1 || :
  28. fi
  29. # assert db directory
  30. mkdir -p "$db_dir"
  31. chown _tang:_tang "$db_dir"
  32. chmod 0750 "$db_dir"
  33. ;;
  34. abort-upgrade | abort-remove | abort-deconfigure) ;;
  35. *)
  36. echo "postinst called with unknown argument '$1'" >&2
  37. exit 1
  38. ;;
  39. esac
  40. #DEBHELPER#
  41. exit 0