我正在运行 tinkerOS,它是 debian 的发行版。但是由于某种原因,在 raspbian(也是基于 debian)上工作的 cwhservice 不能在 tinkerOS 上运行。
脚本放在/etc/init.d/中,名为cwhservice,systemctl deamon-reload已经完成,代码如下:
#!/bin/sh
### BEGIN INIT INFO
# Provides: CWH
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the CWH
# Description: Starts the CWH
### END INIT INFO
case "$1" in
start)
/opt/cwh/start.sh > /opt/cwh/log.scrout 2> /opt/cwh/log.screrr
;;
stop)
/opt/cwh/stop.sh
;;
restart)
/opt/cwh/stop.sh
/opt/cwh/start.sh
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
当我运行时:sudo service cwhservice start
我收到以下错误:
Job for cwhservice.service failed because the control process exited with error code.
See "systemctl status cwhservice.service" and "journalctl -xe" for details.
systemctl status cwhservice.service 给出:
● cwhservice.service - LSB: Starts the CWH
Loaded: loaded (/etc/init.d/cwhservice; generated; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-08-24 13:36:22 UTC; 1min 21s ago
Docs: man:systemd-sysv-generator(8)
Process: 15431 ExecStart=/etc/init.d/cwhservice start (code=exited, status=203/EXEC)
Aug 24 13:36:22 linaro-alip systemd[1]: Failed to start LSB: Starts the CWH.
Aug 24 13:36:22 linaro-alip systemd[1]: cwhservice.service: Failed with result 'exit-code'.
因此,在摆弄了所有代码和值之后,我仍然没有得到它太多的工作,所以我尝试改造重启脚本,目前最终结果为:
#! /bin/sh
### BEGIN INIT INFO
# Provides: kaas2
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 6
# Short-Description: Execute the reboot command.
# Description:
### END INIT INFO
case "$1" in
start)
# No-op
/opt/cwh/start.sh
echo "foo" >&2
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
status)
exit 0
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
sudo service cwhservice start
不返回错误,但什么也不做。但出于某种奇怪的原因,sudo service cwhservicer restart
实际上启动了 start.sh 脚本但没有返回回声......所以我现在完全迷失了,浪费了 2 天......
关于如何创建一个可以在启动时启动并在 debian 上启动 start.sh 脚本的守护程序的任何想法?