]> Pileus Git - ~andy/sunrise/blob - www-misc/profile-sync-daemon/files/daemon
www-misc/profile-sync-daemon: version bump, remove old
[~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
8 start() {
9         ebegin "Starting Profile-Sync-Daemon"
10         if [ -z "$USERS" ]; then
11                 eerror "Define at least one user in /etc/conf.d/psd"
12                 return 1
13         fi
14
15         for i in $USERS; do
16                 homedir=$(su -c 'echo $HOME' $i)
17                 if [ ! -d "$homedir" ]; then
18                         eerror "Invalid user defined in /etc/conf.d/psd"
19                         return 1
20                 fi
21         done
22
23         /usr/bin/profile-sync-daemon check 
24         start-stop-daemon --start --pidfile "${PIDFILE}" --make-pidfile --background \
25                 --exec /usr/bin/profile-sync-daemon -- sync
26         eend $?
27 }
28
29 stop() {
30         ebegin "Stopping Profile-Sync-Daemon"
31         if [ ! -f "$PIDFILE" ]; then
32                 eerror "Profile-Sync-Daemon is not running, nothing to stop!"
33                 return 1
34         else
35                 /usr/bin/profile-sync-daemon sync && /usr/bin/profile-sync-daemon unsync
36                 rm -f "${PIDFILE}"
37         fi
38         eend $?
39 }
40
41 sync() {
42         ebegin "Syncing browser profiles in tmpfs to physical disc"
43         if [ ! -f "$PIDFILE" ]; then
44                 eerror "Profile-Sync-Daemon is not running... cannot sync!"
45                 return 1
46         else
47                 /usr/bin/profile-sync-daemon sync
48         fi
49         eend $?
50 }
51
52 status() {
53         if [ ! -f "$PIDFILE" ]; then
54                 eerror "Profile-Sync-Daemon is not running"
55         else
56                 einfo "Profile-Sync-Daemon is running"
57         fi
58         eend $?
59 }
60