Files
openrouter/rootfs/etc/init.d/init-functions
T

78 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
init () {
test -f $DAEMON || exit 0
case "$1" in
start)
notify $NOTIFY_START
if [ $LOG ] ; then
$start_command $start_params 2>>/var/log/$LOG &
check $?
else
$start_command $start_params &>/dev/null &
check $?
fi
echo $! > $PIDFILE
;;
stop)
notify $NOTIFY_STOP
if [ $STOP ] ; then
$STOP $PARAMS
else
[ -f $PIDFILE ] && kill $(cat $PIDFILE) &>/dev/null
fi
;;
restart|reload)
"$0" stop
"$0" start
;;
*)
echo "$NAME init script usage: $0 {start|stop|restart}"
return 1
esac
return $?
}
rc () {
if [ -d /etc/rc.d ] && [ $0 == "/etc/init.d/rcK" ]; then
for x in $(ls -r /etc/rc.d/) ; do
/etc/rc.d/$x stop
done
return 1
fi
for i in /etc/rc.d/??* ; do
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
$i start
;;
esac
done
sleep 1
#clear
return 1
}
check() {
if [[ "$1" == "0" ]];then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
}
notify() {
printf "$*"
}