Skip to content

Commit

Permalink
fix visibility of configuration options starting with a number, impro…
Browse files Browse the repository at this point in the history
…ve readme
  • Loading branch information
vergoh committed Dec 29, 2023
1 parent d6d47ad commit f0c379a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- <https://humdi.net/vnstat/man/vnstat.html>
- <https://humdi.net/vnstat/man/vnstati.html>
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ 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
mkdir -m 0755 -p "$CFG_DIR"
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:]')
Expand All @@ -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')
Expand Down

0 comments on commit f0c379a

Please sign in to comment.