]> Pileus Git - ~andy/sunrise/blob - www-misc/profile-sync-daemon/files/daemon
www-misc/profile-sync-daemon: New Ebuild for bug 398431
[~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                 if [[ ! -d /home/$i ]]; then
20                         eerror "Invalid user defined in /etc/psd.conf"
21                         return 1
22                 fi
23         done
24
25         /usr/bin/profile-sync-daemon check 
26         start-stop-daemon --start --pidfile ${PIDFILE} --make-pidfile --background \
27                 --exec /usr/bin/profile-sync-daemon -- sync
28         eend $?
29 }
30
31 stop() {
32         ebegin "Stopping Profile-Sync-Daemon"
33         if [[ ! -f $PIDFILE ]]; then
34                 eerror "Profile-Sync-Daemon is not running, nothing to stop!"
35                 return 1
36         else
37                 /usr/bin/profile-sync-daemon unsync
38                 rm -f ${PIDFILE}
39         fi
40         eend $?
41 }
42
43 sync() {
44         ebegin "Syncing browser profiles in tmpfs to physical disc"
45         if [[ ! -f $PIDFILE ]]; then
46                 eerror "Profile-Sync-Daemon is not running... cannot sync!"
47                 return 1
48         else
49                 /usr/bin/profile-sync-daemon sync
50         fi
51         eend $?
52 }