summarylogtreecommitdiffstats
path: root/psd.install
blob: c40c47a160e4cad2b3e66780d150233e0a62c5fb (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
## arg 1:  the new package version
## arg 2:  the old package version

pre_upgrade() {
	# version 6.00 is a major rebuild
	# yes, I realize that pacman should not stop services but in this case it
	# is required or else browser profiles (user data) can get renamed and confuse
	# people if it does not happen
	if [ $(vercmp $2 6.00) -lt 0 ]; then
		echo 'ATTENTION: MAJOR CHANGES TO PSD WITH VERSION 6.00+'
		echo '-> 1. A global /etc/psd.conf is no longer used. $HOME/.config/psd/psd.conf will be'
		echo '->    created when psd is invoked the first time.'
		echo '-> 2. A system service is no longer used. A user service is provided and can be'
		echo '->    used like this:  systemctl --user start psd.service'
		echo '-> 3. Users wanting to use overlayfs mode MUST have sudo access to both mount'
		echo '->    and umount. See the man page for an example configured with visudo.'
		echo
		echo '-> Internal changes to psd require it to be stopped now before updating.'

		# stop system service now since it will be removed upon updating
		systemctl is-active psd.service &>/dev/null
		if [ $? -eq 0 ]; then
			systemctl stop psd.service &>/dev/null
		fi
	fi

	# version 6.01 redefines the location of tmpfs for the software so it is
	# required that pacman stop the user service here if running
	if [ $(vercmp $2 6.01) -lt 0 ]; then
		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'
				su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
				echo '-> Internal changes to psd require it to be stopped now before updating.'
				echo '-> Recommend that you diff /usr/share/doc/psd/psd.conf against ~/.config/psd/psd.conf'
			fi
		done
	fi

	if [ $(vercmp $2 6.03) -lt 0 ]; then
		for i in $(users); do
			HOMEDIR="$(getent passwd $i | cut -d: -f6)"
			if [[ -d "$HOMEDIR"/.psd ]]; then
				echo '-> The use of $HOME/.psd is deprecated.'
				echo '-> Psd will move it for you upon next invocation to $XDG_CONFIG_HOME/psd'
			fi
		done

		# version 6.05 impliments changes to both the service and the way overlayfs is mounted/umount
		# so it is required that pacman stop the user service here if running
		if [ $(vercmp $2 6.05) -lt 0 ]; then
			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'
					su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload'
					echo '-> Internal changes to psd require it to be stopped now before updating.'
					echo '-> Users of overlayfs: you must run the following before starting the service: psd p'
				fi
			done
		fi
	fi

	# version 6.07 has minor changes to config file
	if [ $(vercmp $2 6.07) -lt 0 ]; then
		echo '-> Recommend that you diff /usr/share/psd/psd.conf against ~/.config/psd/psd.conf'
	fi
}

pre_remove() {
	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
			echo "--> In order to preserve your profiles, pacman will now stop your psd service."
			echo "--> Any running and managed browsers will be exited."
			su $i -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID systemctl --user stop psd.service'
		fi
	done
}