I created an init.d script for starting a program on boot. I can see that the start action is called on boot, but immediately after that the stop action is called. Is there something missing from my script that is causing the stop action to be called on boot? Thanks
#! /bin/bash
start()
{
# code removed
}
stop()
{
# code removed
}
case "$1" in
'start')
start
exit $?
;;
'stop')
stop
exit $?
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0
hdasio1234:
I created an init.d script for starting a program on boot. I can see
that the start action is called on boot, but immediately after that the
stop action is called. Is there something missing from my script that
is causing the stop action to be called on boot? Thanks
Code:
#! /bin/bash
start()
{
code removed
}
stop()
{
code removed
}
case “$1” in
‘start’)
start
exit $?
;;
‘stop’)
stop
exit $?
;;
*)
echo “Usage: $0 { start | stop }”
exit 1
;;
esac
exit 0
Hi
Look at the file /etc/init.d/skeleton for the correct layout/format,
else convert it to systemd something like…
# /lib/systemd/system/myscript.service
#
[Unit]
Description=My script blah
[Service]
Type=simple
ExecStart=/bin/sh -c "/path/to/script/startscript"
ExecStop=/bin/sh -c "/path/to/script/stopscript"
KillSignal=SIGTERM
[Install]
WantedBy=multi-user.target
–
Cheers Malcolm °¿° (Linux Counter #276890 )
openSUSE 12.2 (x86_64) Kernel 3.4.6-2.10-desktop
up 1:58, 3 users, load average: 0.03, 0.14, 0.14
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU