Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SLES #32

Merged
merged 1 commit into from
Oct 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
content => template('consul/consul.debian.erb')
}
}
'sles' : {
file { '/etc/init.d/consul':
mode => '0555',
owner => 'root',
group => 'root',
content => template('consul/consul.sles.erb')
}
}
default : {
fail("I don't know how to create an init script for style $init_style")
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
default => 'systemd',
},
'Debian' => 'debian',
'SLES' => 'sles',
default => undef
}
}
94 changes: 94 additions & 0 deletions templates/consul.sles.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
#
# /etc/rc.d/init.d/consul
#
# Daemonize the consul agent.
#
### BEGIN INIT INFO
# Provides: consul
# Required-Start: network
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Service discovery and configuration made easy.
# Description: Service discovery and configuration made easy.
### END INIT INFO

. /etc/rc.status

rc_reset

CONSUL_BIN=<%= scope.lookupvar('consul::bin_dir') %>/consul
CONFIG_DIR=<%= scope.lookupvar('consul::config_dir') %>
LOG_FILE=/var/log/consul


case "$1" in
start)
echo -n "Starting consul "
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
startproc $CONSUL_BIN agent -config-dir "$CONFIG_DIR" <%= scope.lookupvar('consul::extra_options') %> >> "$LOG_FILE"

# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down consul "
## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.

killproc -TERM $CONSUL_BIN

# Remember status and be verbose
rc_status -v
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start

# Remember status and be quiet
rc_status
;;
reload)
# If it supports signaling:
echo -n "Reload service consul "
killproc -HUP $CONSUL_BIN
#touch /var/run/consul.pid
rc_status -v

## Otherwise if it does not support reload:
#rc_failed 3
#rc_status -v
;;
status)
echo -n "Checking for service consul "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.

# Return value is slightly different for the status command:
# 0 - service up and running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running (unused)
# 4 - service status unknown :-(
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

# NOTE: checkproc returns LSB compliant status values.
checkproc $CONSUL_BIN
# NOTE: rc_status knows that we called this init script with
# "status" option and adapts its messages accordingly.
rc_status -v
;;
*)
## If no parameters are given, print which are avaiable.
echo "Usage: $0 {start|stop|status|restart|reload}"
exit 1
;;
esac

rc_exit