Fix various typos and styling errors in __consul_agent, conf-dir

explorer
This commit is contained in:
fnux 2020-01-26 15:13:12 +01:00
parent f595664924
commit 31ad1bdaad
2 changed files with 22 additions and 20 deletions

View file

@ -49,7 +49,7 @@ distribution_setup () {
debian) debian)
# consul is only available starting Debian 10 (buster). # consul is only available starting Debian 10 (buster).
# See https://packages.debian.org/buster/consul # See https://packages.debian.org/buster/consul
if [ $release -lt 10 ]; then if [ "$release" -lt 10 ]; then
echo "Consul is not available for your debian release." >&2 echo "Consul is not available for your debian release." >&2
echo "Please use the 'manual' (i.e. non-package) installation or \ echo "Please use the 'manual' (i.e. non-package) installation or \
upgrade the target system." >&2 upgrade the target system." >&2
@ -59,7 +59,7 @@ distribution_setup () {
# Override previously defined environment to match debian packaging. # Override previously defined environment to match debian packaging.
conf_dir='/etc/consul.d' conf_dir='/etc/consul.d'
user='consul' user='consul'
grou='consul' group='consul'
;; ;;
*) *)
echo "Your operating system ($os) is currently not supported with the \ echo "Your operating system ($os) is currently not supported with the \
@ -71,7 +71,7 @@ distribution_setup () {
esac esac
# Install consul package. # Install consul package.
__package consul --state $state __package consul --state "$state"
export config_deployment_requires="__package/consul" export config_deployment_requires="__package/consul"
} }
@ -139,7 +139,7 @@ manual_setup () {
esac esac
# Create data directory. # Create data directory.
require="__user/consul"__directory "$data_dir" \ require="__user/consul" __directory "$data_dir" \
--owner "$user" --group "$group" --mode 770 --state "$state" --owner "$user" --group "$group" --mode 770 --state "$state"
# Create config directory. # Create config directory.
@ -202,8 +202,23 @@ else
manual_setup manual_setup
fi fi
###
# Install TLS certificates.
if [ -f "$__object/parameter/ca-file-source" ] || \
[ -f "$__object/parameter/cert-file-source" ] || \
[ -f "$__object/parameter/key-file-source" ]; then
requires="$config_deployment_requires" __directory $tls_dir \
--owner root --group "$group" --mode 750 --state "$state"
# Append to service restart requirements.
restart_requires="$restart_requires __directory/$conf_dir/tls"
fi
### ###
# Generate and deploy configuration. # Generate and deploy configuration.
json_configuration=$( json_configuration=$(
echo "{" echo "{"
@ -216,8 +231,8 @@ json_configuration=$(
state|user|group|json-config|use-distribution-package) continue ;; state|user|group|json-config|use-distribution-package) continue ;;
ca-file-source|cert-file-source|key-file-source) ca-file-source|cert-file-source|key-file-source)
source="$(cat "$__object/parameter/$param")" source="$(cat "$__object/parameter/$param")"
destination="/etc/consul/ssl/${source##*/}" destination="$tls_dir/${source##*/}"
require="__directory/etc/consul/ssl" \ require="__directory/$tls_dir" \
__file "$destination" \ __file "$destination" \
--owner root --group consul --mode 640 \ --owner root --group consul --mode 640 \
--source "$source" \ --source "$source" \
@ -276,19 +291,6 @@ echo "$json_configuration" | require="$config_deployment_requires" \
# Set configuration deployment as requirement for service restart. # Set configuration deployment as requirement for service restart.
restart_requires="__file/$conf_dir/$conf_file" restart_requires="__file/$conf_dir/$conf_file"
###
# Install TLS certificates.
if [ -f "$__object/parameter/ca-file-source" ] || \
[ -f "$__object/parameter/cert-file-source" ] || \
[ -f "$__object/parameter/key-file-source" ]; then
requires="__file/$conf_dir/$conf_file" __directory $conf_dir/tls \
--owner root --group "$group" --mode 750 --state "$state"
# Append to service restart requirements.
restart_requires="$restart_requires __directory/$conf_dir/tls"
fi
### ###
# Restart consul agent after everything else. # Restart consul agent after everything else.
require="$restart_requires" __service consul --action restart require="$restart_requires" __service consul --action restart

View file

@ -2,7 +2,7 @@
check_dir () { check_dir () {
if [ -d "$1" ]; then if [ -d "$1" ]; then
echo -n "$1" printf '%s' "$1"
exit exit
fi fi
} }