openconnect: move certificate files to config/ to add graceful upgrade
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 10 Jan 2015 10:12:33 +0000 (11:12 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 10 Jan 2015 10:12:33 +0000 (11:12 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
net/openconnect/README
net/openconnect/files/openconnect.sh

index 3cd562194adcf4e9478f2c7005e72521f113ef69..11e98f5ea779d188cb9ba1ae02866c08d0a5160f 100644 (file)
@@ -14,9 +14,9 @@ config interface 'MYVPN'
         option authgroup 'DEFAULT'
 
 The additional files are also used:
-/etc/openconnect/user-cert-vpn-MYVPN.pem: The user certificate
-/etc/openconnect/user-key-vpn-MYVPN.pem: The user private key
-/etc/openconnect/ca-vpn-MYVPN.pem: The CA certificate (instead of serverhash)
+/etc/config/openconnect-user-cert-vpn-MYVPN.pem: The user certificate
+/etc/config/openconnect-user-key-vpn-MYVPN.pem: The user private key
+/etc/config/openconnect-ca-vpn-MYVPN.pem: The CA certificate (instead of serverhash)
 
 After these are setup you can initiate the VPN using "ifup MYVPN", and
 deinitialize it using ifdown. You may also use the luci web interface
index 553a4ed51ac4a82fdae4413f42bad8e8f6489543..2d3f7141cade06ecb28f0539225f243bd00bab83 100755 (executable)
@@ -38,12 +38,19 @@ proto_openconnect_setup() {
 
        cmdline="$server$port -i vpn-$config --non-inter --syslog --script /lib/netifd/vpnc-script"
 
-       [ -f /etc/openconnect/user-cert-vpn-$config.pem ] && append cmdline "-c /etc/openconnect/user-cert-vpn-$config.pem"
-       [ -f /etc/openconnect/user-key-vpn-$config.pem ] && append cmdline "--sslkey /etc/openconnect/user-key-vpn-$config.pem"
-       [ -f /etc/openconnect/ca-vpn-$config.pem ] && {
+       # migrate to new config files
+       [ -f /etc/openconnect/user-cert-vpn-$config.pem ] && mv "/etc/openconnect/user-cert-vpn-$config.pem" "/etc/config/openconnect-user-cert-vpn-$config.pem"
+       [ -f /etc/openconnect/user-key-vpn-$config.pem ] && mv "/etc/openconnect/user-key-vpn-$config.pem" "/etc/config/openconnect-user-key-vpn-$config.pem"
+       [ -f /etc/openconnect/ca-vpn-$config.pem ] && mv "/etc/openconnect/ca-vpn-$config.pem" "/etc/config/openconnect-ca-vpn-$config.pem"
+
+       # read new config files
+       [ -f /etc/config/openconnect-user-cert-vpn-$config.pem ] && append cmdline "-c /etc/config/openconnect-user-cert-vpn-$config.pem"
+       [ -f /etc/config/openconnect-user-key-vpn-$config.pem ] && append cmdline "--sslkey /etc/config/openconnect-user-key-vpn-$config.pem"
+       [ -f /etc/config/openconnect-ca-vpn-$config.pem ] && {
                append cmdline "--cafile /etc/openconnect/ca-vpn-$config.pem"
                append cmdline "--no-system-trust"
        }
+
        [ -n "$serverhash" ] && {
                append cmdline " --servercert=$serverhash"
                append cmdline "--no-system-trust"