summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dittberner <jandd@cacert.org>2018-03-28 15:54:19 +0200
committerJan Dittberner <jandd@cacert.org>2018-03-28 15:54:19 +0200
commit8afe6775bca33110b89c4c88f260208765957dce (patch)
tree51d4c227d93eacae25dfb5a2aa76b1ddb88e3228
parent8f9b0290b1a8b181e6a243e0fa2e40076ebfa427 (diff)
downloadcacert-puppet-8afe6775bca33110b89c4c88f260208765957dce.tar.gz
cacert-puppet-8afe6775bca33110b89c4c88f260208765957dce.tar.xz
cacert-puppet-8afe6775bca33110b89c4c88f260208765957dce.zip
Add boardvoting init script
-rw-r--r--sitemodules/profiles/files/cacert_boardvoting/init.sh91
-rw-r--r--sitemodules/profiles/manifests/cacert_boardvoting.pp25
2 files changed, 116 insertions, 0 deletions
diff --git a/sitemodules/profiles/files/cacert_boardvoting/init.sh b/sitemodules/profiles/files/cacert_boardvoting/init.sh
new file mode 100644
index 0000000..dc815c6
--- /dev/null
+++ b/sitemodules/profiles/files/cacert_boardvoting/init.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: boardvoting
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: CAcert board voting system
+# Description: CAcert board voting system
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+BASE=boardvoting
+
+BOARDVOTING=/usr/local/bin/cacert-boardvoting
+BOARDVOTING_PIDFILE=/var/run/$BASE.pid
+BOARDVOTING_LOGFILE=/var/log/$BASE.log
+BOARDVOTING_OPTS=
+BOARDVOTING_DESC="Boardvoting"
+
+# Get lsb functions
+. /lib/lsb/init-functions
+
+if [ -f /etc/default/$BASE ]; then
+ . /etc/default/$BASE
+fi
+
+# Check boardvoting is present
+if [ ! -x $BOARDVOTING ]; then
+ log_failure_msg "$BOARDVOTING not present or not executable"
+ exit 1
+fi
+
+fail_unless_root() {
+ if [ "$(id -u)" != '0' ]; then
+ log_failure_msg "$BOARDVOTING_DESC must be run as root"
+ exit 1
+ fi
+}
+
+case "$1" in
+ start)
+ fail_unless_root
+
+ touch "$BOARDVOTING_LOGFILE"
+ chown boardvoting:adm "$BOARDVOTING_LOGFILE"
+
+ log_begin_msg "Starting $BOARDVOTING_DESC: $BOARDVOTING"
+ start-stop-daemon --start --background --no-close \
+ --exec "$BOARDVOTING" \
+ --pidfile "$BOARDVOTING_PIDFILE" \
+ --make-pidfile \
+ -- \
+ $BOARDVOTING_OPTS >> "$BOARDVOTING_LOGFILE" 2>&1
+ log_end_msg $?
+ ;;
+
+ stop)
+ fail_unless_root
+ if [ -f "$BOARDVOTING_PIDFILE" ]; then
+ start-stop-daemon --stop --pidfile "$BOARDVOTING_PIDFILE" --retry 5
+ log_end_msg $?
+ else
+ log_warning_msg "$BOARDVOTING_DESC already stopped - file $BOARDVOTING_PIDFILE not found."
+ fi
+ ;;
+
+ restart)
+ fail_unless_root
+ boardvoting_pid=`cat "$BOARDVOTING_PIDFILE" 2> /dev/null`
+ [ -n "$boardvoting_pid" ] \
+ && ps -p $boardvoting_pid > /dev/null 2>&1 \
+ && $0 stop
+ $0 start
+ ;;
+
+ force-reload)
+ fail_unless_root
+ $0 restart
+ ;;
+
+ status)
+ status_of_proc -p "$BOARDVOTING_PIDFILE" "$BOARDVOTING" "$BOARDVOTING_DESC"
+ ;;
+
+ *)
+ echo "Usage: service boardvoting {start|stop|restart|force-reload|status}"
+ exit 1
+ ;;
+esac
diff --git a/sitemodules/profiles/manifests/cacert_boardvoting.pp b/sitemodules/profiles/manifests/cacert_boardvoting.pp
index 8ffaaf0..265d94b 100644
--- a/sitemodules/profiles/manifests/cacert_boardvoting.pp
+++ b/sitemodules/profiles/manifests/cacert_boardvoting.pp
@@ -42,8 +42,33 @@ class profiles::cacert_boardvoting () {
}
file { '/etc/boardvoting':
ensure => directory,
+ owner => 'root',
group => 'boardvoting',
mode => '0750',
require => Group['boardvoting'],
}
+ file { '/etc/boardvoting/ssl':
+ ensure => directory,
+ owner => 'root',
+ group => 'boardvoting',
+ mode => '0750',
+ require => Group['boardvoting'],
+ }
+ file { '/var/lib/boardvoting':
+ ensure => directory,
+ owner => 'boardvoting',
+ group => 'boardvoting',
+ mode => '0750',
+ require => User['boardvoting'],
+ }
+ package { 'lsb-base':
+ ensure => latest,
+ }
+ file { '/etc/init.d/boardvoting':
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ source => 'puppet:///modules/profiles/cacert_boardvoting/init.sh',
+ }
}