slitaz-arm view rpi/slitaz-rpi @ rev 165

Add a clean command to pileds
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 04 06:00:37 2014 +0200 (2014-05-04)
parents 3bffab5ac240
children 0eb0f35e2f0d
line source
1 #!/bin/sh
2 #
3 # A tiny utility to help manage SliTaz R-Pis from an i486 machine. Make
4 # it clean and fast for users :-). if you're looking for the SliTaz R-Pi
5 # distro builder, have a look at sat-rpi.
6 #
7 # (C) 2014 SliTaz ARM - BSD License
8 # AUTHOR: Christophe Lincoln <pankso@slitaz.org>
9 #
10 # TODO:
11 #
12 # GUI box to dl/install SliTaz R-Pi on sdcard (à la tazusb-box)
13 # SD card DD backup and restore
14 # Setup a R-Pi webboot on any i?86/X64 server/machine
15 #
16 #
17 . /lib/libtaz.sh
19 usage() {
20 cat << EOT
22 $(boldify "Usage:") $(basename $0) [command] [host]
24 $(boldify "Commands:")
25 netmap Search and map R-Pis on the wired local network
26 pscan Scan one or all Raspberry Pi hosts open ports
28 EOT
29 }
31 case "$1" in
32 netmap)
33 # MAC address works for wired raspberry R-Pis
34 # http://hwaddress.com/?q=raspberry
35 newline && colorize 35 "Raspberry Pi wired LAN map"
36 separator
37 arp -a | grep -i "b8:27:eb" | awk '{print $2}' | while read line
38 do
39 ip=$(echo "$line" | tr -d '()')
40 ssh="$(colorize 31 OFF)"
41 http="$ssh"
42 if pscan ${ip} -p 22 -P 22 | fgrep 'ssh' | fgrep -q 'open'; then
43 ssh="$(colorize 32 ON)"
44 fi
45 if pscan ${ip} -p 81 -P 81 | fgrep 'http' | fgrep -q 'open'; then
46 http="$(colorize 32 ON)"
47 fi
48 echo -n "IP: $ip $(indent 30 "SSH: $ssh")"
49 indent 46 "HTTP: $http"
50 done
51 separator
52 count=$(arp -a | grep -i "b8:27:eb" | wc -l)
53 echo -n "Raspberry Pi found: "; boldify "$count"
54 newline ;;
56 pscan)
57 [ "$2" ] && pscan ${2} && exit 0
58 arp -a | grep -i "b8:27:eb" | awk '{print $2}' | while read line
59 do
60 ip=$(echo "$line" | tr -d '()')
61 newline
62 echo "$(colorize 35 'Raspberry Pi Open ports')"
63 separator
64 pscan ${ip}
65 separator; newline
66 done ;;
68 backup) ;;
70 restore) ;;
72 *) usage ;;
73 esac && exit 0