diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2017-07-29 00:34:31 +0200 |
---|---|---|
committer | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2017-07-31 18:20:22 +0200 |
commit | 9dfd08262dd3cf833c84cd1c7c1b05c25e09862b (patch) | |
tree | b707c7e9e345b02a73b54d57e5d1e9ed77f218bd /mcp/scripts/create-config-drive.sh | |
parent | 9677c5ad3c9b94e432c2b1bf0de1a1103d5bd1a2 (diff) |
mcp/scripts: shellcheck cleanup
Change-Id: I280d540b461341e14de654186016248eba4d3521
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'mcp/scripts/create-config-drive.sh')
-rwxr-xr-x | mcp/scripts/create-config-drive.sh | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/mcp/scripts/create-config-drive.sh b/mcp/scripts/create-config-drive.sh index df3f72f1f..0943914ab 100755 --- a/mcp/scripts/create-config-drive.sh +++ b/mcp/scripts/create-config-drive.sh @@ -11,9 +11,10 @@ usage () { ARGS=$(getopt \ -o k:u:v:h: \ - --long help,hostname:,ssh-key:,user-data:,vendor-data: -n ${0##*/} \ + --long help,hostname:,ssh-key:,user-data:,vendor-data: -n "${0##*/}" \ -- "$@") +# shellcheck disable=SC2181 if [ $? -ne 0 ]; then usage >&2 exit 2 @@ -52,51 +53,51 @@ done config_image=$1 shift -if [ "$ssh_key" ] && [ -f "$ssh_key" ]; then - echo "adding pubkey from $ssh_key" - ssh_key_data=$(cat "$ssh_key") +if [ "${ssh_key}" ] && [ -f "${ssh_key}" ]; then + echo "adding pubkey from ${ssh_key}" + ssh_key_data=$(cat "${ssh_key}") fi uuid=$(uuidgen) -if ! [ "$hostname" ]; then - hostname="$uuid" +if ! [ "${hostname}" ]; then + hostname="${uuid}" fi trap 'rm -rf $config_dir' EXIT config_dir=$(mktemp -t -d configXXXXXX) -if [ "$user_data" ] && [ -f "$user_data" ]; then - echo "adding user data from $user_data" - cp ${user_data} ${config_dir}/user-data +if [ "${user_data}" ] && [ -f "${user_data}" ]; then + echo "adding user data from ${user_data}" + cp "${user_data}" "${config_dir}/user-data" else - touch $config_dir/user-data + touch "${config_dir}/user-data" fi -if [ "$vendor_data" ] && [ -f "$vendor_data" ]; then - echo "adding vendor data from $vendor_data" - cp ${vendor_data} ${config_dir}/vendor-data +if [ "${vendor_data}" ] && [ -f "${vendor_data}" ]; then + echo "adding vendor data from ${vendor_data}" + cp "${vendor_data}" "${config_dir}/vendor-data" fi -cat > $config_dir/meta-data <<-EOF -instance-id: $uuid -hostname: $hostname -local-hostname: $hostname +cat > "${config_dir}/meta-data" <<-EOF +instance-id: ${uuid} +hostname: ${hostname} +local-hostname: ${hostname} EOF -if [ "$ssh_key_data" ]; then - cat >> $config_dir/meta-data <<-EOF +if [ "${ssh_key_data}" ]; then + cat >> "${config_dir}/meta-data" <<-EOF public-keys: - | - $ssh_key_data + ${ssh_key_data} EOF fi #PS1="debug> " bash --norc -echo "generating configuration image at $config_image" -if ! mkisofs -o $config_image -V cidata -r -J --quiet $config_dir; then - echo "ERROR: failed to create $config_image" >&2 +echo "generating configuration image at ${config_image}" +if ! mkisofs -o "${config_image}" -V cidata -r -J --quiet "${config_dir}"; then + echo "ERROR: failed to create ${config_image}" >&2 exit 1 fi -chmod a+r $config_image +chmod a+r "${config_image}" |