Wifi on/off control
Wireless PCI-card on/off script
Introduzione
Semplice script per "accendere / spegnere" la scheda wireless del portatile
Requisiti
Modulo acer_acpi compilato ed installato!
Modo d'uso
./wifi <event>
event = 'start' | 'stop' | 'restart' | 'status'
Script
#!/bin/bash
##################################
# #
# Wireless on-off control script #
# Version 1.0 #
# ------------------------------ #
# Description: #
# Use this script for #
# Activate / Deactivate your #
# pci wireless-card #
# ------------------------------ #
# !!! Require acer_acpi #
# extension module !!! #
# #
# (c) 2007 by ir0c_ #
# #
##################################
control=`lsmod | grep "acer_acpi" | awk '{print $1}'`
feature=/proc/acpi/acer/wireless
wifi_on="enabled: 1"
wifi_off="enabled: 0"
wifi_status=`dmesg | grep "acer_acpi: Wireless value" | tail -1 | awk '{print $4}'`;
if [ $# != 1 ]; then
printf "\n\t##################################\n"
printf "\t# #\n"
printf "\t# Wireless on-off control script #\n"
printf "\t# #\n"
printf "\t# (c) 2007 by ir0c_ #\n"
printf "\t# #\n"
printf "\t# v.1.0 #\n"
printf "\t##################################\n\n"
printf "\tUsage: $0 {start|stop|restart|status}\n\n";
exit
fi
if [ -z $control ]; then
printf "[*] Module acer_acpi not loaded or istalled!\n[*] Try \'modprobe acer_acpi\'\n"
exit
fi
case $1 in
start)
if [ -z $wifi_status ] || [ $wifi_status -eq 0 ]; then
printf "[\e[0;32m*\e[0m] Setting on Wireless Interface... ";
sleep 1;
echo $wifi_on > $feature;
printf " [\e[0;32mOk!\e[0m]\n";
else
printf "[\e[0;32m*\e[0m] Nothing to do, Already run...\n";
fi
;;
stop)
if [ -z $wifi_status ]; then
printf "[\e[0;32m*\e[0m] Nothing to do, Wireless is Disable!\n";
else
printf "[\e[0;32m*\e[0m] Setting off Wireless Interface... ";
sleep 1
echo $wifi_off > $feature
printf " [\e[0;32mOk!\e[0m]\n";
fi
;;
restart)
# Stopping...
if [ -z $wifi_status ]; then
printf "[\e[0;32m*\e[0m] Nothing to do, Wireless is Disable!\n";
else
printf "[\e[0;32m*\e[0m] Setting off Wireless Interface... ";
sleep 1
echo $wifi_off > $feature
printf " [\e[0;32mOk!\e[0m]\n";
fi
# Starting...
wifi_status=`dmesg | grep "acer_acpi: Wireless value" | tail -1 | awk '{print $4}'`;
if [ -z $wifi_status ] || [ $wifi_status -eq 0 ]; then
printf "[\e[0;32m*\e[0m] Setting on Wireless Interface... ";
sleep 1;
echo $wifi_on > $feature;
printf " [\e[0;32mOk!\e[0m]\n";
else
printf "[\e[0;32m*\e[0m] Nothing to do, Already run...\n";
fi
;;
status)
printf "[\e[0;32m*\e[0m] Reading Wireless status... "
sleep 1
printf "[\e[0;32mOk!\e[0m]\n";
if [ -z $wifi_status ] || [ $wifi_status -eq 0 ]; then
printf "Status: \e[1;34mDisable!\e[0m\n"
else
printf "Status: \e[0;32mEnable!\e[0m\n"
fi
;;
*)
printf "Sorry, Bad request, nothing to do.\n" ;;
esac
ir0c_