Alexander Afanasyev | 8019a93 | 2014-08-10 18:19:28 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # preinst script for nlsr |
| 3 | # |
| 4 | # see: dh_installdeb(1) |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | # summary of how this script can be called: |
| 9 | # * <new-preinst> `install' |
| 10 | # * <new-preinst> `install' <old-version> |
| 11 | # * <new-preinst> `upgrade' <old-version> |
| 12 | # * <old-preinst> `abort-upgrade' <new-version> |
| 13 | # for details, see http://www.debian.org/doc/debian-policy/ or |
| 14 | # the debian-policy package |
| 15 | |
| 16 | |
| 17 | case "$1" in |
| 18 | install|upgrade) |
| 19 | # Now we have to ensure the following state: |
| 20 | # /etc/passwd: nlsr:x:YYY:ZZZ:NLSR User:/nonexistent:/bin/false |
| 21 | # /etc/group: nlsr:x:ZZZ: |
| 22 | # |
| 23 | # Sadly there could any state be present on the system so we have to |
| 24 | # modify everything carefully i.e. not doing a chown before creating |
| 25 | # the user etc... |
| 26 | |
| 27 | # creating nlsr group if he isn't already there |
| 28 | if ! getent group nlsr >/dev/null; then |
| 29 | # Adding system group: nlsr. |
| 30 | addgroup --system nlsr >/dev/null |
| 31 | fi |
| 32 | |
| 33 | # creating nlsr user if he isn't already there |
| 34 | if ! getent passwd nlsr >/dev/null; then |
| 35 | # Adding system user: nlsr. |
| 36 | adduser \ |
| 37 | --system \ |
| 38 | --disabled-login \ |
| 39 | --ingroup nlsr \ |
| 40 | --home /nonexistent \ |
| 41 | --gecos "NLSR User" \ |
| 42 | --shell /bin/false \ |
| 43 | nlsr >/dev/null |
| 44 | fi |
| 45 | ;; |
| 46 | |
| 47 | abort-upgrade) |
| 48 | ;; |
| 49 | |
| 50 | *) |
| 51 | echo "preinst called with unknown argument \`$1'" >&2 |
| 52 | exit 1 |
| 53 | ;; |
| 54 | esac |
| 55 | |
| 56 | # dh_installdeb will replace this with shell code automatically |
| 57 | # generated by other debhelper scripts. |
| 58 | |
| 59 | #DEBHELPER# |
| 60 | |
| 61 | exit 0 |