2006-10-04 20:57:49 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2011-11-03 16:05:38 +00:00
|
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
2010-04-14 23:22:08 +00:00
|
|
|
START=51
|
2006-07-30 15:51:45 +00:00
|
|
|
|
2011-11-03 16:05:38 +00:00
|
|
|
add_config_bool() {
|
|
|
|
local section="$1"
|
|
|
|
local option="$2"
|
|
|
|
local value="$3"
|
|
|
|
local default="$4"
|
|
|
|
local _val
|
2008-09-24 15:01:43 +00:00
|
|
|
|
2011-11-03 16:05:38 +00:00
|
|
|
config_get_bool _val "$section" "$option" "$default"
|
|
|
|
[ "$_val" -gt 0 ] && _val="true" || _val="false"
|
|
|
|
append args "$3 $_val" "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
add_config() {
|
|
|
|
local section="$1"
|
|
|
|
local option="$2"
|
|
|
|
local value="$3"
|
|
|
|
local _val
|
|
|
|
|
|
|
|
config_get _val "$section" "$option"
|
|
|
|
[ -n "$_val" ] && append args "$3 $_val" "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
start_instance() {
|
|
|
|
local cfg="$1"
|
|
|
|
CFGFILE="/var/etc/aiccu-${cfg}.conf"
|
|
|
|
PIDFILE="/var/run/aiccu-${cfg}.pid"
|
|
|
|
args=""
|
2011-11-03 17:19:43 +00:00
|
|
|
|
2011-11-03 16:05:38 +00:00
|
|
|
add_config "$cfg" username username
|
|
|
|
add_config "$cfg" password password
|
|
|
|
add_config "$cfg" server server
|
|
|
|
add_config "$cfg" protocol protocol
|
|
|
|
add_config "$cfg" interface ipv6_interface
|
|
|
|
add_config "$cfg" tunnel_id tunnel_id
|
|
|
|
add_config_bool "$cfg" requiretls requiretls 0
|
|
|
|
add_config_bool "$cfg" defaultroute defaultroute 1
|
|
|
|
add_config_bool "$cfg" nat behindnat 1
|
|
|
|
add_config_bool "$cfg" heartbeat makebeats 1
|
|
|
|
append args "daemonize true" "\n"
|
|
|
|
append args "pidfile $PIDFILE" "\n"
|
|
|
|
|
2011-11-03 17:19:43 +00:00
|
|
|
mkdir -p /var/run /var/etc
|
2011-11-03 16:05:38 +00:00
|
|
|
echo -e "$args" > "$CFGFILE"
|
|
|
|
|
|
|
|
config_get_bool enabled "$cfg" enabled '1'
|
2011-11-07 03:43:40 +00:00
|
|
|
[ "$enabled" -gt 0 ] && aiccu start "$CFGFILE" &
|
2011-11-03 16:05:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_instance() {
|
|
|
|
local cfg="$1"
|
2011-11-03 17:30:09 +00:00
|
|
|
aiccu stop "/var/etc/aiccu-${cfg}.conf"
|
2011-11-03 16:05:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
restart_instance() {
|
|
|
|
local cfg="$1"
|
2011-11-03 16:05:42 +00:00
|
|
|
config_get_bool restart "$cfg" restart 0
|
|
|
|
[ "$restart" -eq 1 ] && stop_instance "$cfg"
|
2011-11-03 16:05:38 +00:00
|
|
|
start_instance "$cfg"
|
2008-09-24 15:01:43 +00:00
|
|
|
}
|
|
|
|
|
2006-10-04 20:57:49 +00:00
|
|
|
start() {
|
2008-09-24 15:01:43 +00:00
|
|
|
config_load aiccu
|
2011-11-03 16:05:38 +00:00
|
|
|
config_foreach start_instance aiccu
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|
2006-07-30 15:51:45 +00:00
|
|
|
|
2006-10-04 20:57:49 +00:00
|
|
|
stop() {
|
2008-10-06 12:45:30 +00:00
|
|
|
config_load aiccu
|
2011-11-03 16:05:38 +00:00
|
|
|
config_foreach stop_instance aiccu
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|
2011-11-03 16:05:38 +00:00
|
|
|
|
|
|
|
restart() {
|
|
|
|
config_load aiccu
|
|
|
|
config_foreach restart_instance aiccu
|
2011-11-03 17:19:43 +00:00
|
|
|
}
|