diff --git a/README.md b/README.md index fdf932a..f03e2f9 100644 --- a/README.md +++ b/README.md @@ -48,15 +48,17 @@ the `snap` command directly. For vnStat, the commands are: All the configuration options in Snap mirror the same names as in the vnStat configuration file but in full lower case. From vnStat's perspective, the active configuration can be -queried with `vnstat --showconfig`. A restart of the daemon is needed after changing -daemon related configuration options. See the [vnstat.conf man page](https://humdi.net/vnstat/man/vnstat.conf.html) -for longer description for each option. +queried with `vnstat --showconfig`. A restart of the daemon (`sudo snap restart vnstat`) +is needed after changing daemon related configuration options. See the +[vnstat.conf man page](https://humdi.net/vnstat/man/vnstat.conf.html) for longer descriptions +of each option. ## Known limitations - `vnstati` (image output) command is available as `vnstat.image` - `vnstat.image` can't write files due to snap sandbox restriction - use `-o - >file.png` as a workaround +- `sudo snap restart vnstat` is required after changing daemon related configuration options - man pages aren't available, use these these instead: - - @@ -75,7 +77,7 @@ vnStat is published on two snap channels: - the version string consists of two `-` separated fields: 1. vnStat release version 2. commit identifier for current repository -- `latest/edge` - tracks the latest commit in the [vnStat GitHub repository](https://github.com/vergoh/vnstat) +- `latest/edge` - tracks the latest all tests passing commit in the [vnStat GitHub repository](https://github.com/vergoh/vnstat) - can be selected using the `--edge` parameter - the version string consists of four `-` separated fields: 1. vnStat release version diff --git a/snap/hooks/configure b/snap/hooks/configure index 87c06bf..299dd49 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -5,6 +5,8 @@ CFG_DIR="$SNAP_DATA/options" CFG_FILE="$CFG_DIR/config" LOCKED="^DatabaseDir |^DaemonGroup |^DaemonUser |^LogFile |^PidFile " +# currently out of scope: automatically restarting service when daemon specific keys are changed + # new install, no existing configuration -> generate it and populate also key/values in snap if [ ! -d "$CFG_DIR" ] || [ ! -f "$CFG_FILE" ]; then # shellcheck disable=SC2174 @@ -12,7 +14,7 @@ if [ ! -d "$CFG_DIR" ] || [ ! -f "$CFG_FILE" ]; then touch "$CFG_FILE" chmod 644 "$CFG_FILE" echo "DatabaseDir \"$DBDIR\"" >"$CFG_FILE" - vnstat --showconfig | sed -e 's:^;::g' -e 's: *: :g' | grep -E '^[A-Za-z]' | grep -v -E "$LOCKED" | sort | while read -r cfgline + vnstat --showconfig | sed -e 's:^;::g' -e 's: *: :g' | grep -E '^[A-Z0-9]' | grep -v -E "$LOCKED" | sort | while read -r cfgline do native_key=$(echo "$cfgline" | cut -d" " -f1) snap_key=$(echo "$native_key" | tr '[:upper:]' '[:lower:]') @@ -32,7 +34,7 @@ else # --config parameter shouldn't be used here, that way the native_value variable gets the default value # which can then be restored to snap if the user used "snap unset" for a certain value, otherwise # the previously used value would get restored and "snap unset" wouldn't have any effect - vnstat --showconfig | sed -e 's:^;::g' -e 's: *: :g' | grep -E '^[A-Za-z]' | grep -v -E "$LOCKED" | sort | while read -r cfgline + vnstat --showconfig | sed -e 's:^;::g' -e 's: *: :g' | grep -E '^[A-Z0-9]' | grep -v -E "$LOCKED" | sort | while read -r cfgline do native_key=$(echo "$cfgline" | cut -d" " -f1) native_value=$(echo "$cfgline" | cut -d" " -f2- | sed 's:\"::g')