]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
initscripts: Add an initscript for OpenVPN RW
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Mar 2024 16:58:46 +0000 (17:58 +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>
config/rootfiles/common/aarch64/initscripts
config/rootfiles/common/riscv64/initscripts
config/rootfiles/common/x86_64/initscripts
lfs/initscripts
src/initscripts/system/openvpn-rw [new file with mode: 0644]

index 12898701abe26b3d3f062318d638624cc115a17c..dd4b91a48bd3c29a7e1a9f39ce867416a067da3e 100644 (file)
@@ -70,6 +70,7 @@ etc/rc.d/init.d/networking/red.up/99-fireinfo
 etc/rc.d/init.d/networking/red.up/99-pakfire-update
 etc/rc.d/init.d/networking/wpa_supplicant.exe
 etc/rc.d/init.d/ntp
+etc/rc.d/init.d/openvpn-rw
 etc/rc.d/init.d/pakfire
 etc/rc.d/init.d/partresize
 etc/rc.d/init.d/rc
@@ -98,6 +99,7 @@ etc/rc.d/init.d/wlanclient
 etc/rc.d/rc0.d/K01grub-btrfsd
 #etc/rc.d/rc0.d/K01vdradmin
 etc/rc.d/rc0.d/K08fcron
+etc/rc.d/rc0.d/K10openvpn-rw
 etc/rc.d/rc0.d/K28apache
 etc/rc.d/rc0.d/K30sshd
 etc/rc.d/rc0.d/K47setclock
@@ -135,6 +137,7 @@ etc/rc.d/rc3.d/S24cyrus-sasl
 etc/rc.d/rc3.d/S30sshd
 etc/rc.d/rc3.d/S32apache
 etc/rc.d/rc3.d/S40fcron
+etc/rc.d/rc3.d/S50openvpn-rw
 etc/rc.d/rc3.d/S50wireguard
 etc/rc.d/rc3.d/S98rc.local
 etc/rc.d/rc3.d/S99grub-btrfsd
@@ -143,6 +146,7 @@ etc/rc.d/rc3.d/S99grub-btrfsd
 etc/rc.d/rc6.d/K01grub-btrfsd
 #etc/rc.d/rc6.d/K01vdradmin
 etc/rc.d/rc6.d/K08fcron
+etc/rc.d/rc6.d/K10openvpn-rw
 etc/rc.d/rc6.d/K28apache
 etc/rc.d/rc6.d/K30sshd
 etc/rc.d/rc6.d/K47setclock
index 11cfaf2be8fbf01aa35f672ded80f224952a9465..c88c54ac41009d926ad19a401ec14a1369dc801a 100644 (file)
@@ -70,6 +70,7 @@ etc/rc.d/init.d/networking/red.up/99-fireinfo
 etc/rc.d/init.d/networking/red.up/99-pakfire-update
 etc/rc.d/init.d/networking/wpa_supplicant.exe
 etc/rc.d/init.d/ntp
+etc/rc.d/init.d/openvpn-rw
 etc/rc.d/init.d/pakfire
 etc/rc.d/init.d/partresize
 etc/rc.d/init.d/rc
@@ -97,6 +98,7 @@ etc/rc.d/init.d/wlanclient
 etc/rc.d/rc0.d/K01grub-btrfsd
 #etc/rc.d/rc0.d/K01vdradmin
 etc/rc.d/rc0.d/K08fcron
+etc/rc.d/rc0.d/K10openvpn-rw
 etc/rc.d/rc0.d/K28apache
 etc/rc.d/rc0.d/K30sshd
 etc/rc.d/rc0.d/K47setclock
@@ -134,6 +136,7 @@ etc/rc.d/rc3.d/S24cyrus-sasl
 etc/rc.d/rc3.d/S30sshd
 etc/rc.d/rc3.d/S32apache
 etc/rc.d/rc3.d/S40fcron
+etc/rc.d/rc3.d/S50openvpn-rw
 etc/rc.d/rc3.d/S50wireguard
 etc/rc.d/rc3.d/S98rc.local
 etc/rc.d/rc3.d/S99grub-btrfsd
@@ -142,6 +145,7 @@ etc/rc.d/rc3.d/S99grub-btrfsd
 etc/rc.d/rc6.d/K01grub-btrfsd
 #etc/rc.d/rc6.d/K01vdradmin
 etc/rc.d/rc6.d/K08fcron
+etc/rc.d/rc6.d/K10openvpn-rw
 etc/rc.d/rc6.d/K28apache
 etc/rc.d/rc6.d/K30sshd
 etc/rc.d/rc6.d/K47setclock
index 11cfaf2be8fbf01aa35f672ded80f224952a9465..c88c54ac41009d926ad19a401ec14a1369dc801a 100644 (file)
@@ -70,6 +70,7 @@ etc/rc.d/init.d/networking/red.up/99-fireinfo
 etc/rc.d/init.d/networking/red.up/99-pakfire-update
 etc/rc.d/init.d/networking/wpa_supplicant.exe
 etc/rc.d/init.d/ntp
+etc/rc.d/init.d/openvpn-rw
 etc/rc.d/init.d/pakfire
 etc/rc.d/init.d/partresize
 etc/rc.d/init.d/rc
@@ -97,6 +98,7 @@ etc/rc.d/init.d/wlanclient
 etc/rc.d/rc0.d/K01grub-btrfsd
 #etc/rc.d/rc0.d/K01vdradmin
 etc/rc.d/rc0.d/K08fcron
+etc/rc.d/rc0.d/K10openvpn-rw
 etc/rc.d/rc0.d/K28apache
 etc/rc.d/rc0.d/K30sshd
 etc/rc.d/rc0.d/K47setclock
@@ -134,6 +136,7 @@ etc/rc.d/rc3.d/S24cyrus-sasl
 etc/rc.d/rc3.d/S30sshd
 etc/rc.d/rc3.d/S32apache
 etc/rc.d/rc3.d/S40fcron
+etc/rc.d/rc3.d/S50openvpn-rw
 etc/rc.d/rc3.d/S50wireguard
 etc/rc.d/rc3.d/S98rc.local
 etc/rc.d/rc3.d/S99grub-btrfsd
@@ -142,6 +145,7 @@ etc/rc.d/rc3.d/S99grub-btrfsd
 etc/rc.d/rc6.d/K01grub-btrfsd
 #etc/rc.d/rc6.d/K01vdradmin
 etc/rc.d/rc6.d/K08fcron
+etc/rc.d/rc6.d/K10openvpn-rw
 etc/rc.d/rc6.d/K28apache
 etc/rc.d/rc6.d/K30sshd
 etc/rc.d/rc6.d/K47setclock
index 700e9124459fb0cb53b7f740c26f2a4bb2411f4e..75bf4c18f6f622cf7f7870f7ede920d97c121240 100644 (file)
@@ -95,6 +95,7 @@ $(TARGET) :
        ln -sf ../init.d/vdradmin               /etc/rc.d/rc0.d/K01vdradmin
        ln -sf ../init.d/fcron                  /etc/rc.d/rc0.d/K08fcron
        ln -sf ../init.d/apache                 /etc/rc.d/rc0.d/K28apache
+       ln -sf ../init.d/openvpn-rw             /etc/rc.d/rc0.d/K10openvpn-rw
        ln -sf ../init.d/sshd                   /etc/rc.d/rc0.d/K30sshd
        ln -sf ../init.d/setclock               /etc/rc.d/rc0.d/K47setclock
        ln -sf  ../init.d/cyrus-sasl            /etc/rc.d/rc0.d/K49cyrus-sasl
@@ -129,6 +130,7 @@ $(TARGET) :
        ln -sf ../init.d/sshd                   /etc/rc.d/rc3.d/S30sshd
        ln -sf ../init.d/apache                 /etc/rc.d/rc3.d/S32apache
        ln -sf ../init.d/fcron                  /etc/rc.d/rc3.d/S40fcron
+       ln -sf ../init.d/openvpn-rw             /etc/rc.d/rc3.d/S50openvpn-rw
        ln -sf ../init.d/wireguard              /etc/rc.d/rc3.d/S50wireguard
        ln -sf ../../sysconfig/rc.local         /etc/rc.d/rc3.d/S98rc.local
        ln -sf ../init.d/grub-btrfsd            /etc/rc.d/rc3.d/S99grub-btrfsd
@@ -137,6 +139,7 @@ $(TARGET) :
        ln -sf ../init.d/grub-btrfsd            /etc/rc.d/rc6.d/K01grub-btrfsd
        ln -sf ../init.d/vdradmin               /etc/rc.d/rc6.d/K01vdradmin
        ln -sf ../init.d/fcron                  /etc/rc.d/rc6.d/K08fcron
+       ln -sf ../init.d/openvpn-rw             /etc/rc.d/rc6.d/K10openvpn-rw
        ln -sf ../init.d/apache                 /etc/rc.d/rc6.d/K28apache
        ln -sf ../init.d/sshd                   /etc/rc.d/rc6.d/K30sshd
        ln -sf ../init.d/setclock               /etc/rc.d/rc6.d/K47setclock
diff --git a/src/initscripts/system/openvpn-rw b/src/initscripts/system/openvpn-rw
new file mode 100644 (file)
index 0000000..82cf352
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007-2022  IPFire Team  <info@ipfire.org>                     #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+PIDFILE="/var/run/openvpn.pid"
+
+# Load configuration
+eval $(/usr/local/bin/readhash /var/ipfire/ovpn/settings)
+
+case "${1}" in
+       start)
+               # Exit if OpenVPN is not enabled
+               if [ "${ENABLED}" != "on" ]; then
+                       exit 0
+               fi
+
+               # Flush all firewall rules
+               iptables -F OVPNINPUTRW
+
+               # Open the port
+               iptables -A OVPNINPUTRW \
+                       -p "${DPROTOCOL}" --dport "${DDEST_PORT}" -j ACCEPT
+
+               boot_mesg "Starting OpenVPN Roadwarrior Server..."
+               loadproc /usr/sbin/openvpn \
+                       --config /var/ipfire/ovpn/server.conf
+               ;;
+
+       stop)
+               boot_mesg "Stopping OpenVPN Roadwarrior Server..."
+               killproc /usr/sbin/openvpn
+
+               # Flush all firewall rules
+               iptables -F OVPNINPUTRW
+               ;;
+
+       reload)
+               boot_mesg "Reloading OpenVPN Roadwarrior Server..."
+               reloadproc /usr/sbin/openvpn
+               ;;
+
+       restart)
+               ${0} stop
+               sleep 1
+               ${0} start
+               ;;
+
+       status)
+               statusproc /usr/sbin/openvpn
+               ;;
+
+       *)
+               echo "Usage: ${0} {start|stop|reload|restart|status}"
+               exit 1
+               ;;
+esac