Nethence Newdoc Olddoc Lab Your IP BBDock  


Warning: those guides are mostly obsolete, please have a look at the new documentation.

UnixWindowsOracleObsoleteHardwareDIYMechanicsScriptsConfigs

Maintaining init.d vs systemd scripts
 
http://pbraun.nethence.com/unix/sysutils_linux/redhat_rhel7.html
http://pbraun.nethence.com/unix/sysutils_linux/systemd.html
 
On RHEL7, you can still create old fashioned init.d scripts and link them to systemd,
service=servicename 
cd /etc/init.d/
cat > $service <<EOF9 # escaping $1 and $?
#!/bin/bash
#
# chkconfig: 2345 99 01
# description: $service init script
#
 
# Source function library.
. /etc/init.d/functions
 
start() {
echo -n "Starting $service: "
command_line_start_service 
touch /var/lock/subsys/$service
return 0
}
 
status() {
command_line_status_service | grep -v /sbin/service | grep -v init.d 
}
 
stop() {
echo -n "Shutting down $service "
command_line_stop_service 
rm -f /var/lock/subsys/$service
return 0
}
 
case "\$1" in
start)
start
;;
stop)
stop
;;
status)
status
#[[ -f /var/run/davmail.pid ]] && cat /var/run/davmail.pid || echo not running or started by this init script
;;
restart)
stop
start
;;
reload)
echo reload feature not available, use restart
;;
*)
echo "Usage: <servicename> {start|stop|status|restart]"
exit 1
;;
esac
exit \$?
EOF9
chmod +x $service
chkconfig --add $service
chkconfig $service on
chkconfig --list | grep $service
unset service
Ref. skeleton and documentation available at /usr/share/doc/initscripts-9.03.49/sysvinitfiles
 
You can now use init.d,
service $service stop / start / restart / status
also try with systemd,
systemctl status $service
systemctl restart $service
 
Clean-up variables,
unset service
 
References
RHEL7: How to get started with Systemd.: http://www.certdepot.net/rhel7-get-started-systemd/
8.2. MANAGING SYSTEM SERVICES: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html
 

(obsolete, see the new doc)