summaryrefslogtreecommitdiff
blob: 749ba85e726900a67a1a4f83c9762a8f3b33310a (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
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

description="Webbrowser profile syncing"
extra_commands="sync"
PIDFILE=/var/run/${SVCNAME}.pid

[ -e /etc/psd.conf ] && . /etc/psd.conf

start() {
	ebegin "Starting Profile-Sync-Daemon"
	if [[ -z $USERS ]]; then
		eerror "Define at least one user in /etc/psd.conf"
		return 1
	fi

	for i in $USERS; do
		homedir=$(su -c 'echo $HOME' $i)
		if [[ ! -d $homedir ]]; then
			eerror "Invalid user defined in /etc/psd.conf"
			return 1
		fi
	done

	/usr/bin/profile-sync-daemon check 
	start-stop-daemon --start --pidfile ${PIDFILE} --make-pidfile --background \
		--exec /usr/bin/profile-sync-daemon -- sync
	eend $?
}

stop() {
	ebegin "Stopping Profile-Sync-Daemon"
	if [[ ! -f $PIDFILE ]]; then
		eerror "Profile-Sync-Daemon is not running, nothing to stop!"
		return 1
	else
		/usr/bin/profile-sync-daemon sync && /usr/bin/profile-sync-daemon unsync
		rm -f ${PIDFILE}
	fi
	eend $?
}

sync() {
	ebegin "Syncing browser profiles in tmpfs to physical disc"
	if [[ ! -f $PIDFILE ]]; then
		eerror "Profile-Sync-Daemon is not running... cannot sync!"
		return 1
	else
		/usr/bin/profile-sync-daemon sync
	fi
	eend $?
}