blob: 37f4d91ba29c1bd7adf3572109355841e7c8658d [file] [log] [blame]
Alexander Afanasyev469cbcd2014-05-08 01:25:11 -07001#!/bin/sh
2# preinst script for nfd
3#
4# see: dh_installdeb(1)
5
6set -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
17case "$1" in
18 install|upgrade)
19 # Now we have to ensure the following state:
20 # /etc/passwd: ndn:x:YYY:ZZZ:NDN User:/nonexistent:/bin/false
21 # /etc/group: ndn: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 ndn group if he isn't already there
28 if ! getent group ndn >/dev/null; then
29 # Adding system group: ndn.
30 addgroup --system ndn >/dev/null
31 fi
32
33 # creating ndn user if he isn't already there
34 if ! getent passwd ndn >/dev/null; then
35 # Adding system user: ndn.
36 adduser \
37 --system \
38 --disabled-login \
39 --ingroup ndn \
40 --home /nonexistent \
41 --gecos "NDN User" \
42 --shell /bin/false \
43 ndn >/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 ;;
54esac
55
56# dh_installdeb will replace this with shell code automatically
57# generated by other debhelper scripts.
58
59#DEBHELPER#
60
61exit 0