Last active
October 22, 2018 18:00
-
-
Save xdevmaycry/fc3d137adf9c4029988be5faf9b9ca75 to your computer and use it in GitHub Desktop.
/etc/init.d/script_name; borrowed from https://www.linux.com/learn/managing-linux-daemons-init-scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /etc/rc.d/init.d/script_name | |
# script_name This shell script takes care of starting and stopping | |
# script_name (the Fedora Directory Server) | |
# | |
# Author: Brian Jones | |
# This e-mail address is being protected from spambots. You need JavaScript enabled to view it | |
# Taken from: https://www.linux.com/learn/managing-linux-daemons-init-scripts | |
# | |
# chkconfig: 2345 13 87 | |
# description: script_name is the Fedora Directory Service daemon. \ | |
# FDS can serve as a repository for (and, subsequently, a source of) \ | |
# data for most of the resources listed in /etc/nsswitch.conf, such as \ | |
# passwd or group entries. | |
# Source function library. | |
. /etc/init.d/functions | |
SLAPD_HOST=`hostname -a` | |
SLAPD_DIR=/opt/fedora-ds/bin/slapd/server | |
PIDFILE=$SLAPD_DIR/logs/pid | |
STARTPIDFILE=$SLAPD_DIR/logs/startpid | |
if [ -f /etc/sysconfig/script_name ]; then | |
. /etc/sysconfig/script_name | |
fi | |
start() { | |
echo -n "Starting Fedora Directory Server: " | |
if [ -f $STARTPIDFILE ]; then | |
PID=`cat $STARTPIDFILE` | |
echo script_name already running: $PID | |
exit 2; | |
elif [ -f $PIDFILE ]; then | |
PID=`cat $PIDFILE` | |
echo script_name already running: $PID | |
exit 2; | |
else | |
cd $SLAPD_DIR | |
daemon ./script_name $OPTIONS | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/script_name | |
return $RETVAL | |
fi | |
} | |
stop() { | |
echo -n "Shutting down Fedora Directory Server: " | |
echo | |
killproc script_name | |
echo | |
rm -f /var/lock/subsys/script_name | |
return 0 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status script_name | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: {start|stop|status|restart}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment