some modification on instpkg
[cmdllinux.git] / scripts / manage / svcrun
blob52c2e1642e17dd80f24243d49638a2e9c06e0931
1 #! /bin/bash
3 : ${DIALOG=dialog}
5 lsservices()
7 find /etc/runlevels -maxdepth 1 -type l | sort | \
8 while read svc; do
9 TMPRESULT=`rc-service ${svc##*/} status 2> /dev/null`
10 retval=$?
11 if [ -z "$TMPRESULT" ]; then
12 if [ "$retval" != 0 ]; then
13 SVCSTATUS=" error"
14 else
15 SVCSTATUS=" novalue"
17 else
18 SVCSTATUS=`echo "$TMPRESULT" | cut -d : -f 2`
20 echo "${svc##*/}$SVCSTATUS"
21 done
24 while true; do
25 SVC=`$DIALOG --stdout --backtitle "Run services" --title "" --clear --ok-label "Run/Stop" --cancel-label "Exit" --menu "Services:" 20 61 15 $(lsservices)`
26 retval=$?
27 case $retval in
29 if [ "$SVC" != "" ]; then
30 rc-service $SVC status | grep -qw "started$" && rc-service $SVC stop || rc-service $SVC start
34 break
36 255)
37 break
39 esac
40 done