Changeset 10136 in hybrid for trunk/nanobsd/files/tools/wl-config
- Timestamp:
- Mar 12, 2012, 6:32:43 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nanobsd/files/tools/wl-config
r10135 r10136 1 1 #!/bin/sh 2 # Wireless Leiden config-update script for FreeBSD 8.0 (nanobsd)2 # Wireless Leiden proxy config-update script for FreeBSD 8.0 (nanobsd) 3 3 # Based on the 'API' of Jasper 4 # Rick van der Zwet 4 # Rick van der Zwet ; Richard van Mansom 5 5 # XXX: TODO, some proper error checking for fetch 6 6 7 8 # Slow connection = no connection 9 export HTTP_TIMEOUT=3 10 11 12 check_access() { 13 # Direct Access - Internal IP 14 BASEURL="http://172.16.4.46/wleiden/config/" 15 echo "# INFO: Trying to fetch via internal WL $BASEURL" 16 fetch -o /dev/null -q $BASEURL > /dev/null && return 17 echo "# WARN: Fetch via internal $BASEURL failed" 18 19 # Direct Access - External DNS 20 BASEURL="http://132.229.112.21/wleiden/config/" 21 echo "# INFO: Trying to fetch via external $BASEURL" 22 fetch -o /dev/null -q $BASEURL > /dev/null && return 23 echo "# CRIT: Fetch via external $BASEURL failed" 24 25 exit 1 26 } 27 check_access 28 7 BASEURL="http://132.229.112.21/config/iris/proxy/FreeBSD/8.0-RELEASE/g_list.pl" 29 8 30 9 # Default config to fetch 31 CONFIG=`hostname -s `10 CONFIG=`hostname -s | tr '[A-Z]' '[a-z]'` 32 11 33 12 # Determine it's statup and running location and some other hints 34 13 # Skip named.conf as it not planned in current release 35 FILES="authorized_keys dnsmasq.conf rc.conf.local resolv.conf motd wleiden.yaml"14 FILES="authorized_keys rc.conf.local resolv.conf" 36 15 file_details() { 37 16 case "$1" in … … 40 19 RUNNING_LOC="/etc/dot_ssh/${FILE}" 41 20 FILE_HINT="" 42 ;;43 'motd')44 STARTUP_LOC="/cfg/$1"45 RUNNING_LOC="/etc/$1"46 FILE_HINT=""47 ;;48 'dnsmasq.conf')49 STARTUP_LOC="/cfg/local/${FILE}"50 RUNNING_LOC="/etc/local/${FILE}"51 FILE_HINT="/usr/local/etc/rc.d/dnsmasq restart"52 ;;53 'named.conf')54 STARTUP_LOC="/cfg/namedb/${FILE}"55 RUNNING_LOC="/etc/namedb/${FILE}"56 FILE_HINT="/etc/rc.d/named restart"57 21 ;; 58 22 'rc.conf.local') … … 66 30 FILE_HINT="" 67 31 ;; 68 'wleiden.yaml')69 STARTUP_LOC="/cfg/local/${FILE}"70 RUNNING_LOC="/etc/local/${FILE}"71 FILE_HINT=""72 ;;73 32 esac 74 33 } … … 77 36 ( 78 37 echo "Usage: $0 [-bn] [-c <config>] [-m <all|startup|testing|running>]" 79 echo " -b =batch mode, no user input"80 echo " -c <config> =default configuration to fetch"81 echo " -n =do not mount config partition"82 echo " -m all =copy config files to running & config partition [default]"83 echo " -m startup =copy config files to config partition"84 echo " -m testing =do not copy config files"85 echo " -m running =copy config files to running partition"86 echo " -m hack = copyrunning files to config partition"38 echo " -b batch mode, no user input" 39 echo " -c <config> default configuration to fetch" 40 echo " -n do not mount config partition" 41 echo " -m all copy config files to running & config partition [default]" 42 echo " -m startup copy config files to config partition" 43 echo " -m testing do not copy config files" 44 echo " -m running copy config files to running partition" 45 echo " -m hack copy running files to config partition" 87 46 ) 1>&2 88 47 exit 2 … … 121 80 122 81 if [ "${OPT_RUNNING}" -eq 1 ]; then 123 echo " #INFO: Storing new config files in running configuration"82 echo "INFO: Storing new config files in running configuration" 124 83 fi 125 84 126 85 if [ "${OPT_STARTUP}" -eq 1 ]; then 127 echo " #INFO: Storing new config files in startup configuration"86 echo "INFO: Storing new config files in startup configuration" 128 87 fi 129 88 130 89 if [ "${OPT_HACK}" -eq 1 ]; then 131 echo " #WARN: Copy running configuration to startup configuration"132 echo " #WARN: Please do mind to document/mention this changes somewhere"90 echo "WARN: Copy running configuration to startup configuration" 91 echo "WARN: Please do mind to document/mention this changes somewhere" 133 92 fi 134 93 … … 148 107 else 149 108 echo "WARNING: Input '${INPUT}' is not valid, some hints..." 150 grep -i"${INPUT}" ${TMPDIR}/node_list.txt109 grep "${INPUT}" ${TMPDIR}/node_list.txt 151 110 return 1 152 111 fi … … 197 156 # Copy file, saving some bits if no change needed 198 157 copy_file() { 199 NEWFILE=$1158 SOURCE=$1 200 159 TARGET=$2 201 diff - I '^# Generated at ' ${TARGET} ${NEWFILE}2>/dev/null160 diff -q ${SOURCE} ${TARGET} >/dev/null 2>/dev/null 202 161 if [ $? -ne 0 ]; then 203 162 mkdir -p `dirname ${TARGET}` || exit 1 204 cp ${ NEWFILE} ${TARGET} || exit 1163 cp ${SOURCE} ${TARGET} || exit 1 205 164 return $? 206 165 fi … … 241 200 file_details ${FILE} 242 201 243 echo " #INFO: Working on file: '${FILE}'"202 echo "INFO: Working on file: '${FILE}'" 244 203 # Copy file boot location 245 204 if [ ${OPT_STARTUP} -eq 1 ]; then … … 251 210 copy_file ${FRESH_LOC} ${RUNNING_LOC} 252 211 if [ $? -eq 0 ]; then 253 echo " #INFO: '${FILE}' changed"212 echo "INFO: '${FILE}' changed" 254 213 if [ -n "${FILE_HINT}" ]; then 255 echo " #INFO: For instant activate: ${FILE_HINT}"214 echo "INFO: For instant activate: ${FILE_HINT}" 256 215 echo "" 257 216 fi
Note:
See TracChangeset
for help on using the changeset viewer.