]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
openvpn-n2n: Implement deleting RRD databases
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Mar 2024 13:43:46 +0000 (14:43 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Jun 2025 19:45:52 +0000 (19:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/openvpn-n2n

index ee98078af580d99dfa5050fc25f3afc1d83bca0a..0febfe32dc63ddad8e64689bf55ef0faf2339cc2 100644 (file)
@@ -290,6 +290,34 @@ status() {
        fi
 }
 
+delete() {
+       local name="${1}"
+
+       local id
+       local enabled
+       local _name
+       local x3
+       local type
+       local rest
+
+       local IFS=,
+
+       # Read the connection
+       while read -r id enabled _name x3 type rest; do
+               if [ "${name}" = "${_name}" ]; then
+                       case "${type}" in
+                               host)
+                                       rm -rf "/var/log/rrd/collectd/localhost/openvpn-${name}/"
+                                       ;;
+
+                               net)
+                                       rm -rf "/var/log/rrd/collectd/localhost/openvpn-${name}-n2n/"
+                                       ;;
+                       esac
+               fi
+       done < /var/ipfire/ovpn/ovpnconfig
+}
+
 case "${1}" in
        start)
                # Update all firewall rules
@@ -326,6 +354,10 @@ case "${1}" in
                all_connections status "${@:2}"
                ;;
 
+       delete)
+               delete "${2}"
+               ;;
+
        *)
                echo "Usage: ${0} {start|stop|reload|restart|status}"
                exit 1