脚本不会手动启动(或启动时)(init.d)

时间:2017-08-24 13:42:50

标签: linux shell debian init.d lsb

我正在运行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天...

关于如何创建deamon的任何想法,我可以在启动时启动并在debian上启动start.sh脚本?

0 个答案:

没有答案