Created
September 30, 2018 02:18
-
-
Save msaulohenrique/6b63396707b3e64dae83be917f4ffd94 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# Init Script to run stunnel in daemon mode at boot time. | |
# | |
# Author: Riccardo Riva - RPM S.r.l. | |
# Revision 1.0 - 2010 November, 11 | |
#==================================================================== | |
# Run level information: | |
# | |
# chkconfig: 2345 99 99 | |
# description: Secure Tunnel | |
# processname: stunnel | |
# | |
# Run "/sbin/chkconfig --add stunnel" to add the Run levels. | |
# This will setup the symlinks and set the process to run at boot. | |
#==================================================================== | |
#==================================================================== | |
# Paths and variables and system checks. | |
# Source function library | |
. /etc/rc.d/init.d/functions | |
# Check that networking is up. | |
# | |
[ ${NETWORKING} ="yes" ] || exit 0 | |
# Path to the executable. | |
# | |
SEXE=/usr/bin/stunnel | |
# Path to the configuration file. | |
# | |
CONF=/etc/stunnel/stunnel.conf | |
# Check the configuration file exists. | |
# | |
if [ ! -f $CONF ] ; then | |
echo "The configuration file cannot be found!" | |
exit 0 | |
fi | |
# Path to the lock file. | |
# | |
LOCK_FILE=/var/lock/subsys/stunnel | |
#==================================================================== | |
# Run controls: | |
prog=$"stunnel" | |
RETVAL=0 | |
# Start stunnel as daemon. | |
# | |
start() { | |
if [ -f $LOCK_FILE ]; then | |
echo "stunnel is already running!" | |
exit 0 | |
else | |
echo -n $"Starting $prog: " | |
$SEXE $CONF | |
fi | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && success | |
echo | |
[ $RETVAL -eq 0 ] && touch $LOCK_FILE | |
return $RETVAL | |
} | |
# Stop stunnel. | |
# | |
stop() { | |
if [ ! -f $LOCK_FILE ]; then | |
echo "stunnel is not running!" | |
exit 0 | |
else | |
echo -n $"Shutting down $prog: " | |
killproc stunnel | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] | |
rm -f $LOCK_FILE | |
echo | |
return $RETVAL | |
fi | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
condrestart) | |
if [ -f $LOCK_FILE ]; then | |
stop | |
start | |
RETVAL=$? | |
fi | |
;; | |
status) | |
status stunnel | |
RETVAL=$? | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|condrestart|status}" | |
RETVAL=1 | |
esac | |
exit $RETVAL | |
#--- End of file --- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment