summaryrefslogtreecommitdiff
path: root/noncore/tools/opie-sh/scripts/hostlist.sh
blob: d7c94f8da702b15434d3d3f4295bd30cb7390791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh

# hostlist.sh - a demonstration of opie-sh
#
# Copyright (C) 2002 gonz@directbox.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# 20020524-1 - icon to hostlist
# 20020517-1 - added icon, changed name in launcher
#

CFG=$OPIEDIR/share/config/hostlist.cfg
OPIE_SH=opie-sh

hostlist() {
(	echo "<img src=$OPIEDIR/pics/opie-sh-scripts/hostlist.png>"
	echo "<h3>Hostlist</h3><br>"
	HOSTLIST=`cat $CFG | grep -v '#'`
	for HOST in $HOSTLIST
	do
		PT=` ping -c 1 $HOST | grep avg|cut -d " " -f4-`
		if [ "$PT" != "" ] 
		then echo "<b><font color=#00ff00> "
		     echo "$HOST is up<br></font></b>[$PT]<br>"
		else echo "<b><font color=#ff0000> "
		     echo "$HOST is down<br></font></b>[$PT]<br>"
		fi
	done
)       | $OPIE_SH -t "Which are up ?" -f 


}

cleanup() {
	kill  $SCREENCLEAN
	rm -f /tmp/qcop-msg-hostlist.sh
}

about() {
	( echo "<img src=$OPIEDIR/pics/opie-sh-scripts/hostlist.png>"
	  echo "<h3>About</h3>"
	  echo "This little App should make it possible for you to "
	  echo "check some hosts for availability."
	  echo "<p>"
        )  | $OPIE_SH -t hostlist -f  &
	SCREENCLEAN=$!
	sleep 1
}

#####################################################################
#
# main

about

# ask to: start or edit list
$OPIE_SH -m -g -t Hostlist -M "Welcome!" -0 Start -1 "Edit Hostlist"
RETURNCODE=$?
case $RETURNCODE in
-1)	echo died unexpectedly... | $OPIE_SH -f
	cleanup
	exit ;; 
1)      textedit $CFG 
	cleanup ;;
0)	if [ -f $CFG ]
	then	hostlist
	else 	echo www,handhelds.org >$CFG ; hostlist
	fi
	cleanup 
	;;
esac