定义函数,然后后面的可以直接调用
#!/bin/bash
#
#
start(){
....
}
stop() {
….
}
case $1 in
start) # 服务启动需要做的步骤
...
;;
stop) # 服务停止需要做的步骤
...
;;
restart) # 重启服务需要做的步骤
...
;;
status) # 查看状态需要做的步骤
...
;;
*) echo "$0 {start|stop|restart|status}"
exit 4
;;
esac