updated on Sat Jan 14 12:12:45 UTC 2012
[aur-mirror.git] / pacman-cage / pacmandb.rc
blob4b6eba73171731c62ecaa0a4c1f4e62e08233a42
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 pacmanlog=$(pacman -Qv | grep "Log File" | cut -d ":" -f2)
8 case "$1" in
9 start)
10 # Check and mount pacman database
11 stat_busy "Mounting the pacman database"
12 # write to pacman.log
13 echo "[ $(date "+%Y-%m-%d %H:%M ")] Pacman-cage [rc] >> Mounting the pacmans database" >> ${pacmanlog}
14 /sbin/e2fsck -p /var/lib/pacman.db >/dev/null
15 if [ $? -gt 1 ]; then
16 stat_fail
17 echo
18 echo "WARNING: PACMAN DATABASE FILESYSTEM CHECK FAILED, NOT MOUNTED"
19 echo
20 # write to pacman.log
21 echo "[ $(date "+%Y-%m-%d %H:%M ")] Pacman-cage [rc] >> WARNING: Pacman database filesystem check failed, not mounted!" >> ${pacmanlog}
22 else
23 mount -o loop -t ext2 /var/lib/pacman.db /var/lib/pacman
24 if [ $? -gt 0 ]; then
25 stat_fail
26 echo
27 echo "WARNING: MOUNTING PACMAN DATABASE FAILED"
28 echo
29 # write to pacman.log
30 echo "[ $(date "+%Y-%m-%d %H:%M ")] Pacman-cage [rc] >> WARNING: Mounting of the pacman database failed!" >> ${pacmanlog}
31 else
32 stat_done
33 add_daemon pacmandb
34 # write to pacman.log
35 echo "[ $(date "+%Y-%m-%d %H:%M ")] Pacman-cage [rc] >> Pacman database successfully mounted." >> ${pacmanlog}
40 stop)
41 stat_busy "Unmounting the pacman database"
42 umount /var/lib/pacman >/dev/null 2>&1
43 if [ $? -ne 0 ]; then
44 # write to pacman.log
45 echo "[ $(date "+%Y-%m-%d %H:%M ")] Pacman-cage [rc] >> WARNING: Umounting of the pacman database failed!" >> ${pacmanlog}
46 stat_fail
47 else
48 stat_done
49 rm_daemon pacmandb
50 # write to pacman.log
51 echo "[ $(date "+%Y-%m-%d %H:%M ")] Pacman-cage [rc] >> Pacman database successfully unmounted." >> ${pacmanlog}
55 restart)
56 $0 stop
57 sleep 2
58 $0 start
62 echo "usage: $0 {start|stop|restart}"
64 esac