]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/system/vnstat
999307d9971a81f3b5a523734c07bb55a1a11291
[people/pmueller/ipfire-2.x.git] / src / initscripts / system / vnstat
1 #!/bin/sh
2 # Begin $rc_base/init.d/vnstat
3
4 . /etc/sysconfig/rc
5 . $rc_functions
6
7 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
8
9 if [ "$VNSTATLOG" = '' ]; then
10 VNSTATLOG=/var/log/vnstat
11 fi
12
13 case "$1" in
14 start)
15 if use_ramdisk; then
16 boot_mesg "Mounting vnstat ramdisk..."
17 mount_ramdisk "${VNSTATLOG}"
18 evaluate_retval
19 fi
20
21 boot_mesg "Starting vnstatd..."
22 loadproc /usr/sbin/vnstatd -d --alwaysadd
23 evaluate_retval
24 ;;
25
26 stop)
27 boot_mesg "Stopping vnstatd..."
28 killproc /usr/sbin/vnstatd
29 evaluate_retval
30
31 umount_ramdisk "${VNSTATLOG}"
32 boot_mesg "Unmounting vnstat ramdisk..."
33 evaluate_retval
34 ;;
35
36 restart)
37 ${0} stop
38 sleep 1
39 ${0} start
40 ;;
41
42 backup)
43 # Backup all data if ramdisk is used
44 if mountpoint "${RRDLOG}" &>/dev/null; then
45 ${0} restart
46 fi
47 ;;
48
49 *)
50 echo "Usage: $0 {start|stop|restart|backup}"
51 exit 1
52 ;;
53 esac
54
55 # End $rc_base/init.d/vnstat