systemd or init.d
by Jinux75 from LinuxQuestions.org on (#4Y00Z)
Hello, i have some questions because i do not understand the logic of it.
It is a bit hard for me to explain, but here goes:
I have some program.sh and that can be started with init.d or systemd.
The wiki of the program tells me it is preferred to use systemd, so i setup a service file and it works. But i just do not understand how this works.
Here is the service file:
Code:[Unit]
Description=program_service
[Service]
User=me
Group=me
ExecStart=/home/me/program/program
WorkingDirectory=/home/me/program
[Install]
WantedBy=multi-user.targetHere is the program.sh file where the service file points to:
Code:#! /bin/sh
### BEGIN INIT INFO
# Provides: program
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Some program example
# Description: This daemon will start some program example
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Some program"
NAME=program
USERNAME=me
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/home/$USERNAME/program/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -log /tmp/program.txt"
#DAEMON_ARGS="$DAEMON_ARGS -syslog"As you can see in the program.sh the scriptname points to init.d, but it is setup in systemd so i just do not get the logic. And when i start it with init.d logging works, but if it crashes it is not started automatically. And when i use systemd the logging does not work but if it crashes it just restarts.
Also when in the wiki i choose the preferred method to start, every change they describe is made when starting it from init.d. So it is a bit hard to understand how to make changes if i use the systemd method.
Can any one explain to me why in the program.sh it is pointed to /etc/init.d as the preferred method in systemd?
Do i need to put the program.sh also in init.d?
Here is the programs wiki and the preferred method of starting it:
https://www.domoticz.com/wiki/Linux
And here is one of the many changes that can be made, where they use it in init.d:
https://www.domoticz.com/wiki/Setup_fail2ban
https://www.domoticz.com/wiki/Plugins/BatteryLevel.html
As i said it is a bit hard for me to explain, i just like to see the logic of it so i can understand what to do when making changes and using systemd.
Does it just work like this? Should the program.sh be edited so the script point to somewhere else? Why is the script pointed to init.d as there is nothing there it still works.
Here is my computer and linux:
Code:Architecture: i686
CPU op-mode(s): 32-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 2
Core(s) per socket: 1
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 28
Model name: Intel(R) Atom(TM) CPU N270 @ 1.60GHz
Stepping: 2
CPU MHz: 1187.069
CPU max MHz: 1600,0000
CPU min MHz: 800,0000
BogoMIPS: 3192.14
L1d cache: 24K
L1i cache: 32K
L2 cache: 512K
on the ssd it runs:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.10
DISTRIB_CODENAME=cosmic
DISTRIB_DESCRIPTION="Ubuntu 18.10"
NAME="Ubuntu"
VERSION="18.10 (Cosmic Cuttlefish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.10"
VERSION_ID="18.10"Thanks for reading.


It is a bit hard for me to explain, but here goes:
I have some program.sh and that can be started with init.d or systemd.
The wiki of the program tells me it is preferred to use systemd, so i setup a service file and it works. But i just do not understand how this works.
Here is the service file:
Code:[Unit]
Description=program_service
[Service]
User=me
Group=me
ExecStart=/home/me/program/program
WorkingDirectory=/home/me/program
[Install]
WantedBy=multi-user.targetHere is the program.sh file where the service file points to:
Code:#! /bin/sh
### BEGIN INIT INFO
# Provides: program
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Some program example
# Description: This daemon will start some program example
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Some program"
NAME=program
USERNAME=me
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/home/$USERNAME/program/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -log /tmp/program.txt"
#DAEMON_ARGS="$DAEMON_ARGS -syslog"As you can see in the program.sh the scriptname points to init.d, but it is setup in systemd so i just do not get the logic. And when i start it with init.d logging works, but if it crashes it is not started automatically. And when i use systemd the logging does not work but if it crashes it just restarts.
Also when in the wiki i choose the preferred method to start, every change they describe is made when starting it from init.d. So it is a bit hard to understand how to make changes if i use the systemd method.
Can any one explain to me why in the program.sh it is pointed to /etc/init.d as the preferred method in systemd?
Do i need to put the program.sh also in init.d?
Here is the programs wiki and the preferred method of starting it:
https://www.domoticz.com/wiki/Linux
And here is one of the many changes that can be made, where they use it in init.d:
https://www.domoticz.com/wiki/Setup_fail2ban
https://www.domoticz.com/wiki/Plugins/BatteryLevel.html
As i said it is a bit hard for me to explain, i just like to see the logic of it so i can understand what to do when making changes and using systemd.
Does it just work like this? Should the program.sh be edited so the script point to somewhere else? Why is the script pointed to init.d as there is nothing there it still works.
Here is my computer and linux:
Code:Architecture: i686
CPU op-mode(s): 32-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 2
Core(s) per socket: 1
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 28
Model name: Intel(R) Atom(TM) CPU N270 @ 1.60GHz
Stepping: 2
CPU MHz: 1187.069
CPU max MHz: 1600,0000
CPU min MHz: 800,0000
BogoMIPS: 3192.14
L1d cache: 24K
L1i cache: 32K
L2 cache: 512K
on the ssd it runs:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.10
DISTRIB_CODENAME=cosmic
DISTRIB_DESCRIPTION="Ubuntu 18.10"
NAME="Ubuntu"
VERSION="18.10 (Cosmic Cuttlefish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.10"
VERSION_ID="18.10"Thanks for reading.