此处参考linux本身的开机脚本模式
会自动开启同目录下 S+两位数字的(S01-zhi) 脚本,并带 start 参数开启;
将各进程的开机脚本按 Sxx 的格式命名即可;
#!/bin/bash
# Start all init scripts in path
# executing them in numerical order.
#
path=`pwd`
for i in $path/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
demo S01-zhi 内容
#!/bin/bash
case "$1" in
start)
echo zhi-start
;;
stop)
echo zhi-stop
;;
restart)
echo zhi-restart
;;
*)
exit 1
esac