Changeset 10136 in hybrid for trunk/nanobsd/files/tools/wl-config


Ignore:
Timestamp:
Mar 12, 2012, 6:32:43 AM (13 years ago)
Author:
richardvm
Message:

domme toevoeging van proxy files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nanobsd/files/tools/wl-config

    r10135 r10136  
    11#!/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)
    33# Based on the 'API' of Jasper
    4 # Rick van der Zwet
     4# Rick van der Zwet ; Richard van Mansom
    55# XXX: TODO, some proper error checking for fetch
    66
    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 
     7BASEURL="http://132.229.112.21/config/iris/proxy/FreeBSD/8.0-RELEASE/g_list.pl"
    298
    309# Default config to fetch
    31 CONFIG=`hostname -s`
     10CONFIG=`hostname -s | tr '[A-Z]' '[a-z]'`
    3211
    3312# Determine it's statup and running location and some other hints
    3413# Skip named.conf as it not planned in current release
    35 FILES="authorized_keys dnsmasq.conf rc.conf.local resolv.conf motd wleiden.yaml"
     14FILES="authorized_keys rc.conf.local resolv.conf"
    3615file_details() {
    3716  case "$1" in
     
    4019     RUNNING_LOC="/etc/dot_ssh/${FILE}"
    4120     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"
    5721   ;;
    5822  'rc.conf.local')
     
    6630     FILE_HINT=""
    6731   ;;
    68    'wleiden.yaml')
    69      STARTUP_LOC="/cfg/local/${FILE}"
    70      RUNNING_LOC="/etc/local/${FILE}"
    71      FILE_HINT=""
    72    ;;
    7332  esac
    7433}
     
    7736        (
    7837        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     = copy running 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"
    8746        ) 1>&2
    8847        exit 2
     
    12180 
    12281  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"
    12483  fi
    12584 
    12685  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"
    12887  fi
    12988 
    13089  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"
    13392  fi
    13493
     
    148107  else
    149108     echo "WARNING: Input '${INPUT}' is not valid, some hints..."
    150      grep -i "${INPUT}" ${TMPDIR}/node_list.txt
     109     grep "${INPUT}" ${TMPDIR}/node_list.txt
    151110     return 1
    152111  fi 
     
    197156# Copy file, saving some bits if no change needed
    198157copy_file() {
    199   NEWFILE=$1
     158  SOURCE=$1
    200159  TARGET=$2
    201   diff -I '^# Generated at ' ${TARGET} ${NEWFILE} 2>/dev/null
     160  diff -q ${SOURCE} ${TARGET} >/dev/null 2>/dev/null
    202161  if [ $? -ne 0 ]; then
    203162    mkdir -p `dirname ${TARGET}` || exit 1
    204     cp ${NEWFILE} ${TARGET} || exit 1
     163    cp ${SOURCE} ${TARGET} || exit 1
    205164    return $?
    206165  fi
     
    241200    file_details ${FILE}
    242201 
    243     echo "# INFO: Working on file: '${FILE}'"
     202    echo "INFO: Working on file: '${FILE}'"
    244203    # Copy file boot location
    245204    if [ ${OPT_STARTUP} -eq 1 ]; then
     
    251210      copy_file ${FRESH_LOC} ${RUNNING_LOC}
    252211      if [ $? -eq 0 ]; then
    253         echo "# INFO: '${FILE}' changed" 
     212        echo "INFO: '${FILE}' changed" 
    254213        if [ -n "${FILE_HINT}" ]; then
    255           echo "# INFO: For instant activate: ${FILE_HINT}"
     214          echo "INFO: For instant activate: ${FILE_HINT}"
    256215          echo ""
    257216        fi
Note: See TracChangeset for help on using the changeset viewer.