updated on Sat Jan 21 04:00:54 UTC 2012
[aur-mirror.git] / firefox-tmpfs-daemon / rc.firefox-tmpfs
bloba87de98bada4c82d29b96095a792e0eca1afa12e
1 #!/bin/bash
3 # /etc/rc.d/firefox-tmpfs
5 # Sync mozilla preferences to tmpfs
7 # An initial backup is always kept in ~/.mozilla_ref
8 # In case of crash, firefox-tmpfs tries to recover your old profile at startup
10 . /etc/rc.conf
11 . /etc/rc.d/functions
13 # source application-specific settings
14 [ -f /etc/conf.d/firefox-tmpfs ] && . /etc/conf.d/firefox-tmpfs
16 # exit if $TMPFS does not exist
17 [ ! -z "$TMPFS" ] && [ ! -d "$TMPFS" ] && exit 1
19 # delete repeated users in configuration file
20 [ -n "$USERS" ] && USERS=`echo $USERS | tr " " "\n" | uniq`
22 # set defaults
23 [ -z "$TMPFS" ] && TMPFS=/dev/shm
24 [ -z "$USERS" ] && USERS="`ls -d -c1 /home/*/.mozilla | cut -d/ -f3`"
26 case "$1" in
27 start)
28 stat_busy "Sync firefox profiles from hd to tmpfs"
30 for user in $USERS ; do
32 if [ -h /home/$user/.mozilla ] && [ -d /home/$user/.mozilla_ref ] ; then
34 # In case of crash, if old symlinks to $TMPFS still exists, use the old profile
36 rm /home/$user/.mozilla
37 mv /home/$user/.mozilla_ref /home/$user/.mozilla
41 if [ -d /home/$user/.mozilla ] && [ ! -d /home/$user/.mozilla_ref ] ; then
43 # Create a directory in $TMPFS, symlink it with ~/.mozilla
44 mkdir -p $TMPFS/$user.mozilla
45 mv /home/$user/.mozilla /home/$user/.mozilla_ref
47 ln -s $TMPFS/$user.mozilla /home/$user/.mozilla
49 # sync mozilla directory to tmpfs
50 rsync -a -q /home/$user/.mozilla_ref/ /home/$user/.mozilla/
54 done
56 add_daemon firefox-tmpfs
58 stat_done
61 stop)
62 stat_busy "Sync firefox profiles from tmpfs to hd"
64 for user in $USERS ; do
66 if [ -h /home/$user/.mozilla ] && [ -d /home/$user/.mozilla_ref ] ; then
68 rsync -a -q --delete /home/$user/.mozilla/ /home/$user/.mozilla_ref/
70 rm /home/$user/.mozilla
71 mv /home/$user/.mozilla_ref /home/$user/.mozilla
75 done
77 rm_daemon firefox-tmpfs
78 stat_done
80 restart)
81 $0 stop
82 $0 start
84 save)
85 stat_busy "Sync firefox profiles from tmpfs to hd"
87 for user in $USERS ; do
89 if [ -h /home/$user/.mozilla ] && [ -d /home/$user/.mozilla_ref ] ; then
90 rsync -a -q --delete /home/$user/.mozilla/ /home/$user/.mozilla_ref/
93 done
95 stat_done
98 echo "usage: $0 {start|stop|restart|save}"
99 esac
100 exit 0
102 # vim:set ts=2 sw=2 ft=sh et: