Ignore:
Timestamp:
Mar 17, 2012, 11:51:28 AM (13 years ago)
Author:
richardvm
Message:

firewall and portal fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/files/tools/wl-config

    r10136 r10185  
    11#!/bin/sh
    2 # Wireless Leiden proxy config-update script for FreeBSD 8.0 (nanobsd)
     2# Wireless Leiden config-update script for FreeBSD 8.0 (nanobsd)
    33# Based on the 'API' of Jasper
    4 # Rick van der Zwet ; Richard van Mansom
     4# Rick van der Zwet
    55# XXX: TODO, some proper error checking for fetch
    66
    7 BASEURL="http://132.229.112.21/config/iris/proxy/FreeBSD/8.0-RELEASE/g_list.pl"
     7
     8# Slow connection = no connection
     9HTTP_TIMEOUT=3
     10
     11
     12check_access() {
     13  # Direct Access - Internal IP
     14  BASEURL="http://172.16.4.46/wleiden/config/"
     15  # Connectivity check
     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  fetch -o /dev/null -q $BASEURL > /dev/null && return
     22  echo "# CRIT: Fetch via external $BASEURL failed"
     23
     24  exit 1
     25}
     26check_access
     27
    828
    929# Default config to fetch
    10 CONFIG=`hostname -s | tr '[A-Z]' '[a-z]'`
     30CONFIG=`hostname -s`
    1131
    1232# Determine it's statup and running location and some other hints
    1333# Skip named.conf as it not planned in current release
    14 FILES="authorized_keys rc.conf.local resolv.conf"
     34FILES="authorized_keys dnsmasq.conf rc.conf.local resolv.conf wleiden.yaml"
    1535file_details() {
    1636  case "$1" in
     
    2040     FILE_HINT=""
    2141   ;;
     42  'dnsmasq.conf')
     43     STARTUP_LOC="/cfg/local/${FILE}"
     44     RUNNING_LOC="/etc/local/${FILE}"
     45     FILE_HINT="/usr/local/etc/rc.d/dnsmasq restart"
     46   ;;
     47  'named.conf')
     48     STARTUP_LOC="/cfg/namedb/${FILE}"
     49     RUNNING_LOC="/etc/namedb/${FILE}"
     50     FILE_HINT="/etc/rc.d/named restart"
     51   ;;
    2252  'rc.conf.local')
    2353     STARTUP_LOC="/cfg/${FILE}"
     
    3060     FILE_HINT=""
    3161   ;;
     62   'wleiden.yaml')
     63     STARTUP_LOC="/cfg/local/${FILE}"
     64     RUNNING_LOC="/etc/local/${FILE}"
     65     FILE_HINT=""
     66   ;;
    3267  esac
    3368}
     
    3671        (
    3772        echo "Usage: $0 [-bn] [-c <config>] [-m <all|startup|testing|running>]"
    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"
     73        echo "  -b          = batch mode, no user input"
     74        echo "  -c <config> = default configuration to fetch"
     75        echo "  -n          = do not mount config partition"
     76        echo "  -m all      = copy config files to running & config partition [default]"
     77        echo "  -m startup  = copy config files to config partition"
     78        echo "  -m testing  = do not copy config files"
     79        echo "  -m running  = copy config files to running partition"
     80        echo "  -m hack     = copy running files to config partition"
    4681        ) 1>&2
    4782        exit 2
     
    80115 
    81116  if [ "${OPT_RUNNING}" -eq 1 ]; then
    82     echo "INFO: Storing new config files in running configuration"
     117    echo "# INFO: Storing new config files in running configuration"
    83118  fi
    84119 
    85120  if [ "${OPT_STARTUP}" -eq 1 ]; then
    86     echo "INFO: Storing new config files in startup configuration"
     121    echo "# INFO: Storing new config files in startup configuration"
    87122  fi
    88123 
    89124  if [ "${OPT_HACK}" -eq 1 ]; then
    90     echo "WARN: Copy running configuration to startup configuration"
    91     echo "WARN: Please do mind to document/mention this changes somewhere"
     125    echo "# WARN: Copy running configuration to startup configuration"
     126    echo "# WARN: Please do mind to document/mention this changes somewhere"
    92127  fi
    93128
     
    107142  else
    108143     echo "WARNING: Input '${INPUT}' is not valid, some hints..."
    109      grep "${INPUT}" ${TMPDIR}/node_list.txt
     144     grep -i "${INPUT}" ${TMPDIR}/node_list.txt
    110145     return 1
    111146  fi 
     
    158193  SOURCE=$1
    159194  TARGET=$2
    160   diff -q ${SOURCE} ${TARGET} >/dev/null 2>/dev/null
     195  diff -I '^# Generated at ' ${SOURCE} ${TARGET} 2>/dev/null
    161196  if [ $? -ne 0 ]; then
    162197    mkdir -p `dirname ${TARGET}` || exit 1
     
    200235    file_details ${FILE}
    201236 
    202     echo "INFO: Working on file: '${FILE}'"
     237    echo "# INFO: Working on file: '${FILE}'"
    203238    # Copy file boot location
    204239    if [ ${OPT_STARTUP} -eq 1 ]; then
     
    210245      copy_file ${FRESH_LOC} ${RUNNING_LOC}
    211246      if [ $? -eq 0 ]; then
    212         echo "INFO: '${FILE}' changed" 
     247        echo "# INFO: '${FILE}' changed" 
    213248        if [ -n "${FILE_HINT}" ]; then
    214           echo "INFO: For instant activate: ${FILE_HINT}"
     249          echo "# INFO: For instant activate: ${FILE_HINT}"
    215250          echo ""
    216251        fi
Note: See TracChangeset for help on using the changeset viewer.