]> git.ipfire.org Git - people/stevee/network.git/commitdiff
ipsec: Add commands to bring connections up and down
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 11:59:04 +0000 (11:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 11:59:04 +0000 (11:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.ipsec

index 70931ed984b8e80f8ed25aa2c3890ed0f16a6b4f..5fc8b081ae37c70df0d56f824bcae008b6daf6f6 100644 (file)
@@ -61,7 +61,7 @@ cli_ipsec_connection() {
                shift 2
 
                case "${key}" in
-                       authentication|dpd|inactivity_timeout|local|mode|peer|remote|security_policy|start_action)
+                       authentication|down|dpd|inactivity_timeout|local|mode|peer|remote|security_policy|start_action|up)
                                ipsec_connection_${key} ${connection} $@
                                ;;
                        show)
@@ -363,6 +363,27 @@ ipsec_connection_authentication_psk() {
        return ${EXIT_OK}
 }
 
+ipsec_connection_up() {
+       local connection="${1}"
+
+       if ! ipsec_connection_exists "${connection}"; then
+               error "No such VPN IPsec connection: ${connection}"
+               return ${EXIT_ERROR}
+       fi
+
+       cmd swanctl --initiate --child "${connection}"
+}
+
+ipsec_connection_down() {
+       local connection="${1}"
+
+       if ! ipsec_connection_exists "${connection}"; then
+               error "No such VPN IPsec connection: ${connection}"
+               return ${EXIT_ERROR}
+       fi
+
+       cmd swanctl --terminate --ike "${connection}"
+}
 
 # Handle the cli after authentification
 ipsec_connection_dpd() {