I'm trying to write a script that can set a service to:
- automatically restart after killed
- automatically start during boot up
I can do this by using /etc/inittab
but some of the AIX server that I'm working on don't have inittab
. Meaning I cannot set the service to behave like the one in inittab. While I was trying a workaround, I found out about mkssys, rmssys, startsrc and stopsrc. So I tried writing a script using all the command.
%post
if [ -f /bin/mkssys ]; then
mkssys -s myservice -p /opt/fikrie/bin/myservice -a "-n" -u -R -S -f 9 -n 15
startsrc -s myservice
else
#use the inittab's script here
fi
%postun
if [ -f /bin/stopsrc ]; then
stopsrc -s myservice
rmssys -s myservice
else
#use the inittab's script here
fi
This script almost did the job. The only problem is that the service doesn't start during boot up. Which mean I need to manually start the process when the server first boot up. Is there any command to do this? Did I miss any available option on the mkssys command?
I tried to follow sshd service because it is not in the inittab, but does start during boot up. Maybe I could use the same trick for my service. I think the sshd is using the rc.d to start the service during boot up. So I tried writing a script in the same directory as sshd but it doesn't seems to work. Can anyone help or guide me to the correct path?