File: sysuser-helper

package info (click to toggle)
dh-sysuser 1.3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 72 kB
  • ctags: 1
  • sloc: perl: 56; sh: 18; makefile: 5
file content (29 lines) | stat: -rwxr-xr-x 826 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
set -eu
exec >/dev/null # only errors should pass.

case "$1" in
	postinst)
		if ! getent passwd "$CONF_USERNAME" ; then
			# Create home directory for system user, unless it is
			# /nonexistent, which must stay nonexistent.
			CREATE_HOME='--create-home'
			[ "$CONF_HOME" = '/nonexistent' ] && CREATE_HOME=''

			# Correct, no quotes around $CREATE_HOME.
			useradd --system --home-dir "$CONF_HOME" $CREATE_HOME \
			        "$CONF_USERNAME"
		fi

		# If user already have another home directory, we use `usermod
		# --move-home'. Unfortunately, new home is required to be
		# non-existent (and different from previous), so this
		# conditional is required.
		if [ ! -d "$CONF_HOME" ] ; then
			usermod --move-home --home "$CONF_HOME" "$CONF_USERNAME"
		fi
		;;
	prerm)
		passwd --lock "$CONF_USERNAME"
		;;
esac