slitaz-arm rev 116

Add slitaz-rpi - user tool to manage R-Pi's from a standard i486 machine
author Christophe Lincoln <pankso@slitaz.org>
date Mon Apr 21 02:09:15 2014 +0200 (2014-04-21)
parents 30880db2d56f
children 128b9292c97e
files rpi/slitaz-rpi
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rpi/slitaz-rpi	Mon Apr 21 02:09:15 2014 +0200
     1.3 @@ -0,0 +1,73 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# A tiny utility to help manage SliTaz R-Pi's from an i486 machine. Make
     1.7 +# it clean and fast for users :-). i you looking for the SliTaz R-Pi distro
     1.8 +# builder, have a look at sat-rpi.
     1.9 +#
    1.10 +# (C) 2014 SliTaz ARM - BSD License
    1.11 +# AUTHOR: Christophe Lincoln <pankso@slitaz.org> 
    1.12 +#
    1.13 +# TODO:
    1.14 +#
    1.15 +#   GUI box to dl/install SliTaz R-Pi on sdcard (à la tazusb-box)
    1.16 +#   SD card DD backup and restore
    1.17 +#   Setup a R-Pi webboot on any i?86/X64 server/machine
    1.18 +#
    1.19 +#
    1.20 +. /lib/libtaz.sh
    1.21 +
    1.22 +usage() {
    1.23 +	cat << EOT
    1.24 +
    1.25 +$(boldify "Usage:") $(basename $0) [command] [host]
    1.26 +
    1.27 +$(boldify "Commands:")
    1.28 +  netmap    Search and map R-Pi's on the wired local network
    1.29 +  pscan     Scan a or all Raspberry Pi hosts open ports
    1.30 +
    1.31 +EOT
    1.32 +}
    1.33 +
    1.34 +case "$1" in
    1.35 +	netmap)
    1.36 +		# MAC address works for wired raspberry R-Pi's
    1.37 +		# http://hwaddress.com/?q=raspberry
    1.38 +		newline && colorize 35 "Raspberry Pi wired LAN map"
    1.39 +		separator
    1.40 +		arp -a | grep -i "b8:27:eb" | awk '{print $2}' | while read line
    1.41 +		do
    1.42 +			ip=$(echo "$line" | tr -d '()')
    1.43 +			ssh="$(colorize 31 OFF)"
    1.44 +			http="$ssh"
    1.45 +			if pscan ${ip} -p 22 -P 22 | fgrep 'ssh' | fgrep -q 'open'; then
    1.46 +				ssh="$(colorize 32 ON)"
    1.47 +			fi
    1.48 +			if pscan ${ip} -p 81 -P 81 | fgrep 'http' | fgrep -q 'open'; then
    1.49 +				http="$(colorize 32 ON)"
    1.50 +			fi
    1.51 +			echo -n "IP: $ip $(indent 30 "SSH: $ssh")"
    1.52 +			indent 46 "HTTP: $http"
    1.53 +		done
    1.54 +		separator
    1.55 +		count=$(arp -a | grep -i "b8:27:eb" | wc -l)
    1.56 +		echo -n "Raspberry Pi found: "; boldify "$count"
    1.57 +		newline ;;
    1.58 +	
    1.59 +	pscan)
    1.60 +		[ "$2" ] && pscan ${2} && exit 0
    1.61 +		arp -a | grep -i "b8:27:eb" | awk '{print $2}' | while read line
    1.62 +		do
    1.63 +			ip=$(echo "$line" | tr -d '()')
    1.64 +			newline
    1.65 +			echo "$(colorize 35 'Raspberry Pi Open ports')"
    1.66 +			separator
    1.67 +			pscan ${ip}
    1.68 +			separator; newline
    1.69 +		done ;;
    1.70 +	
    1.71 +	backup) ;;
    1.72 +	
    1.73 +	restore) ;;
    1.74 +	
    1.75 +	*) usage ;;
    1.76 +esac && exit 0