Bug 221732 - sysutils/consul - check config in rc.d script
Summary: sysutils/consul - check config in rc.d script
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Steve Wills
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-23 03:39 UTC by Andrew Thompson
Modified: 2017-09-17 01:44 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (swills)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Thompson freebsd_committer freebsd_triage 2017-08-23 03:39:51 UTC
Consul will silently fail to load if there is a syntax error in the config, add a precheck to catch this.


--- /usr/local/etc/rc.d/consul	2017-07-19 10:19:37.000000000 +1200
+++ /tmp/puppet-file20170823-57649-2mf3pd	2017-08-23 15:29:05.985906660 +1200
@@ -22,7 +22,7 @@
 
 name=consul
 rcvar=consul_enable
-extra_commands="reload"
+extra_commands="reload configtest"
 
 load_rc_config $name
 
@@ -37,6 +37,10 @@
 command_args="-f -p ${pidfile} /usr/bin/env ${consul_env} ${procname} agent -data-dir=${consul_dir} -config-dir=/usr/local/etc/consul.d ${consul_args}"
 
 start_precmd=consul_startprecmd
+restart_precmd=consul_checkconfig
+reload_precmd=consul_checkconfig
+configtest_cmd=consul_checkconfig
+upgrade_precmd=consul_checkconfig
 
 consul_startprecmd()
 {
@@ -47,7 +51,12 @@
         if [ ! -d ${consul_dir} ]; then
                 install -d -o ${consul_user} -g ${consul_group} ${consul_dir}
         fi
+	consul_checkconfig
+}
 
+consul_checkconfig()
+{
+	${procname} validate /usr/local/etc/consul.d
 }
 
 run_rc_command "$1"
Comment 1 Andrew Thompson freebsd_committer freebsd_triage 2017-08-23 03:41:45 UTC
I used nginx as a template, the upgrade_precmd line shouldnt have been copied.
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-09-17 01:43:30 UTC
A commit references this bug:

Author: swills
Date: Sun Sep 17 01:43:07 UTC 2017
New revision: 449980
URL: https://svnweb.freebsd.org/changeset/ports/449980

Log:
  sysutils/consul: check config in rc.d script

  PR:		221732
  Submitted by:	thompsa

Changes:
  head/sysutils/consul/Makefile
  head/sysutils/consul/files/consul.in
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-09-17 01:44:33 UTC
A commit references this bug:

Author: swills
Date: Sun Sep 17 01:44:09 UTC 2017
New revision: 449981
URL: https://svnweb.freebsd.org/changeset/ports/449981

Log:
  sysutils/consul: remove unneeded upgrade_precmd line

  PR:		221732
  Pointyhat to:	swills

Changes:
  head/sysutils/consul/files/consul.in
Comment 4 Steve Wills freebsd_committer freebsd_triage 2017-09-17 01:44:58 UTC
Committed, thanks!