69265fcebb
This currently uses eval $* which doesn't correctly handle complex args e.g with complex quoting, subshells etc.. exec "$@" is the correct command to run. "$@" is special in bash and expands to "$1" "$2" "$3" etc... to pass through command line args verbatim. Also exec accepts a list of args while eval accepts a string. However fixing it may break command strings that happened to work previously. So this change deprecates bootstrap_host_exec, replacing it with bootstrap_host_only_eval and bootstrap_host_only_exec. Change-Id: I993c3354a3d9fd392fa4fa2e3b5b8ed421487a88 Closes-bug: 1718914
20 lines
504 B
Bash
Executable File
20 lines
504 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
SERVICE_NAME=$1
|
|
if [ -z "$SERVICE_NAME" ]; then
|
|
echo "Please supply a valid service name."
|
|
exit 1
|
|
fi
|
|
shift
|
|
if [ -z "$*" ]; then
|
|
echo "Please supply a valid 'command' to run as an argument."
|
|
exit 1
|
|
fi
|
|
HOSTNAME=$(/bin/hostname -s)
|
|
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
|
|
if [[ "$HOSTNAME" == "$SERVICE_NODEID" ]]; then
|
|
eval $*
|
|
else
|
|
echo "Skipping execution since this is not the bootstrap node for this service."
|
|
fi
|