slitaz-arm rev 166
Add a small Yad Box to handle Slitaz RPi from an i486 desktop
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun May 04 19:10:58 2014 +0200 (2014-05-04) |
parents | e90abb253448 |
children | e481a1b067df |
files | rpi/data/raspberrypi.png rpi/data/slitaz-rpi.desktop rpi/pileds rpi/slitaz-rpi |
line diff
1.1 Binary file rpi/data/raspberrypi.png has changed
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/rpi/data/slitaz-rpi.desktop Sun May 04 19:10:58 2014 +0200 2.3 @@ -0,0 +1,6 @@ 2.4 +[Desktop Entry] 2.5 +Type=Application 2.6 +Name=SliTaz RPi Devices 2.7 +Icon=raspberrypi.png 2.8 +Exec=slitaz-rpi box 2.9 +Categories=System;
3.1 --- a/rpi/pileds Sun May 04 06:00:37 2014 +0200 3.2 +++ b/rpi/pileds Sun May 04 19:10:58 2014 +0200 3.3 @@ -59,7 +59,7 @@ 3.4 echo "TODO: $scripts" ;; 3.5 3.6 ada-clean) 3.7 - ada_clean ;; 3.8 + adafruit_clean ;; 3.9 3.10 *) usage ;; 3.11
4.1 --- a/rpi/slitaz-rpi Sun May 04 06:00:37 2014 +0200 4.2 +++ b/rpi/slitaz-rpi Sun May 04 19:10:58 2014 +0200 4.3 @@ -16,6 +16,8 @@ 4.4 # 4.5 . /lib/libtaz.sh 4.6 4.7 +pilist="$HOME/.config/slitaz/rpi.list" 4.8 + 4.9 usage() { 4.10 cat << EOT 4.11 4.12 @@ -24,10 +26,55 @@ 4.13 $(boldify "Commands:") 4.14 netmap Search and map R-Pis on the wired local network 4.15 pscan Scan one or all Raspberry Pi hosts open ports 4.16 + box Run the GTK/Yad graphical user interface 4.17 4.18 EOT 4.19 } 4.20 4.21 +ssh_term() { 4.22 + xterm -e "echo 'Connecting: $@'; ssh $@ || read" 4.23 +} 4.24 + 4.25 +netmap_term() { 4.26 + xterm -e "$0 netmap; echo -n 'Press ENTER to continue...'; read" 4.27 + $0 box 4.28 +} 4.29 + 4.30 +pscan_term() { 4.31 + local host="$1" 4.32 + echo $0 pscan $host 4.33 + xterm -e "$0 pscan $1; echo -n 'Press ENTER to continue...'; read" 4.34 + $0 box 4.35 +} 4.36 + 4.37 +rpi_list() { 4.38 + for host in $(cat $pilist); do 4.39 + echo -n "$host!" 4.40 + done 4.41 + echo "Clean list" 4.42 +} 4.43 + 4.44 +rpi_box() { 4.45 + count=$(cat $pilist | wc -l) 4.46 + logo="/usr/share/pixmaps/raspberrypi.png" 4.47 + text="<b>Connect to you local Raspberry Pi devices</b>\nRaspberry Pi: $count\n" 4.48 + # Have a config file, store RPi IPs, have button to launch an SSH 4.49 + # connection or an sftp connexion with gftp. 4.50 + yad --form --borders=4 \ 4.51 + --window-icon="$logo" \ 4.52 + --title="SliTaz RPi" --center \ 4.53 + --image="$logo" --image-on-top \ 4.54 + --text "$text" --width=520 --height=240 \ 4.55 + --button="Web admin!gtk-properties:4" \ 4.56 + --button="Netmap!find:2" \ 4.57 + --button="Connect!insert-link:0" \ 4.58 + --button="Cancel!gtk-close:1" \ 4.59 + --field="$(gettext "Raspberry Pi host:")":CB \ 4.60 + --field="$(gettext "New device IP:")" \ 4.61 + --field="$(gettext "User name:")" \ 4.62 + "$(rpi_list)" "" "$USER" 4.63 +} 4.64 + 4.65 case "$1" in 4.66 netmap) 4.67 # MAC address works for wired raspberry R-Pis 4.68 @@ -54,7 +101,9 @@ 4.69 newline ;; 4.70 4.71 pscan) 4.72 - [ "$2" ] && pscan ${2} && exit 0 4.73 + if [ "$2" ]; then 4.74 + pscan ${2} && exit 0 4.75 + fi 4.76 arp -a | grep -i "b8:27:eb" | awk '{print $2}' | while read line 4.77 do 4.78 ip=$(echo "$line" | tr -d '()') 4.79 @@ -65,9 +114,46 @@ 4.80 separator; newline 4.81 done ;; 4.82 4.83 - backup) ;; 4.84 + box) 4.85 + # Store box results 4.86 + main=$(rpi_box) 4.87 + action="$?" 4.88 + 4.89 + host=$(echo $main | cut -d "|" -f 1) 4.90 + new=$(echo $main | cut -d "|" -f 2) 4.91 + user=$(echo $main | cut -d "|" -f 3) 4.92 + 4.93 + # New host 4.94 + [ "$new" ] && host="$new" && main="$new" 4.95 + if [ "$new" ] && ! grep "^$new" ${pilist}; then 4.96 + echo "$new" >> ${pilist} 4.97 + fi 4.98 + 4.99 + # Deal with --button actions 4.100 + case "$action" in 4.101 + 0) ssh_term "$user@$host" ;; 4.102 + 1) exit 0 ;; 4.103 + 2) netmap_term ;; 4.104 + 4) tazweb --notoolbar ${host}/adm ;; 4.105 + *) continue ;; 4.106 + esac 4.107 + 4.108 + # Deal with $main values 4.109 + case "$main" in 4.110 + Clean*) 4.111 + echo "Cleaning: $pilist" 4.112 + rm -f ${pilist} && touch ${pilist} 4.113 + $0 box ;; 4.114 + esac ;; 4.115 4.116 - restore) ;; 4.117 + backup) 4.118 + # dd an SD card with time stamp 4.119 + ;; 4.120 + 4.121 + restore) 4.122 + # Restore a previwsly backup up SD card 4.123 + ;; 4.124 4.125 *) usage ;; 4.126 + 4.127 esac && exit 0