diff --git a/.etckeeper b/.etckeeper index d61fbb20..98141964 100755 --- a/.etckeeper +++ b/.etckeeper @@ -691,6 +691,7 @@ maybe chmod 0755 'init.d/ssh' maybe chmod 0755 'init.d/sudo' maybe chmod 0755 'init.d/triggerhappy' maybe chmod 0755 'init.d/udev' +maybe chmod 0755 'init.d/vnstat' maybe chmod 0644 'init/bootmisc.sh.conf' maybe chmod 0644 'init/checkfs.sh.conf' maybe chmod 0644 'init/checkroot-bootclean.sh.conf' @@ -1122,6 +1123,8 @@ maybe chmod 0755 'usb_modeswitch.d' maybe chmod 0755 'vim' maybe chmod 0644 'vim/vimrc' maybe chmod 0644 'vim/vimrc.tiny' +maybe chgrp 'vnstat' 'vnstat.conf' +maybe chmod 0644 'vnstat.conf' maybe chmod 0644 'wgetrc' maybe chmod 0755 'wpa_supplicant' maybe chmod 0755 'wpa_supplicant/action_wpa.sh' diff --git a/group b/group index 0afded17..bce4f24c 100644 --- a/group +++ b/group @@ -57,3 +57,4 @@ jgdye:x:1000: bind:x:113: Debian-exim:x:114: duck:x:115: +vnstat:x:116: diff --git a/group- b/group- index ae14ffe6..0afded17 100644 --- a/group- +++ b/group- @@ -56,3 +56,4 @@ middle:x:1001: jgdye:x:1000: bind:x:113: Debian-exim:x:114: +duck:x:115: diff --git a/gshadow b/gshadow index 3554c2a2..0b932bc9 100644 --- a/gshadow +++ b/gshadow @@ -57,3 +57,4 @@ jgdye:!:: bind:!:: Debian-exim:!:: duck:!:: +vnstat:!:: diff --git a/gshadow- b/gshadow- index d676b9a6..3554c2a2 100644 --- a/gshadow- +++ b/gshadow- @@ -56,3 +56,4 @@ middle:!:: jgdye:!:: bind:!:: Debian-exim:!:: +duck:!:: diff --git a/init.d/vnstat b/init.d/vnstat new file mode 100755 index 00000000..74bd658f --- /dev/null +++ b/init.d/vnstat @@ -0,0 +1,69 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: vnstat +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: lightweight network traffic monitor +### END INIT INFO + +PATH=/usr/sbin:/usr/bin:/sbin:/bin +DESC="vnStat daemon" +NAME=vnstatd +PIDFILE=/run/vnstat/vnstat.pid +DAEMON=/usr/sbin/$NAME +DAEMON_ARGS="-d --pidfile $PIDFILE" +SCRIPTNAME=/etc/init.d/vnstat +USER=vnstat + +. /lib/lsb/init-functions + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + if [ ! -d /run/vnstat ]; then + mkdir /run/vnstat + fi + chown $USER:$USER /run/vnstat + start-stop-daemon --start --quiet --oknodo --chuid $USER \ + --exec $DAEMON -- $DAEMON_ARGS + log_end_msg $? + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + start-stop-daemon --stop --quiet --oknodo --retry=TERM/15/KILL/5 --pidfile $PIDFILE \ + --name $NAME + status=$? + rm -f $PIDFILE + log_end_msg $? + ;; + status) + pidofproc -p $PIDFILE $DAEMON >/dev/null + status=$? + + if [ $status -eq 0 ]; then + log_success_msg "$DESC is running" + else + log_failure_msg "$DESC is not running" + fi + exit $status + ;; + reload|force-reload) + log_daemon_msg "Reloading $DESC configuration..." + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + log_end_msg $? + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" + exit 1 + ;; +esac diff --git a/passwd b/passwd index 1712b36b..a21dabca 100644 --- a/passwd +++ b/passwd @@ -30,3 +30,4 @@ jgdye:x:1000:1000:Joshua Dye,,,:/home/jgdye:/usr/bin/zsh bind:x:109:113::/var/cache/bind:/usr/sbin/nologin Debian-exim:x:110:114::/var/spool/exim4:/usr/sbin/nologin duck:x:111:115::/home/duck:/usr/sbin/nologin +vnstat:x:112:116::/var/lib/vnstat:/usr/sbin/nologin diff --git a/passwd- b/passwd- index 1712b36b..a21dabca 100644 --- a/passwd- +++ b/passwd- @@ -30,3 +30,4 @@ jgdye:x:1000:1000:Joshua Dye,,,:/home/jgdye:/usr/bin/zsh bind:x:109:113::/var/cache/bind:/usr/sbin/nologin Debian-exim:x:110:114::/var/spool/exim4:/usr/sbin/nologin duck:x:111:115::/home/duck:/usr/sbin/nologin +vnstat:x:112:116::/var/lib/vnstat:/usr/sbin/nologin diff --git a/rc0.d/K01vnstat b/rc0.d/K01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc0.d/K01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/rc1.d/K01vnstat b/rc1.d/K01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc1.d/K01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/rc2.d/S01vnstat b/rc2.d/S01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc2.d/S01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/rc3.d/S01vnstat b/rc3.d/S01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc3.d/S01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/rc4.d/S01vnstat b/rc4.d/S01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc4.d/S01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/rc5.d/S01vnstat b/rc5.d/S01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc5.d/S01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/rc6.d/K01vnstat b/rc6.d/K01vnstat new file mode 120000 index 00000000..4c730037 --- /dev/null +++ b/rc6.d/K01vnstat @@ -0,0 +1 @@ +../init.d/vnstat \ No newline at end of file diff --git a/shadow b/shadow index 855695dd..6ab84bc3 100644 --- a/shadow +++ b/shadow @@ -30,3 +30,4 @@ jgdye:$6$taLG2n/D$WCkHqVIY3aICSXIeg9pfcjEHPX1WWlnTGO8SUqXfXM/3ns56GVKCwxeKvgvzLB bind:*:17452:0:99999:7::: Debian-exim:!:17452:0:99999:7::: duck:*:17452:0:99999:7::: +vnstat:*:17455:0:99999:7::: diff --git a/shadow- b/shadow- index 855695dd..6ab84bc3 100644 --- a/shadow- +++ b/shadow- @@ -30,3 +30,4 @@ jgdye:$6$taLG2n/D$WCkHqVIY3aICSXIeg9pfcjEHPX1WWlnTGO8SUqXfXM/3ns56GVKCwxeKvgvzLB bind:*:17452:0:99999:7::: Debian-exim:!:17452:0:99999:7::: duck:*:17452:0:99999:7::: +vnstat:*:17455:0:99999:7::: diff --git a/systemd/system/multi-user.target.wants/vnstat.service b/systemd/system/multi-user.target.wants/vnstat.service new file mode 120000 index 00000000..ce8d7a6e --- /dev/null +++ b/systemd/system/multi-user.target.wants/vnstat.service @@ -0,0 +1 @@ +/lib/systemd/system/vnstat.service \ No newline at end of file diff --git a/vnstat.conf b/vnstat.conf new file mode 100644 index 00000000..a8d79fab --- /dev/null +++ b/vnstat.conf @@ -0,0 +1,149 @@ +# vnStat 1.15 config file +## + +# default interface +Interface "eth0" + +# location of the database directory +DatabaseDir "/var/lib/vnstat" + +# locale (LC_ALL) ("-" = use system locale) +Locale "-" + +# on which day should months change +MonthRotate 1 + +# date output formats for -d, -m, -t and -w +# see 'man date' for control codes +DayFormat "%x" +MonthFormat "%b '%y" +TopFormat "%x" + +# characters used for visuals +RXCharacter "%" +TXCharacter ":" +RXHourCharacter "r" +TXHourCharacter "t" + +# how units are prefixed when traffic is shown +# 0 = IEC standard prefixes (KiB/MiB/GiB/TiB) +# 1 = old style binary prefixes (KB/MB/GB/TB) +UnitMode 0 + +# output style +# 0 = minimal & narrow, 1 = bar column visible +# 2 = same as 1 except rate in summary and weekly +# 3 = rate column visible +OutputStyle 3 + +# used rate unit (0 = bytes, 1 = bits) +RateUnit 1 + +# try to detect interface maximum bandwidth, 0 = disable feature +# MaxBandwidth will be used as fallback value when enabled +BandwidthDetection 1 + +# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature +# (unless interface specific limit is given) +MaxBandwidth 1000 + +# interface specific limits +# example 8Mbit limit for eth0 (remove # to activate): +#MaxBWeth0 8 + +# how many seconds should sampling for -tr take by default +Sampletime 5 + +# default query mode +# 0 = normal, 1 = days, 2 = months, 3 = top10 +# 4 = exportdb, 5 = short, 6 = weeks, 7 = hours +QueryMode 0 + +# filesystem disk space check (1 = enabled, 0 = disabled) +CheckDiskSpace 1 + +# database file locking (1 = enabled, 0 = disabled) +UseFileLocking 1 + +# how much the boot time can variate between updates (seconds) +BootVariation 15 + +# log days without traffic to daily list (1 = enabled, 0 = disabled) +TrafficlessDays 1 + + +# vnstatd +## + +# switch to given user when started as root (leave empty to disable) +DaemonUser "" + +# switch to given user when started as root (leave empty to disable) +DaemonGroup "" + +# how often (in seconds) interface data is updated +UpdateInterval 30 + +# how often (in seconds) interface status changes are checked +PollInterval 5 + +# how often (in minutes) data is saved to file +SaveInterval 5 + +# how often (in minutes) data is saved when all interface are offline +OfflineSaveInterval 30 + +# how often (in minutes) bandwidth detection is redone when +# BandwidthDetection is enabled (0 = disabled) +BandwidthDetectionInterval 5 + +# force data save when interface status changes (1 = enabled, 0 = disabled) +SaveOnStatusChange 1 + +# enable / disable logging (0 = disabled, 1 = logfile, 2 = syslog) +UseLogging 2 + +# create dirs if needed (1 = enabled, 0 = disabled) +CreateDirs 1 + +# update ownership of files if needed (1 = enabled, 0 = disabled) +UpdateFileOwner 1 + +# file used for logging if UseLogging is set to 1 +LogFile "/var/log/vnstat/vnstat.log" + +# file used as daemon pid / lock file +PidFile "/var/run/vnstat/vnstat.pid" + + +# vnstati +## + +# title timestamp format +HeaderFormat "%x %H:%M" + +# show hours with rate (1 = enabled, 0 = disabled) +HourlyRate 1 + +# show rate in summary (1 = enabled, 0 = disabled) +SummaryRate 1 + +# layout of summary (1 = with monthly, 0 = without monthly) +SummaryLayout 1 + +# transparent background (1 = enabled, 0 = disabled) +TransparentBg 0 + +# image colors +CBackground "FFFFFF" +CEdge "AEAEAE" +CHeader "606060" +CHeaderTitle "FFFFFF" +CHeaderDate "FFFFFF" +CText "000000" +CLine "B0B0B0" +CLineL "-" +CRx "92CF00" +CTx "606060" +CRxD "-" +CTxD "-"