TUN-528: Move cloudflared into a separate repo

This commit is contained in:
Areg Harutyunyan
2018-05-01 18:45:06 -05:00
parent e8c621a648
commit d06fc520c7
4726 changed files with 1763680 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
SysVinit conf for Caddy
=======================
Usage
-----
* Download the appropriate Caddy binary in `/usr/local/bin/caddy` or use `curl https://getcaddy.com | bash`.
* Save the SysVinit config file in `/etc/init.d/caddy`.
* Ensure that the folder `/etc/caddy` exists and that the folder `/etc/ssl/caddy` is owned by `www-data`.
* Create a Caddyfile in `/etc/caddy/Caddyfile`
* Now you can use `service caddy start|stop|restart|reload|status` as `root`.
Init script manipulation
-----
The init script supports configuration via the following files:
* `/etc/default/caddy` ( Debian based https://www.debian.org/doc/manuals/debian-reference/ch03.en.html#_the_default_parameter_for_each_init_script )
* `/etc/sysconfig/caddy` ( CentOS based https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-sysconfig-files.html )
The following variables can be changed:
* DAEMON: path to the caddy binary file (default: `/usr/local/bin/caddy`)
* DAEMONUSER: user used to run caddy (default: `www-data`)
* PIDFILE: path to the pidfile (default: `/var/run/$NAME.pid`)
* LOGFILE: path to the log file for caddy daemon (not for access logs) (default: `/var/log/$NAME.log`)
* CONFIGFILE: path to the caddy configuration file (default: `/etc/caddy/Caddyfile`)
* CADDYPATH: path for SSL certificates managed by caddy (default: `/etc/ssl/caddy`)
* ULIMIT: open files limit (default: `8192`)

View File

@@ -0,0 +1,106 @@
#!/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)
DESC="the caddy web server"
NAME=caddy
DAEMON=/usr/local/bin/caddy
DAEMONUSER=www-data
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME.log
CONFIGFILE=/etc/caddy/Caddyfile
USERBIND="setcap cap_net_bind_service=+ep"
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"
CADDYPATH=/etc/ssl/caddy
ULIMIT=8192
test -x $DAEMON || exit 0
# allow overwriting variables
# Debian based
[ -e "/etc/default/caddy" ] && . /etc/default/caddy
# CentOS based
[ -e "/etc/sysconfig/caddy" ] && . /etc/sysconfig/caddy
if [ -z "$DAEMONOPTS" ]; then
# daemon options
DAEMONOPTS="-agree=true -log=$LOGFILE -conf=$CONFIGFILE"
fi
# Set the CADDYPATH; Let's Encrypt certificates will be written to this directory.
export CADDYPATH
# Set the ulimits
ulimit -n ${ULIMIT}
start() {
$USERBIND $DAEMON
touch $LOGFILE && chown $DAEMONUSER $LOGFILE
start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE \
--background --chuid $DAEMONUSER --oknodo --exec $DAEMON -- $DAEMONOPTS
}
stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --retry=$STOP_SCHEDULE \
--name $NAME --oknodo
rm -f $PIDFILE
}
reload() {
start-stop-daemon --stop --quiet --signal USR1 --pidfile $PIDFILE \
--name $NAME
}
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
;;
reload)
echo "Reloading $NAME configuration"
reload
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 2
;;
esac
exit 0