summarylogtreecommitdiffstats
path: root/tuptime.install
blob: d7889a173b434e51bf9af021f31ad58ee5a2c6c5 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
post_install() {
	echo -e '\nActivate using: \nsystemctl enable --now tuptime.service tuptime-sync.timer \n'

	/usr/bin/systemd-sysusers
	local dir='/var/lib/tuptime'
	if [ ! -d ${dir} ]; then
		mkdir -p ${dir}
	fi
	chown -R _tuptime:_tuptime ${dir}
	chmod 0755 ${dir}
}

post_upgrade() {
	if id tuptime &>/dev/null; then
		echo -e '\nUser "tuptime" was replaced with "_tuptime", you may remove it. \n'
	fi

	/usr/bin/systemd-sysusers
	local dir='/var/lib/tuptime'
	if [ -d ${dir} ]; then
		local owner=$(stat -c %U%G ${dir})

		if [[ "${owner}" != "_tuptime_tuptime" ]]; then
			chown -R _tuptime:_tuptime ${dir}
			chmod 0755 ${dir}
		fi
	else
		mkdir -p ${dir}
		chown _tuptime:_tuptime ${dir}
		chmod 0755 ${dir}
	fi
}

post_remove() {
	local dir='/var/lib/tuptime'
	if [ -d ${dir} ]; then
		rm -rf ${dir}
	fi
	if id _tuptime &>/dev/null; then
		userdel -f _tuptime
	fi
}