Ticket #96: 0002-Make-init-script-start-openvpn-for-each-.ovpn-in-add.patch

File 0002-Make-init-script-start-openvpn-for-each-.ovpn-in-add.patch, 1.9 KB (added by Ville Skyttä, 11 years ago)
  • sample-scripts/openvpn.init

    From 61c5dae777217183f1779f2b8f91f02b141cf744 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
    Date: Mon, 28 Feb 2011 23:34:18 +0200
    Subject: [PATCH 2/2] Make init script start openvpn for each *.ovpn in addition to *.conf.
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    
    Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
    ---
     sample-scripts/openvpn.init |   12 ++++++------
     1 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/sample-scripts/openvpn.init b/sample-scripts/openvpn.init
    index 821abd5..5de748d 100755
    a b  
    1919#   copy this file to /etc/rc.d/init.d/openvpn
    2020#   shell> chkconfig --add openvpn
    2121#   shell> mkdir /etc/openvpn
    22 #   make .conf or .sh files in /etc/openvpn (see below)
     22#   create .conf or .ovpn and optionally .sh files in /etc/openvpn (see below)
    2323
    2424# To uninstall:
    2525#   run: chkconfig --del openvpn
     
    3333#
    3434# The init script does the following:
    3535#
    36 # - Starts an openvpn process for each .conf file it finds in
     36# - Starts an openvpn process for each .conf and .ovpn file it finds in
    3737#   /etc/openvpn.
    3838#
    39 # - If /etc/openvpn/xxx.sh exists for a xxx.conf file then it executes
     39# - If /etc/openvpn/xxx.sh exists for a xxx.conf or xxx.ovpn then it executes
    4040#   it before starting openvpn (useful for doing openvpn --mktun...).
    4141#
    4242# - In addition to start/stop you can do:
    case "$1" in 
    142142        rm -f $piddir/*.pid
    143143        cd $work
    144144
    145         # Start every .conf in $work and run .sh if exists
     145        # Start every .conf and .ovpn in $work and run .sh if exists
    146146        errors=0
    147147        successes=0
    148         for c in `/bin/ls *.conf 2>/dev/null`; do
    149             bn=${c%%.conf}
     148        for c in `/bin/ls *.conf *.ovpn 2>/dev/null`; do
     149            bn=${c%%.conf}; [ "$bn" = "$c" ] && bn=${c%%.ovpn}
    150150            if [ -f "$bn.sh" ]; then
    151151                . $bn.sh
    152152            fi