openfortivpn: avoid flash writes on pppd script 12324/head
authorAaron Goodman <aaronjg@stanford.edu>
Wed, 27 May 2020 17:26:47 +0000 (13:26 -0400)
committerAaron Goodman <aaronjg@stanford.edu>
Thu, 4 Jun 2020 20:55:11 +0000 (16:55 -0400)
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
net/openfortivpn/files/openfortivpn.sh

index d69575230fedd9355a945fd44c445b52d50665d7..292ffd4b23741f92af258a6f5dee400e593c8955 100755 (executable)
@@ -92,13 +92,18 @@ proto_openfortivpn_setup() {
         [ -n "$password" ] && {
                 umask 077
                 mkdir -p /var/etc
-                pwfile="/var/etc/openfortivpn-$config.passwd"
+                pwfile="/var/etc/openfortivpn/$config.passwd"
                 echo "$password" > "$pwfile"
         }
 
         [ -n "$local_ip" ] || local_ip=192.0.2.1
-        mkdir -p '/etc/ppp/peers'
-        callfile="/etc/ppp/peers/$config"
+        [ -e '/etc/ppp/peers' ] || mkdir -p '/etc/ppp/peers'
+        [ -e '/etc/ppp/peers/openfortivpn' ] || {
+            ln -s -T '/var/etc/openfortivpn/peers' '/etc/ppp/peers/openfortivpn'
+            mkdir -p '/var/etc/openfortivpn/peers'
+        }
+
+        callfile="/var/etc/openfortivpn/peers/$config"
         echo "115200
 :$local_ip
 noipdefault
@@ -114,7 +119,7 @@ lcp-max-configure 40
 ip-up-script /lib/netifd/ppp-up
 ip-down-script /lib/netifd/ppp-down
 mru 1354"  > $callfile
-        append_args "--pppd-call=$config"
+        append_args "--pppd-call=openfortivpn/$config"
 
         proto_export INTERFACE="$ifname"
         logger -t openfortivpn "$config: executing 'openfortivpn $cmdline'"
@@ -127,8 +132,8 @@ mru 1354"  > $callfile
 proto_openfortivpn_teardown() {
         local config="$1"
 
-        pwfile="/var/etc/openfortivpn-$config.passwd"
-        callfile="/etc/ppp/peers/$config"
+        pwfile="/var/etc/openfortivpn/$config.passwd"
+        callfile="/var/etc/openfortivpn/peers/$config"
 
         rm -f $pwfile
         rm -f $callfile