mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 02:27:19 -04:00 
			
		
		
		
	Updated FreeBSD init script (#1098)
* Updated FreeBSD init script to allow the server to stop properly * Fixed FreeBSD init script permissions * Updated FreeBSD init script to allow the server to stop properly
This commit is contained in:
		
							parent
							
								
									7ef405f9b2
								
							
						
					
					
						commit
						8e54d5cecb
					
				
							
								
								
									
										28
									
								
								dist/init/freebsd/caddy
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								dist/init/freebsd/caddy
									
									
									
									
										vendored
									
									
								
							| @ -1,8 +1,7 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
| # | # | ||||||
| 
 |  | ||||||
| # PROVIDE: caddy | # PROVIDE: caddy | ||||||
| # REQUIRE: LOGIN NETWORKING named cleanvar sshd | # REQUIRE: networking | ||||||
| # KEYWORD: shutdown | # KEYWORD: shutdown | ||||||
| 
 | 
 | ||||||
| # | # | ||||||
| @ -31,7 +30,7 @@ | |||||||
| . /etc/rc.subr | . /etc/rc.subr | ||||||
| 
 | 
 | ||||||
| name="caddy" | name="caddy" | ||||||
| rcvar=${name}_enable | rcvar="${name}_enable" | ||||||
| 
 | 
 | ||||||
| load_rc_config $name | load_rc_config $name | ||||||
| : ${caddy_enable:=no} | : ${caddy_enable:=no} | ||||||
| @ -50,24 +49,35 @@ fi | |||||||
| pidfile="/var/run/caddy.pid" | pidfile="/var/run/caddy.pid" | ||||||
| logfile="/var/log/caddy.log" | logfile="/var/log/caddy.log" | ||||||
| 
 | 
 | ||||||
| command="${caddy_bin_path} -log ${logfile} -pidfile ${pidfile} -cpu ${caddy_cpu} -conf ${caddy_config_path} -agree -email ${caddy_cert_email}" | command="${caddy_bin_path} -log ${logfile} -cpu ${caddy_cpu} -conf ${caddy_config_path} -agree -email ${caddy_cert_email}" | ||||||
| 
 | 
 | ||||||
| start_cmd="caddy_start" | start_cmd="caddy_start" | ||||||
| status_cmd="caddy_status" | status_cmd="caddy_status" | ||||||
| stop_cmd="caddy_stop" | stop_cmd="caddy_stop" | ||||||
| 
 | 
 | ||||||
| caddy_start() { | caddy_start() { | ||||||
|     echo "Starting Caddy..." |     echo "Starting ${name}..." | ||||||
|     /usr/sbin/daemon -u ${caddy_run_user} -c ${command} >> ${logfile} |     /usr/sbin/daemon -u ${caddy_run_user} -c -p ${pidfile} -f ${command} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| caddy_status() { | caddy_status() { | ||||||
|     ps -p `cat ${pidfile} 2> /dev/null` > /dev/null 2>&1 && echo 'Running' || echo 'Not Running. Please note that upon startup it will take Caddy a few seconds to come up. So you might just wanna wait a few seconds before starting it again.' |     if [ -f ${pidfile} ]; then | ||||||
|  |       echo "${name} is running as $(cat $pidfile)." | ||||||
|  |     else | ||||||
|  |       echo "${name} is not running." | ||||||
|  |       return 1 | ||||||
|  |     fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| caddy_stop() { | caddy_stop() { | ||||||
|     echo "Stopping Caddy..." |     if [ ! -f ${pidfile} ]; then | ||||||
|     kill -QUIT `cat $pidfile 2> /dev/null` |       echo "${name} is not running." | ||||||
|  |       return 1 | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|  |     echo -n "Stopping ${name}..." | ||||||
|  |     kill -KILL $(cat $pidfile) 2> /dev/null && echo "stopped" | ||||||
|  |     rm -f ${pidfile} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| run_rc_command "$1" | run_rc_command "$1" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user