Created
January 19, 2017 01:46
-
-
Save monobilisim/071a3a9bdc0455902a5966a07a33987c to your computer and use it in GitHub Desktop.
Revisions
-
monobilisim created this gist
Jan 19, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,85 @@ #!/bin/sh ### BEGIN INIT INFO # Provides: caddy # Required-Start: $local_fs $network $named $time $syslog # Required-Stop: $local_fs $network $named $time $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the caddy web server # Description: starts caddy using start-stop-daemon ### END INIT INFO # Original Author: Frédéric Galusik (fredg) # Maintainer: Daniel van Dorp (djvdorp) # Modified by: Mono Bilişim (monobilisim) ## yum install -y daemonize DESC="the caddy web server" NAME=caddy DAEMON=$(which caddy) DAEMONUSER=webapps EMAIL=root@localhost PIDFILE=/var/run/$NAME.pid LOCKFILE=/var/lock/subsys/$NAME LOGFILE=/var/log/caddy/$NAME.log CONFIGFILE=/etc/caddy/Caddyfile DAEMONOPTS="-agree=true -email=$EMAIL -pidfile=$PIDFILE -log=$LOGFILE -conf=$CONFIGFILE" USERBIND="setcap cap_net_bind_service=+ep" STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}" test -x $DAEMON || exit 0 # Set the CADDYPATH; Let's Encrypt certificates will be written to this directory. export CADDYPATH=/etc/caddy/ssl # Set the ulimits ulimit -n 8192 start() { $USERBIND $DAEMON daemonize -p $PIDFILE -l $LOCKFILE $DAEMON $DAEMONOPTS } stop() { kill -9 $(cat "$PIDFILE") rm -f $PIDFILE $LOCKFILE } status() { if [ -f $PIDFILE ]; then if kill -0 $(cat "$PIDFILE"); then echo "$NAME is running" else echo "$NAME process is dead, but pidfile exists" fi else echo "$NAME is not running" fi } case "$1" in start) echo "Starting $NAME" start ;; stop) echo "Stopping $NAME" stop ;; restart) echo "Restarting $NAME" stop start ;; status) status ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 2 ;; esac exit 0