實現代碼
#!/bin/bash
. /etc/init.d/functions
function usage()
{
echo "$0 {start|stop|restart}"
}
if [ $# -ne 1 ]
then
echo "ttt"
usage
exit 1
fi
case $1 in
start)
action "start..." /bin/true
;;
*)
usage
;;
esac
存為test_1.sh
[root@test# sh test_1.sh
ttt
test_1.sh {start|stop|restart}
[root@test]# sh test_1.sh start
start... [ OK ]
關鍵代碼是. /etc/init.d/functions 和action "start..." /bin/true,失敗則是 action "fail..." /bin/false