Skip to content

Commit

Permalink
Merge pull request #87 from voxpupuli/set-e
Browse files Browse the repository at this point in the history
add set -e to all scripts.
  • Loading branch information
rwaffen authored Apr 18, 2024
2 parents e832a9e + 181377c commit a84fc0c
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /bin/bash
#!/bin/bash

set -e

# During build, pristine config files get copied to this directory. If
# they are not in the current container, use these templates as the
Expand Down
4 changes: 3 additions & 1 deletion puppetserver/docker-entrypoint.d/30-set-permissions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /bin/bash
#!/bin/bash

set -e

chown -R puppet:puppet /etc/puppetlabs/puppet/
chown -R puppet:puppet /opt/puppetlabs/server/data/puppetserver/
Expand Down
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/40-update-puppetdb-conf.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

if test -n "${PUPPETDB_SERVER_URLS}" ; then
sed -i "s@^server_urls.*@server_urls = ${PUPPETDB_SERVER_URLS}@" /etc/puppetlabs/puppet/puppetdb.conf
fi
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/50-set-certname.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

if [ -n "${PUPPETSERVER_HOSTNAME}" ]; then
/opt/puppetlabs/bin/puppet config set server "$PUPPETSERVER_HOSTNAME"
fi
Expand Down
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/55-set-masterport.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

hocon() {
/opt/puppetlabs/puppet/lib/ruby/vendor_gems/bin/hocon "$@"
}
Expand Down
5 changes: 3 additions & 2 deletions puppetserver/docker-entrypoint.d/56-set-environmentpath.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#
puppet config set --section server environmentpath $ENVIRONMENTPATH

set -e

puppet config set --section server environmentpath $ENVIRONMENTPATH
5 changes: 3 additions & 2 deletions puppetserver/docker-entrypoint.d/57-set-hiera_config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#
puppet config set --section server hiera_config $HIERACONFIG

set -e

puppet config set --section server hiera_config $HIERACONFIG
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/60-setup-autosign.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

# Configure puppet to use a certificate autosign script (if it exists)
# AUTOSIGN=true|false|path_to_autosign.conf
if test -n "${AUTOSIGN}" ; then
Expand Down
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/70-set-dns-alt-names.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

# Allow setting dns_alt_names for the compilers certificate. This
# setting will only have an effect when the container is started without
# an existing certificate on the /etc/puppetlabs/puppet volume
Expand Down
4 changes: 3 additions & 1 deletion puppetserver/docker-entrypoint.d/83-environment-cache.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
#

set -e

if [ -n "$PUPPETSERVER_ENVIRONMENT_TIMEOUT" ]; then
echo "Settings environment_timeout to ${PUPPETSERVER_ENVIRONMENT_TIMEOUT}"
puppet config set --section server environment_timeout $PUPPETSERVER_ENVIRONMENT_TIMEOUT
Expand Down
3 changes: 2 additions & 1 deletion puppetserver/docker-entrypoint.d/84-enable_graphite.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

if [[ "$PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED" == "true" ]]; then
if [[ -n "$PUPPETSERVER_GRAPHITE_HOST" && -n "$PUPPETSERVER_GRAPHITE_PORT" ]]; then
echo "Enabling graphite exporter"
Expand All @@ -9,4 +11,3 @@ if [[ "$PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED" == "true" ]]; then
exit 99
fi
fi

2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/85-setup-storeconfigs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

set -e

if [ -n "$PUPPET_STORECONFIGS_BACKEND" ]; then
puppet config set storeconfigs_backend $PUPPET_STORECONFIGS_BACKEND --section master
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
#

set -e

if [[ "$PUPPETSERVER_ENABLE_ENV_CACHE_DEL_API" == true ]]; then
if [[ $(grep 'puppet-admin-api' /etc/puppetlabs/puppetserver/conf.d/auth.conf) ]]; then
echo "Admin API already set"
Expand Down
5 changes: 2 additions & 3 deletions puppetserver/docker-entrypoint.d/89-csr_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

begin
csr_yaml = YAML.dump(JSON.load(ENV['CSR_ATTRIBUTES']))
File.open('/etc/puppetlabs/puppet/csr_attributes.yaml', 'w') do |file|
file.write(csr_yaml)
end
File.write('/etc/puppetlabs/puppet/csr_attributes.yaml', csr_yaml)
rescue => error
puts "Error on reading JSON env. Terminating"
puts "Malformed JSON: #{ENV['CSR_ATTRIBUTES']}"
p error.message
exit 99
end
5 changes: 4 additions & 1 deletion puppetserver/docker-entrypoint.d/89-csr_attributes.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash
echo $CSR_ATTRIBUTES

set -e

echo "CSR Attributes: ${CSR_ATTRIBUTES}"
/opt/puppetlabs/puppet/bin/ruby /docker-entrypoint.d/89-csr_attributes.rb
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/90-ca.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

ca_running() {
status=$(curl --silent --fail --insecure "https://${CA_HOSTNAME}:${CA_PORT:-8140}/status/v1/simple")
test "$status" = "running"
Expand Down
2 changes: 2 additions & 0 deletions puppetserver/docker-entrypoint.d/99-log-config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/sh

set -e

### Print configuration for troubleshooting
echo "System configuration values:"
# shellcheck disable=SC2039 # Docker injects $HOSTNAME
Expand Down

0 comments on commit a84fc0c

Please sign in to comment.