summarylogtreecommitdiffstats
path: root/mcsctl-git.install
blob: 16fd88158bcaa7a5308f22405e51f4ba042f4bb8 (plain)
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
MCS_USER='mcs'

user_exists() {
	if getent passwd "$MCS_USER" > /dev/null; then
		return $(true)
	else
		return $(false)
	fi
}

post_install() {
	if ! user_exists; then
		echo "Adding user \"$MCS_USER\"..."
		useradd --user-group --comment 'Minecraft user' --shell /usr/bin/nologin --create-home "$MCS_USER" &> /dev/null
		passwd --lock "$MCS_USER" > /dev/null
	fi
}

post_remove() {
	if user_exists; then
		echo "Stopping processes controlled by \"$MCS_USER\"..."
		killall --wait --user "$MCS_USER"
		echo "Removing user \"$MCS_USER\"..."
		userdel --force "$MCS_USER" &> /dev/null
	fi
}