Update to 0.1.1 and add an init script
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
56
glorytun/init
Executable file
56
glorytun/init
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
PROG_NAME=glorytun
|
||||
PROG=/usr/sbin/$PROG_NAME
|
||||
|
||||
validate_section() {
|
||||
uci_validate_section $PROG_NAME $PROG_NAME "$1" \
|
||||
'enable:bool:0' \
|
||||
'key:string' \
|
||||
'server:host' \
|
||||
'port:port' \
|
||||
'dev:string'
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local enable key server port dev
|
||||
|
||||
validate_section "$1" || return
|
||||
[ "$enable" = "1" ] || return 0
|
||||
[ "$key" ] || return
|
||||
[ "$server" ] || return
|
||||
[ "$port" ] || return
|
||||
|
||||
keyfile="/tmp/$PROG_NAME.key"
|
||||
( umask 077; echo "$key" > "$keyfile" )
|
||||
key=""
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command $PROG \
|
||||
bind "0.0.0.0" "$port" \
|
||||
to "$server" "$port" \
|
||||
keyfile "$keyfile" \
|
||||
${dev:+dev "$dev"}
|
||||
|
||||
procd_set_param respawn 0 30 0
|
||||
procd_set_param file "$keyfile"
|
||||
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load glorytun
|
||||
config_foreach start_instance mud
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger glorytun
|
||||
}
|
||||
Reference in New Issue
Block a user