mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 10:28:06 +00:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			v1.0.3
			...
			v1.0.4-rc2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | f3fc398eac | ||
|   | 7aea689d9a | 
| @@ -1,12 +1,45 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| if [ $# -ne 1 ] ; then | ||||
| 	echo "Usage: $0 <redirector address>" >&2 | ||||
| AP_PRIVATE_KEY_FILE="/usr/opensync/certs/client_dec.key" | ||||
| AP_CERTIFICATE_FILE="/usr/opensync/certs/client.pem" | ||||
| AP_DEVICE_ID_FILE="/usr/opensync/certs/client_deviceid.txt" | ||||
| DIGICERT_API_URI="clientauth.one.digicert.com" | ||||
|  | ||||
| if [ "$1" = "-h" ]; then | ||||
|   echo "Usage: $0 [redirector address]" >&2 | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| redirector_addr=$1 | ||||
| # Query DigiCert's API if redirector wasn't specified | ||||
| if [ -z "$1" ]; then | ||||
|   if [ ! -f "$AP_DEVICE_ID_FILE" ]; then | ||||
|       echo "Device ID file $AP_DEVICE_ID_FILE does not exist. Make sure to create it or specify the redirector address manually." | ||||
|       exit 1 | ||||
|   fi | ||||
|  | ||||
|   # TODO: this command should be retried if it fails | ||||
|   digicert_device_id=`cat ${AP_DEVICE_ID_FILE}` | ||||
|   device_data=`curl -s \ | ||||
|     --key "${AP_PRIVATE_KEY_FILE}" \ | ||||
|     --cert "${AP_CERTIFICATE_FILE}" \ | ||||
|     "https://${DIGICERT_API_URI}/iot/api/v2/device/${digicert_device_id}"` | ||||
|  | ||||
|   controller_url=`echo ${device_data} | jsonfilter -e '@.fields[@.name="Redirector"].value'` | ||||
|   if [ -z "$controller_url" ]; then | ||||
|     echo "No redirector found for this device" | ||||
|     exit 1 | ||||
|   fi | ||||
|   controller_port=`echo ${controller_url} | cut -d ":" -f2)` | ||||
|   if [ -z "$controller_port" ]; then | ||||
|     redirector_addr="ssl:${controller_url}:6643" | ||||
|   else | ||||
|     redirector_addr="ssl:${controller_url}" | ||||
|   fi | ||||
| else | ||||
|   redirector_addr=$1 | ||||
| fi | ||||
|  | ||||
| uci set system.tip.redirector="${redirector_addr}" | ||||
| uci set system.tip.deployed=0 | ||||
| uci commit system | ||||
| /etc/init.d/opensync restart | ||||
|   | ||||
| @@ -37,6 +37,14 @@ start_service() { | ||||
|     echo "Setting certificates" | ||||
|     mkdir -p ${CERTS_DEST_PATH} | ||||
|     cp ${CERTS_SRC_PATH}/* ${CERTS_DEST_PATH}/ | ||||
|     echo "Checking Redirector" | ||||
|     redirector=$(uci get system.tip.redirector) | ||||
|     if [ -z "$redirector" ]; then | ||||
|         logger -t opensync "Contacting DigiCert for redirector address" | ||||
|         wlan_ap_redirector.sh | ||||
|     else | ||||
|         logger -t opensync "Redirector address is ${redirector}" | ||||
|     fi | ||||
|     echo "Starting OpenSync" | ||||
|     procd_set_param command ${PROG} | ||||
|     procd_close_instance | ||||
|   | ||||
		Reference in New Issue
	
	Block a user