]> Pileus Git - ~andy/sunrise/blob - www-misc/profile-sync-daemon/files/daemon
749ba85e726900a67a1a4f83c9762a8f3b33310a
[~andy/sunrise] / www-misc / profile-sync-daemon / files / daemon
1 #!/sbin/runscript
2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 description="Webbrowser profile syncing"
6 extra_commands="sync"
7 PIDFILE=/var/run/${SVCNAME}.pid
8
9 [ -e /etc/psd.conf ] && . /etc/psd.conf
10
11 start() {
12         ebegin "Starting Profile-Sync-Daemon"
13         if [[ -z $USERS ]]; then
14                 eerror "Define at least one user in /etc/psd.conf"
15                 return 1
16         fi
17
18         for i in $USERS; do
19                 homedir=$(su -c 'echo $HOME' $i)
20                 if [[ ! -d $homedir ]]; then
21                         eerror "Invalid user defined in /etc/psd.conf"
22                         return 1
23                 fi
24         done
25
26         /usr/bin/profile-sync-daemon check 
27         start-stop-daemon --start --pidfile ${PIDFILE} --make-pidfile --background \
28                 --exec /usr/bin/profile-sync-daemon -- sync
29         eend $?
30 }
31
32 stop() {
33         ebegin "Stopping Profile-Sync-Daemon"
34         if [[ ! -f $PIDFILE ]]; then
35                 eerror "Profile-Sync-Daemon is not running, nothing to stop!"
36                 return 1
37         else
38                 /usr/bin/profile-sync-daemon sync && /usr/bin/profile-sync-daemon unsync
39                 rm -f ${PIDFILE}
40         fi
41         eend $?
42 }
43
44 sync() {
45         ebegin "Syncing browser profiles in tmpfs to physical disc"
46         if [[ ! -f $PIDFILE ]]; then
47                 eerror "Profile-Sync-Daemon is not running... cannot sync!"
48                 return 1
49         else
50                 /usr/bin/profile-sync-daemon sync
51         fi
52         eend $?
53 }