Running Fedora 33/34 on multiple machines. I successfully activated rc-local.service
which works fine. I have couple of other scripts that I need to run in /etc/init.d/
and I created similar service files as rc-local.service
, but I can't enable it, whereas rc-local.service can be enabled/disabled/stared/stopped without any troubles.
I know, that I have an option (which I currently use) to call those scripts from rc.local
file, but would rather called them separately as service. So my service file looks like this:
#cat net-scr1.service
[Unit]
Description=Network check service
ConditionFileIsExecutable=/etc/init.d/net-scr1
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/net-scr1 start
TimeoutSec=3
ExecStop=/etc/init.d/net-scr1 stop
RemainAfterExit=yes
GuessMainPID=no
StandardOutput=tty
[Install]
WantedBy=multi-user.target
systemctl enable net-scr1
Synchronizing state of net-scr1.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable net-scr1
service net-scr1 does not support chkconfig
I moved the script out of init.d
thinking maybe systemd assumes it's an old sysv
script, but no change. What should I have in my script to work properly?
My script looks like:
#!/bin/bash
[email protected]
[email protected]
dv0=p1p1
ipdv0=`ifconfig $dv0 | grep "inet " | awk '{print $2}'`
if [ "$1" = "stop" ]; then
cat $msg | mail $EMFR -s "$srv-shut_down-ip-$ipdv0" $eml
fi
if [ "$1" = "start" ]; then
cat $msg | mail $EMFR -s "$srv-booted_up-ip-$ipdv0" $eml
fi
Should I include Functions from the old sysv system or something else? Thanks
See this
I've found a solution. I have included following 3 lines on top of my script:
head /etc/init.d/net-scr1
now
systemctl enable net-scr1
works fine