aruba_scripts
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | aruba_scripts [2010/02/11 23:51] (current) – created ginko | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Aruba Scripts ====== | ||
+ | Scripts permettant plus ou moins la gestion de la connexion à un point d' | ||
+ | ===== Aruba login ===== | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | # *** Aruba Login Script *** | ||
+ | # * v1.7 * | ||
+ | |||
+ | # Permet de se connecter automatiquement au wifi à sully avec le login:XXXXX et le password: | ||
+ | |||
+ | # *** Utilisation *** | ||
+ | # arg1: cmd > shell / else > notifications graphiques | ||
+ | # arg2: V > shell / else > log dans les fichiers " | ||
+ | |||
+ | # *** Release Notes *** | ||
+ | # | ||
+ | # -v1.0: -Script fonctionnel | ||
+ | # -v1.1: -Ajout de la notification | ||
+ | # -v1.2: -Amélioration de la notification (icone) | ||
+ | # -Ajout des commentaires | ||
+ | # -v1.3: -Ajout de la notification de démarrage | ||
+ | # -v1.4: -Ajout du mode commande | ||
+ | # -v1.5: -Débuggage du mode commande | ||
+ | # -Parsing de l' | ||
+ | # -Redirection de la sortie de curl vers /dev/null | ||
+ | # -v1.6: -Ajout du mode verbose/log | ||
+ | # -Ajout de la rubrique " | ||
+ | # -v1.7: -Intégration du notificateur d' | ||
+ | # ********************* | ||
+ | |||
+ | # *** Initialisation des variables *** | ||
+ | msg_init=" | ||
+ | msg_ok=" | ||
+ | msg_er=" | ||
+ | user=" | ||
+ | pass=" | ||
+ | connect_state=0 | ||
+ | |||
+ | if [ $1 ]; then | ||
+ | mode=$1 | ||
+ | else | ||
+ | mode=" | ||
+ | fi | ||
+ | |||
+ | # *** Notification de démarrage *** | ||
+ | if [ $mode = cmd ]; then | ||
+ | echo $msg_init | ||
+ | else | ||
+ | notify-send -t 3000 Aruba_login $msg_init | ||
+ | fi | ||
+ | |||
+ | # *** Connexion *** | ||
+ | # -L active la gestion des redirections | ||
+ | # -b active la gestion des cookies | ||
+ | # -d permet d' | ||
+ | if [ $2 ]; then | ||
+ | if [ $2 = V ]; then | ||
+ | curl -L -b cookie https:// | ||
+ | curl -L -b cookie -d " | ||
+ | else | ||
+ | curl -L -b cookie https:// | ||
+ | curl -L -b cookie -d " | ||
+ | fi | ||
+ | else | ||
+ | curl -L -b cookie https:// | ||
+ | curl -L -b cookie -d " | ||
+ | fi | ||
+ | |||
+ | # *** Notification *** | ||
+ | # Dépends du code de retour de la dernière commande. | ||
+ | if (( $? == 0 )); then | ||
+ | $connect_state=1 | ||
+ | if [ $mode = cmd ]; then | ||
+ | echo $msg_ok | ||
+ | else | ||
+ | notify-send -i / | ||
+ | fi | ||
+ | else | ||
+ | $connect_state=2 | ||
+ | if [ $mode = cmd ]; then | ||
+ | echo $msg_er | ||
+ | else | ||
+ | notify-send -i / | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | # | ||
+ | echo $connect_state >/ | ||
+ | </ | ||
+ | ===== Aruba logout ===== | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | # *** Aruba Logout Script *** | ||
+ | # * v1.7 * | ||
+ | |||
+ | # Permet de se déconnecter facilement du wifi à Sully | ||
+ | |||
+ | # *** Utilisation *** | ||
+ | # arg1: cmd > shell / else > notifications graphiques | ||
+ | # arg2: V > shell / else > log dans le fichier " | ||
+ | |||
+ | # *** Release Notes *** | ||
+ | # | ||
+ | # -v1.0: -Script fonctionnel | ||
+ | # -v1.1: -Ajout de la notification | ||
+ | # -v1.2: -Amélioration de la notification (icone) | ||
+ | # -Ajout des commentaires | ||
+ | # -v1.3: -Ajout de la notification de démarrage | ||
+ | # -v1.4: -Ajout du mode commande | ||
+ | # -v1.5: -Débuggage du mode commande | ||
+ | # -Parsing de l' | ||
+ | # -Redirection de la sortie de curl vers /dev/null | ||
+ | # -v1.6: -Ajout du mode verbose/log | ||
+ | # -Ajout de la rubrique " | ||
+ | # -v1.7: -Intégration du notificateur d' | ||
+ | # ********************* | ||
+ | |||
+ | # *** Initialisation des variables *** | ||
+ | msg_init=" | ||
+ | msg_ok=" | ||
+ | msg_er=" | ||
+ | |||
+ | connect_state=0 | ||
+ | |||
+ | if [ $1 ]; then | ||
+ | mode=$1 | ||
+ | else | ||
+ | mode=" | ||
+ | fi | ||
+ | |||
+ | # *** Notification de démarage *** | ||
+ | if [ $mode = cmd ]; then | ||
+ | echo $msg_init | ||
+ | else | ||
+ | notify-send -t 3000 Aruba_logout $msg_init | ||
+ | fi | ||
+ | |||
+ | # *** Déconnexion *** | ||
+ | # -L active la gestion des redirections | ||
+ | if [ $2 ]; then | ||
+ | if [ $2 = V ]; then | ||
+ | curl -L https:// | ||
+ | else | ||
+ | curl -L https:// | ||
+ | fi | ||
+ | else | ||
+ | curl -L https:// | ||
+ | fi | ||
+ | |||
+ | # *** Notification *** | ||
+ | # Dépends du code de retour de la dernière commande. | ||
+ | if (( $? == 0 )); then | ||
+ | connect_state=0 | ||
+ | if [ $mode = cmd ]; then | ||
+ | echo $msg_ok | ||
+ | else | ||
+ | notify-send -i / | ||
+ | fi | ||
+ | else | ||
+ | connect_state=2 | ||
+ | if [ $mode = cmd ]; then | ||
+ | echo $msg_er | ||
+ | else | ||
+ | notify-send -i / | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | # | ||
+ | echo $connect_state >/ | ||
+ | </ | ||
+ | ===== Aruba state ===== | ||
+ | NB: Script non fonctionnel... le fichier de stockage de l' | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | # *** Aruba state notification script *** | ||
+ | # * v1.0 * | ||
+ | |||
+ | # Permet l'a notification à la demande de l' | ||
+ | |||
+ | # *** Utilisation *** | ||
+ | # L' | ||
+ | |||
+ | # *** Release Notes *** | ||
+ | # | ||
+ | # -v1.0: -Script fonctionnel | ||
+ | # | ||
+ | |||
+ | state_file=$HOME/ | ||
+ | msg_ko=unconnected | ||
+ | msg_ok=connected | ||
+ | msg_er=error | ||
+ | msg_ex=" | ||
+ | msg_el=" | ||
+ | |||
+ | if [ -r $state_file ]; then | ||
+ | state=`tail -n 1 $state_file` | ||
+ | else | ||
+ | state=3 | ||
+ | fi | ||
+ | |||
+ | if [ $1 ]; then | ||
+ | mode=$1 | ||
+ | else | ||
+ | mode=" | ||
+ | fi | ||
+ | |||
+ | if [ $mode = cmd ];then | ||
+ | if [ $state = 0 ]; then | ||
+ | echo $msg_ko | ||
+ | elif [ $state = 1 ]; then | ||
+ | echo $msg_ok | ||
+ | elif [ $state = 2 ]; then | ||
+ | echo $msg_er | ||
+ | elif [ $state = 3 ]; then | ||
+ | echo $msg_ex | ||
+ | else | ||
+ | echo $msg_el | ||
+ | fi | ||
+ | else | ||
+ | if [ $state = 0 ]; then | ||
+ | notify-send Aruba_State $msg_ko | ||
+ | elif [ $state = 1 ]; then | ||
+ | notify-send Aruba_State $msg_ok | ||
+ | elif [ $state = 2 ]; then | ||
+ | notify-send Aruba_State $msg_er | ||
+ | elif [ $state = 3 ]; then | ||
+ | notify-send Aruba_State $msg_ex | ||
+ | else | ||
+ | notify-send Aruba_State $msg_el | ||
+ | fi | ||
+ | fi | ||
+ | </ | ||
+ | ===== Aruba state reloaded ===== | ||
+ | NB: pas totalement testé, notamment, que ce passe-t-il si l'on est redirigé? Bonne sortie ou pas? | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | # *** Aruba State Reloaded *** | ||
+ | |||
+ | # Vérifie si l' | ||
+ | |||
+ | msg_ok=Connecté | ||
+ | msg_er=" | ||
+ | score=0 | ||
+ | |||
+ | if [ $1 ];then | ||
+ | mode=$1 | ||
+ | else | ||
+ | mode=graph | ||
+ | fi | ||
+ | |||
+ | echo $score | ||
+ | echo init perdu | ||
+ | curl -m 30 perdu.com >/ | ||
+ | |||
+ | if [ $? = 0 ]; then | ||
+ | score=${score+1} | ||
+ | fi | ||
+ | echo $score | ||
+ | echo init google | ||
+ | curl -m 30 www.google.fr >/ | ||
+ | |||
+ | if [ $? = 0 ]; then | ||
+ | score=${score+1} | ||
+ | fi | ||
+ | echo $score | ||
+ | if [ $mode = cmd ];then | ||
+ | if [ $score = 2 ]; then | ||
+ | echo $msg_ok | ||
+ | else | ||
+ | echo $msg_er " | ||
+ | fi | ||
+ | else | ||
+ | if [ $score = 2 ];then | ||
+ | notify-send State $msg_ok | ||
+ | else | ||
+ | notify-send " | ||
+ | fi | ||
+ | fi | ||
+ | </ | ||
+ | |||
aruba_scripts.txt · Last modified: 2010/02/11 23:51 by ginko