summarylogtreecommitdiffstats
path: root/psd.install
blob: 6f20951a60641183d6867c84c00c06c3b51bb05e (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
## arg 1:  the new package version
## arg 2:  the old package version
users=$(loginctl --no-legend list-users | awk '{ print $2 }' | sed ':a;N;$!ba;s/\n/ /g')

post_upgrade() {
	for i in $users; do
		su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
	done
}

post_install() {
	echo '--> WARNING! DEVELOPMENT VERSION!'
	echo '--> ALWAYS backup your profile data before using utils like psd!'
	post_upgrade
}

pre_upgrade() {
	# in general stop and restart always when using dev version
	for i in $users; do
		running="$(su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user is-active psd')"
		if [[ "$running" = "active" ]]; then
			su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user stop psd.service'
			echo '-> Dev version of psd so ALWAYS a good idea to stop running psd before updating.'
		fi
	done
}

pre_remove() {
	for i in $users; do
		running="$(su $i -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user is-active psd')"
		if [[ "$running" = "active" ]]; then
			su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user stop psd.service'
			echo "--> In order to preserve your profiles, pacman will now stop your psd service."
			echo "--> Any running and managed browsers will be exited."
		fi
	done
}