]> git.ipfire.org Git - people/ms/ipfire-2.x.git/blob - src/initscripts/system/vnstat
vnstat 2.6: New initscript
[people/ms/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 sleep 2
24 evaluate_retval
25 ;;
26
27 stop)
28 boot_mesg "Stopping vnstatd..."
29 killproc /usr/sbin/vnstatd
30 sleep 2
31 evaluate_retval
32
33 umount_ramdisk "${VNSTATLOG}"
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