packages/openvpn: use new service functions, change 'enable' option to 'enabled' like most other services are using
git-svn-id: svn://svn.openwrt.org/openwrt/packages@29167 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
62db3b32f6
commit
d8e3724a5e
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=openvpn
|
PKG_NAME:=openvpn
|
||||||
PKG_VERSION:=2.2.1
|
PKG_VERSION:=2.2.1
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases @SF/openvpn
|
PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases @SF/openvpn
|
||||||
|
@ -7,7 +7,7 @@ package openvpn
|
|||||||
config openvpn custom_config
|
config openvpn custom_config
|
||||||
|
|
||||||
# Set to 1 to enable this instance:
|
# Set to 1 to enable this instance:
|
||||||
option enable 0
|
option enabled 0
|
||||||
|
|
||||||
# Include OpenVPN configuration
|
# Include OpenVPN configuration
|
||||||
option config /etc/openvpn/my-vpn.conf
|
option config /etc/openvpn/my-vpn.conf
|
||||||
@ -21,7 +21,7 @@ config openvpn custom_config
|
|||||||
config openvpn sample_server
|
config openvpn sample_server
|
||||||
|
|
||||||
# Set to 1 to enable this instance:
|
# Set to 1 to enable this instance:
|
||||||
option enable 0
|
option enabled 0
|
||||||
|
|
||||||
# Which local IP address should OpenVPN
|
# Which local IP address should OpenVPN
|
||||||
# listen on? (optional)
|
# listen on? (optional)
|
||||||
@ -292,7 +292,7 @@ config openvpn sample_server
|
|||||||
config openvpn sample_client
|
config openvpn sample_client
|
||||||
|
|
||||||
# Set to 1 to enable this instance:
|
# Set to 1 to enable this instance:
|
||||||
option enable 0
|
option enabled 0
|
||||||
|
|
||||||
# Specify that we are a client and that we
|
# Specify that we are a client and that we
|
||||||
# will be pulling certain config file directives
|
# will be pulling certain config file directives
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# OpenVPN init script
|
# Copyright (C) 2008-2011 OpenWrt.org
|
||||||
# Copyright (C) 2008 Jo-Philipp Wich
|
# Copyright (C) 2008 Jo-Philipp Wich
|
||||||
# This is free software, licensed under the GNU General Public License v2.
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
|
|
||||||
START=95
|
START=95
|
||||||
BIN=/usr/sbin/openvpn
|
|
||||||
SSD=start-stop-daemon
|
SERVICE_DAEMONIZE=1
|
||||||
|
SERVICE_WRITE_PID=1
|
||||||
|
|
||||||
EXTRA_COMMANDS="up down"
|
EXTRA_COMMANDS="up down"
|
||||||
|
|
||||||
LIST_SEP="
|
LIST_SEP="
|
||||||
@ -55,15 +57,16 @@ append_params_quoted() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
section_enabled() {
|
||||||
|
config_get_bool enabled "$1" 'enabled' 0
|
||||||
|
[ $enabled -gt 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
local s="$1"
|
local s="$1"
|
||||||
local enable=0
|
|
||||||
|
|
||||||
# disabled?
|
section_enabled "$s" || return 1
|
||||||
config_get_bool enable "$s" enable 0
|
|
||||||
[ "$enable" == 0 ] && return 0
|
|
||||||
|
|
||||||
PID="/var/run/openvpn-$s.pid"
|
|
||||||
ARGS=""
|
ARGS=""
|
||||||
|
|
||||||
# append flags
|
# append flags
|
||||||
@ -104,67 +107,63 @@ start_service() {
|
|||||||
down push up
|
down push up
|
||||||
|
|
||||||
|
|
||||||
[ -n "$ARGS" ] && \
|
SERVICE_PID_FILE="/var/run/openvpn-$s.pid" \
|
||||||
eval "$SSD -q -b -p '$PID' -x $BIN -S -- --syslog 'openvpn($s)' --writepid '$PID' $ARGS"
|
service_start /usr/sbin/openvpn --syslog "openvpn($s)" --writepid "$SERVICE_PID_FILE" $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
kill_service() {
|
stop_instance() {
|
||||||
local s="$1"
|
local s="$1"
|
||||||
local S="${2:-TERM}"
|
|
||||||
local enable=0
|
|
||||||
|
|
||||||
# disabled?
|
section_enabled "$s" || return 1
|
||||||
config_get_bool enable "$s" enable 0
|
|
||||||
[ "$enable" == 1 ] || [ "$S" == "TERM" ] || return 0
|
|
||||||
|
|
||||||
PID="/var/run/openvpn-$s.pid"
|
SERVICE_PID_FILE="/var/run/openvpn-$s.pid" \
|
||||||
|
service_stop /usr/sbin/openvpn
|
||||||
$SSD -q -p $PID -x $BIN -K -s $S
|
|
||||||
[ "$S" == "TERM" ] && rm -f "$PID"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hup_service() { kill_service "$1" HUP; }
|
reload_instance() {
|
||||||
stop_service() { kill_service "$1" TERM; }
|
local s="$1"
|
||||||
|
|
||||||
|
section_enabled "$s" || return 1
|
||||||
|
|
||||||
|
SERVICE_PID_FILE="/var/run/openvpn-$s.pid" \
|
||||||
|
service_reload /usr/sbin/openvpn
|
||||||
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
config_load openvpn
|
config_load 'openvpn'
|
||||||
config_foreach start_service openvpn
|
config_foreach start_instance 'openvpn'
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
config_load openvpn
|
config_load 'openvpn'
|
||||||
config_foreach stop_service openvpn
|
config_foreach stop_instance 'openvpn'
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
config_load openvpn
|
config_load 'openvpn'
|
||||||
config_foreach hup_service openvpn
|
config_foreach reload_instance 'openvpn'
|
||||||
}
|
|
||||||
|
|
||||||
restart() {
|
|
||||||
stop; sleep 5; start
|
|
||||||
}
|
}
|
||||||
|
|
||||||
up() {
|
up() {
|
||||||
local exists
|
local exists
|
||||||
local INSTANCE
|
local instance
|
||||||
config_load openvpn
|
config_load 'openvpn'
|
||||||
for INSTANCE in "$@"; do
|
for instance in "$@"; do
|
||||||
config_get exists "$INSTANCE" TYPE
|
config_get exists "$instance" 'TYPE'
|
||||||
if [ "$exists" == "openvpn" ]; then
|
if [ "$exists" == "openvpn" ]; then
|
||||||
start_service "$INSTANCE"
|
start_instance "$instance"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
down() {
|
down() {
|
||||||
local exists
|
local exists
|
||||||
local INSTANCE
|
local instance
|
||||||
config_load openvpn
|
config_load 'openvpn'
|
||||||
for INSTANCE in "$@"; do
|
for instance in "$@"; do
|
||||||
config_get exists "$INSTANCE" TYPE
|
config_get exists "$instance" 'TYPE'
|
||||||
if [ "$exists" == "openvpn" ]; then
|
if [ "$exists" == "openvpn" ]; then
|
||||||
stop_service "$INSTANCE"
|
stop_instance "$instance"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user