mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			71 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/sh /etc/rc.common
 | |
| 
 | |
| USE_PROCD=1
 | |
| START=99
 | |
| 
 | |
| BIN=/usr/sbin/rtty
 | |
| 
 | |
| validate_rtty_section() {
 | |
| 	uci_load_validate rtty rtty "$1" "$2" \
 | |
| 		'interface:uci("network", "@interface"):lan' \
 | |
| 		'id:maxlength(63)' \
 | |
| 		'description:maxlength(126)' \
 | |
| 		'host:host' \
 | |
| 		'port:port' \
 | |
| 		'ssl:bool:0' \
 | |
| 		'token:maxlength(32)' \
 | |
| 		'verbose:bool:0' \
 | |
| 		'enable:bool:0' \
 | |
| 		'timeout:uinteger:0'
 | |
| }
 | |
| 
 | |
| start_rtty() {
 | |
| 	. /lib/functions/network.sh
 | |
| 
 | |
| 	local ifname
 | |
| 
 | |
| 	[ "$2" = 0 ] || {
 | |
| 		echo "validation failed" >&2
 | |
| 		return 1
 | |
| 	}
 | |
| 
 | |
| 	[ $enable -eq 0 -a $interval -eq 0 ] && return 1
 | |
| 
 | |
| 	[ -n "$interface" ] && network_get_device ifname "$interface"
 | |
| 
 | |
| 	[ -z "$ifname" -a -z "$id" ] && {
 | |
| 		echo "You must specify an interface or ID" >&2
 | |
| 		return 1
 | |
| 	}
 | |
| 
 | |
| 	[ -z "$host" ] && {
 | |
| 		echo "host required" >&2
 | |
| 		return 1
 | |
| 	}
 | |
| 
 | |
| 	[ -z "$id" ] && {
 | |
| 		id=$(sed 's/://g' /sys/class/net/$ifname/address | tr 'a-z' 'A-Z')
 | |
| 	}
 | |
| 
 | |
| 	procd_open_instance
 | |
| 	procd_set_param command $BIN -h $host -I "$id" -a
 | |
| 	[ -n "$port" ] && procd_append_param command -p "$port"
 | |
| 	[ -n "$description" ] && procd_append_param command -d "$description"
 | |
| 	[ "$ssl" = "1" ] && procd_append_param command -s -c /etc/ucentral/operational.pem -k /etc/ucentral/key.pem
 | |
| 	[ -n "$token" ] && procd_append_param command -t "$token"
 | |
| 	[ "$verbose" = "1" ] && procd_append_param command -v
 | |
| 	[ "$timeout" -eq "0" ] || procd_append_param command -e $timeout
 | |
| 	[ "$timeout" -eq "0" ] && procd_set_param respawn
 | |
| 	procd_close_instance
 | |
| }
 | |
| 
 | |
| start_service() {
 | |
| 	config_load rtty
 | |
| 	config_foreach validate_rtty_section rtty start_rtty
 | |
| }
 | |
| 
 | |
| service_triggers() {
 | |
| 	procd_add_reload_trigger "rtty"
 | |
| 	procd_add_validation validate_rtty_section
 | |
| }
 | 
