summaryrefslogtreecommitdiff
path: root/noncore/tools/opie-sh/scripts/service_manager.sh
authorspiralman <spiralman>2002-09-01 14:42:39 (UTC)
committer spiralman <spiralman>2002-09-01 14:42:39 (UTC)
commitdfac71239116c4804081d925e9cf3021680b1e2c (patch) (unidiff)
treecf6a5c3897e9b73eb3415d470de95b77245abdad /noncore/tools/opie-sh/scripts/service_manager.sh
parent27b087fc3458d3d0c01eb0485490a64b2a201541 (diff)
downloadopie-dfac71239116c4804081d925e9cf3021680b1e2c.zip
opie-dfac71239116c4804081d925e9cf3021680b1e2c.tar.gz
opie-dfac71239116c4804081d925e9cf3021680b1e2c.tar.bz2
initial import of gonz's opie-sh scripts
Diffstat (limited to 'noncore/tools/opie-sh/scripts/service_manager.sh') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/tools/opie-sh/scripts/service_manager.sh110
1 files changed, 110 insertions, 0 deletions
diff --git a/noncore/tools/opie-sh/scripts/service_manager.sh b/noncore/tools/opie-sh/scripts/service_manager.sh
new file mode 100755
index 0000000..d1423a5
--- a/dev/null
+++ b/noncore/tools/opie-sh/scripts/service_manager.sh
@@ -0,0 +1,110 @@
1#!/bin/sh
2
3# service_manager.sh - a demonstration of opie-sh
4#
5# Copyright (C) 2002 gonz@directbox.com
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# 20020524-1 - added icon to statusinfo...
18# 20020518-1 - optix
19# 20020517-1 - added about and fullscreen
20#
21
22OPIE_SH=/opt/QtPalmtop/bin/opie-sh
23INITPATH=/etc/init.d
24
25######################################################################
26# subroutines
27
28about() {
29 ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/service_manager.png>"
30 echo "<h3>About</h3>"
31 echo "This little App should make it possible for you to "
32 echo "easily start and stop services in /etc/init.d."
33 echo "<p>"
34 ) | $OPIE_SH -t service-manager -f &
35 SCREENCLEAN=$!
36 sleep 1
37}
38
39cleanup() {
40 kill $SCREENCLEAN
41 rm -f /tmp/qcop-msg-service_manager.sh
42}
43
44get_action() {
45 # ask what to do (start/stop/status)
46 #
47 $OPIE_SH -m -t "Select Action" \
48 -M "which action do you want to do to $SERVICE ?<br>" \
49 -g -0 start -1 stop -2 status
50 RETURNCODE=$?
51
52 case $RETURNCODE in
53 -1) echo unexpected input detected, exiting.
54 exit ;;
55 0) ACTION=start ;;
56 1) ACTION=stop ;;
57 2) ACTION=status ;;
58 esac
59}
60
61status_disclaimer() {
62 # tell that init scripts are not too standard
63 #
64 cat | $OPIE_SH -f <<EOT
65<img src=/opt/QtPalmtop/pics/opie-sh-scripts/service_manager.png>
66<h3>status has been disabled</h3>
67
68 the status service has been disabled
69 because it is not supported by the
70 most init scripts that come with
71 familiar ...<p>
72
73 perhaps it will be replaced with
74 something more useful in the future...
75EOT
76}
77
78select_service() {
79 # present service list and choose
80 #
81 cd $INITPATH/
82 SERVICE=` ls -1 | $OPIE_SH -i -l \
83 -g -t "Select Service" \
84 `
85 cd -
86}
87
88######################################################################
89# main
90
91about
92select_service
93get_action
94
95if [ "$SERVICE" = "" ]
96then cleanup ; exit
97fi
98
99if [ "$ACTION" = "status" ]
100then status_disclaimer
101else ( echo "<h3>Output of $INITPATH/$SERVICE $ACTION:</h3>"
102 echo "<pre>"
103 $INITPATH/$SERVICE $ACTION
104 echo "</pre><p>"
105 echo done.
106 ) | $OPIE_SH -f
107fi
108
109cleanup
110