#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2006-2012 OpenWrt.org
|
|
# Copyright (C) 2014 Zhao, Gang <gang.zhao.42@gmail.com>
|
|
|
|
START=99
|
|
|
|
USE_PROCD=1
|
|
PROG=/usr/bin/sslocal
|
|
|
|
validate_section_sslocal() {
|
|
uci_validate_section sslocal sslocal "${1}" \
|
|
'server_addr:host' \
|
|
'server_port:port' \
|
|
'local_addr:host' \
|
|
'local_port:port' \
|
|
'password:string' \
|
|
'method:string' \
|
|
'log_level:range(0,7):5'
|
|
|
|
return $?
|
|
}
|
|
|
|
sslocal_instance() {
|
|
local server_addr server_port local_addr local_port
|
|
local password method log_level
|
|
|
|
validate_section_sslocal "${1}" || {
|
|
echo "validation failed"
|
|
return 1
|
|
}
|
|
|
|
procd_open_instance
|
|
procd_set_param command "$PROG"
|
|
procd_append_param command -s "${server_addr}" -p "${server_port}"
|
|
procd_append_param command -u "${local_addr}" -b "${local_port}"
|
|
procd_append_param command -k "${password}" -m "${method}"
|
|
procd_append_param command -l "${log_level}"
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
}
|
|
|
|
start_service() {
|
|
config_load sslocal
|
|
|
|
config_foreach sslocal_instance sslocal
|
|
}
|
|
|
|
service_triggers()
|
|
{
|
|
procd_add_reload_trigger "sslocal"
|
|
procd_add_validation validate_section_sslocal
|
|
}
|