wok annotate nomad/stuff/nomad @ rev 23776

updated xorg-xf86-video-sis (0.11.0 -> 0.12.0)
author Hans-G?nter Theisgen
date Wed May 20 16:55:27 2020 +0100 (2020-05-20)
parents
children
rev   line source
sygne@1123 1 #! /bin/sh
sygne@1123 2 # nomad: configure wifi and change acces point easily.
sygne@1123 3
sygne@1123 4 # Copyright (C) <2008> <Pierre-Jean Fichet> <sygnes@ombres.eu>
sygne@1123 5 #
sygne@1123 6 # This program is free software: you can redistribute it and/or modify
sygne@1123 7 # it under the terms of the GNU General Public License as published by
sygne@1123 8 # the Free Software Foundation, either version 3 of the License, or
sygne@1123 9 # (at your option) any later version.
sygne@1123 10 #
sygne@1123 11 # This program is distributed in the hope that it will be useful,
sygne@1123 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
sygne@1123 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
sygne@1123 14 # GNU General Public License for more details.
sygne@1123 15 #
sygne@1123 16 # You should have received a copy of the GNU General Public License
sygne@1123 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
sygne@1123 18
sygne@1123 19
sygne@1123 20 CONFIG="/etc/nomad.conf"
sygne@1123 21
sygne@1123 22 . $CONFIG
sygne@1123 23 . /etc/init.d/rc.functions
sygne@1123 24
sygne@1123 25
sygne@1123 26 case "$1" in
sygne@1123 27 # we want to configure au new interface
sygne@1123 28 new)
sygne@1123 29 TYPE="wifi"
sygne@1123 30 WIFI_INTERFACE="$2"
sygne@1123 31 ESSID="$3"
sygne@1123 32 KEYTYPE="$4"
sygne@1123 33 KEY="$5"
sygne@1123 34 DRIVER="$6"
sygne@1123 35 if [ "$KEYTYPE" = "wpa" ]; then
sygne@1123 36 WPA="
sygne@1123 37 ap_scan=1
sygne@1123 38 network={
sygne@1123 39 ssid=\"$ESSID\"
sygne@1123 40 scan_ssid=1
sygne@1123 41 proto=WPA
sygne@1123 42 key_mgmt=WPA-PSK
sygne@1123 43 psk=\"$KEY\"
sygne@1123 44 priority=5
sygne@1123 45 }"
sygne@1123 46 fi
sygne@1123 47 ;;
sygne@1123 48
sygne@1123 49 # we want to poweroff wifi
sygne@1123 50 stop)
sygne@1123 51 echo -n "pidof wpa_supplicant: "
sygne@1123 52 if pidof wpa_supplicant; then
sygne@1123 53 echo -n "stopping wpa_supplicant..."
sygne@1123 54 killall wpa_supplicant
sygne@1123 55 status
sygne@1123 56 else
sygne@1123 57 echo "None"
sygne@1123 58 fi
sygne@1123 59 echo -n "power off wifi..."
sygne@1123 60 iwconfig $WIFI_INTERFACE txpower off
sygne@1123 61 status
sygne@1123 62 ;;
sygne@1123 63
sygne@1123 64
sygne@1123 65 *)
sygne@1123 66 # we want to join a known access point
sygne@1123 67 if [ "$1" != "" ] && grep -q "$1() {" $CONFIG ; then
sygne@1123 68 $1 # here we launch the function to set variables
sygne@1123 69 # we don't know how to use nomad
sygne@1123 70 else
sygne@1123 71 echo -n -e "\033[01musage:\033[0m `basename $0` ["
sygne@1123 72 for line in `grep "() {" $CONFIG | sed "/#.*/d" | sed -e "s/() {//g"`
sygne@1123 73 do
sygne@1123 74 echo -n "$line|"
sygne@1123 75 done
sygne@1123 76 echo -n "stop]"
sygne@1123 77 echo ""
sygne@1123 78 echo -e "\033[1mOr :\033[0m `basename $0` new \
sygne@1123 79 WIFI_INTERFACE ESSID KEYTYPE KEY DRIVER"
sygne@1123 80 echo " KEYTYPE is: wpa or wep"
sygne@1123 81 echo " DRIVER is wext or another-wpa_supplicant-driver"
sygne@1123 82 echo ""
sygne@1123 83 echo -e " But first, you have to edit \033[1m/etc/nomad.conf\033[0m "
sygne@1123 84 echo ""
sygne@1123 85 echo -e "You can also use \033[1mnomadbox\033[0m, if you want a graphical interface for nomad"
sygne@1123 86 echo ""
sygne@1123 87 exit 1
sygne@1123 88 fi
sygne@1123 89 ;;
sygne@1123 90 esac
sygne@1123 91
sygne@1123 92
sygne@1123 93 #Si ethernet
sygne@1123 94 if [ "$TYPE" = "ethernet" ]; then
sygne@1123 95 if [ "$DHCP" = "yes" ] ; then
sygne@1123 96 echo "Starting udhcpc client on: $INTERFACE... "
sygne@1123 97 /sbin/udhcpc -b -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid
sygne@1123 98 status
sygne@1123 99 fi
sygne@1123 100 # For a static IP.
sygne@1123 101 if [ "$STATIC" = "yes" ] ; then
sygne@1123 102 echo -n "Configuring static IP on $INTERFACE: $IP... "
sygne@1123 103 /sbin/ifconfig $INTERFACE $IP netmask $NETMASK up
sygne@1123 104 /sbin/route add default gateway $GATEWAY
sygne@1123 105 status
sygne@1123 106 # Multi-DNS server in $DNS_SERVER.
sygne@1123 107 /bin/mv /etc/resolv.conf /tmp/resolv.conf.$$
sygne@1123 108 for NS in $DNS_SERVER
sygne@1123 109 do
sygne@1123 110 echo "nameserver $NS" >> /etc/resolv.conf
sygne@1123 111 done
sygne@1123 112 fi
sygne@1123 113
sygne@1123 114 #si wifi
sygne@1123 115 elif [ "$TYPE" = "wifi" ]; then
sygne@1123 116 iwconfig $WIFI_INTERFACE txpower on
sygne@1123 117 status
sygne@1123 118 iwconfig $WIFI_INTERFACE essid $ESSID
sygne@1123 119 if [ -n "$WPA" ]; then
sygne@1123 120 echo "$WPA" >/tmp/wpa.conf
sygne@1123 121 echo "starting wpa_supplicant for $INTERFACE..."
sygne@1123 122 wpa_supplicant -B -w -c/tmp/wpa.conf -D$DRIVER -i$WIFI_INTERFACE
sygne@1123 123 status
sygne@1123 124 rm /tmp/wpa.conf
sygne@1123 125 elif [ -n "$KEY" ]; then
sygne@1123 126 iwconfig $WIFI_INTERFACE key $KEY
sygne@1123 127 fi
sygne@1123 128 /sbin/udhcpc -b -i $WIFI_INTERFACE -p /var/run/udhcpc.$WIFI_INTERFACE.pid
sygne@1123 129 fi
sygne@1123 130
sygne@1123 131 exit 0