Diffstat (limited to 'noncore/tools/opie-sh/scripts/service_manager.sh') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/tools/opie-sh/scripts/service_manager.sh | 110 |
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 | |||
22 | OPIE_SH=/opt/QtPalmtop/bin/opie-sh | ||
23 | INITPATH=/etc/init.d | ||
24 | |||
25 | ###################################################################### | ||
26 | # subroutines | ||
27 | |||
28 | about() { | ||
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 | |||
39 | cleanup() { | ||
40 | kill $SCREENCLEAN | ||
41 | rm -f /tmp/qcop-msg-service_manager.sh | ||
42 | } | ||
43 | |||
44 | get_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 | |||
61 | status_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... | ||
75 | EOT | ||
76 | } | ||
77 | |||
78 | select_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 | |||
91 | about | ||
92 | select_service | ||
93 | get_action | ||
94 | |||
95 | if [ "$SERVICE" = "" ] | ||
96 | then cleanup ; exit | ||
97 | fi | ||
98 | |||
99 | if [ "$ACTION" = "status" ] | ||
100 | then status_disclaimer | ||
101 | else ( 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 | ||
107 | fi | ||
108 | |||
109 | cleanup | ||
110 | |||