summarylogtreecommitdiffstats
path: root/sickrage.install
blob: 7d4fef08e55eacb1a5b9f9cc7c476f952330c48f (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
SB_USER=sickrage

post_install() {
	getent passwd ${SB_USER} > /dev/null || useradd -U -d /opt/sickrage -s /bin/false -r ${SB_USER} > /dev/null

	if grep -qr 'tvrage' /opt/sickbeard 2>/dev/null
	then
		echo "A previous installation of sickbeard-tvrage-git has been found."
		if [[ ! -f /opt/sickrage/sickbeard.db ]]
		then
			echo "No sickrage database found; replicating leftover database from previous sickbeard-tvrage-git install."
			mkdir -p /opt/sickrage/Logs
			cp /opt/sickbeard/Logs/* /opt/sickrage/Logs/
			cp /opt/sickbeard/*.db /opt/sickrage/
			cp /opt/sickbeard/config.ini /opt/sickrage/
		else
			echo "A sickrage database was found; Ignoring old sickbeard-tvrage-git database"
		fi
		echo "/opt/sickbeard should be safe to remove after testing that sickrage is working as expected"
	fi

	chown -R ${SB_USER}. /opt/sickrage

	# Create a directory in /run if it does not exist
	if [ ! -d /run/sickrage ]; then
		mkdir /run/sickrage
		chown ${SB_USER}. /run/sickrage
		chmod 775 /run/sickrage
	fi

}

post_upgrade() {
	post_install
}

post_remove() {
	echo "Some files have not been removed because they are created by sickrage itself, e.g. the show database."
	userdel -f ${SB_USER}
	groupdel -f ${SB_USER}
}