# HG changeset patch # User Christophe Lincoln # Date 1399223458 -7200 # Node ID 0eb0f35e2f0db11fc4751eb4db95e43889ff57c5 # Parent e90abb253448d331d4434eb63471f089aa43c7f3 Add a small Yad Box to handle Slitaz RPi from an i486 desktop diff -r e90abb253448 -r 0eb0f35e2f0d rpi/data/raspberrypi.png Binary file rpi/data/raspberrypi.png has changed diff -r e90abb253448 -r 0eb0f35e2f0d rpi/data/slitaz-rpi.desktop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rpi/data/slitaz-rpi.desktop Sun May 04 19:10:58 2014 +0200 @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Application +Name=SliTaz RPi Devices +Icon=raspberrypi.png +Exec=slitaz-rpi box +Categories=System; diff -r e90abb253448 -r 0eb0f35e2f0d rpi/pileds --- a/rpi/pileds Sun May 04 06:00:37 2014 +0200 +++ b/rpi/pileds Sun May 04 19:10:58 2014 +0200 @@ -59,7 +59,7 @@ echo "TODO: $scripts" ;; ada-clean) - ada_clean ;; + adafruit_clean ;; *) usage ;; diff -r e90abb253448 -r 0eb0f35e2f0d rpi/slitaz-rpi --- a/rpi/slitaz-rpi Sun May 04 06:00:37 2014 +0200 +++ b/rpi/slitaz-rpi Sun May 04 19:10:58 2014 +0200 @@ -16,6 +16,8 @@ # . /lib/libtaz.sh +pilist="$HOME/.config/slitaz/rpi.list" + usage() { cat << EOT @@ -24,10 +26,55 @@ $(boldify "Commands:") netmap Search and map R-Pis on the wired local network pscan Scan one or all Raspberry Pi hosts open ports + box Run the GTK/Yad graphical user interface EOT } +ssh_term() { + xterm -e "echo 'Connecting: $@'; ssh $@ || read" +} + +netmap_term() { + xterm -e "$0 netmap; echo -n 'Press ENTER to continue...'; read" + $0 box +} + +pscan_term() { + local host="$1" + echo $0 pscan $host + xterm -e "$0 pscan $1; echo -n 'Press ENTER to continue...'; read" + $0 box +} + +rpi_list() { + for host in $(cat $pilist); do + echo -n "$host!" + done + echo "Clean list" +} + +rpi_box() { + count=$(cat $pilist | wc -l) + logo="/usr/share/pixmaps/raspberrypi.png" + text="Connect to you local Raspberry Pi devices\nRaspberry Pi: $count\n" + # Have a config file, store RPi IPs, have button to launch an SSH + # connection or an sftp connexion with gftp. + yad --form --borders=4 \ + --window-icon="$logo" \ + --title="SliTaz RPi" --center \ + --image="$logo" --image-on-top \ + --text "$text" --width=520 --height=240 \ + --button="Web admin!gtk-properties:4" \ + --button="Netmap!find:2" \ + --button="Connect!insert-link:0" \ + --button="Cancel!gtk-close:1" \ + --field="$(gettext "Raspberry Pi host:")":CB \ + --field="$(gettext "New device IP:")" \ + --field="$(gettext "User name:")" \ + "$(rpi_list)" "" "$USER" +} + case "$1" in netmap) # MAC address works for wired raspberry R-Pis @@ -54,7 +101,9 @@ newline ;; pscan) - [ "$2" ] && pscan ${2} && exit 0 + if [ "$2" ]; then + pscan ${2} && exit 0 + fi arp -a | grep -i "b8:27:eb" | awk '{print $2}' | while read line do ip=$(echo "$line" | tr -d '()') @@ -65,9 +114,46 @@ separator; newline done ;; - backup) ;; + box) + # Store box results + main=$(rpi_box) + action="$?" + + host=$(echo $main | cut -d "|" -f 1) + new=$(echo $main | cut -d "|" -f 2) + user=$(echo $main | cut -d "|" -f 3) + + # New host + [ "$new" ] && host="$new" && main="$new" + if [ "$new" ] && ! grep "^$new" ${pilist}; then + echo "$new" >> ${pilist} + fi + + # Deal with --button actions + case "$action" in + 0) ssh_term "$user@$host" ;; + 1) exit 0 ;; + 2) netmap_term ;; + 4) tazweb --notoolbar ${host}/adm ;; + *) continue ;; + esac + + # Deal with $main values + case "$main" in + Clean*) + echo "Cleaning: $pilist" + rm -f ${pilist} && touch ${pilist} + $0 box ;; + esac ;; - restore) ;; + backup) + # dd an SD card with time stamp + ;; + + restore) + # Restore a previwsly backup up SD card + ;; *) usage ;; + esac && exit 0