Skip to content

Commit

Permalink
Use # as separator for sed s command (openshift#198)
Browse files Browse the repository at this point in the history
base64 output can contain `/` which breaks sed as it considers `/` to be
end of command.

Also remove remnants of SSH key substitution in templates.
  • Loading branch information
YorikSar authored and flaper87 committed Jan 28, 2019
1 parent 4042ccb commit 9cb428a
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions cmd/clusterctl/examples/openstack/generate-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ PROVIDERCOMPONENT_GENERATED_FILE=${OUTPUT_DIR}/provider-components.yaml
MASTER_USER_DATA_FILE=${TEMPLATES_PATH}/master-user-data.sh
WORKER_USER_DATA_FILE=${TEMPLATES_PATH}/worker-user-data.sh

MACHINE_CONTROLLER_SSH_PUBLIC_FILE=openstack_tmp.pub
MACHINE_CONTROLLER_SSH_PUBLIC=
MACHINE_CONTROLLER_SSH_PRIVATE_FILE=openstack_tmp
MACHINE_CONTROLLER_SSH_PRIVATE=
MACHINE_CONTROLLER_SSH_HOME=${HOME}/.ssh/

CONTROLLER_IMAGE_VERSION="0.0.0-alpha.4"
Expand Down Expand Up @@ -213,19 +210,19 @@ if [[ "$OS" =~ "Linux" ]]; then
OPENSTACK_CLOUD_CONFIG=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN"|base64 -w0)
OPENSTACK_CLOUD_PROVIDER_CONF=$(echo "$OPENSTACK_CLOUD_PROVIDER_CONF_PLAIN"|base64 -w0)
MASTER_USER_DATA=$(echo "$MASTER_USER_DATA_PLAIN" \
| sed -e "s/\$OPENSTACK_CLOUD_PROVIDER_CONF/$OPENSTACK_CLOUD_PROVIDER_CONF/" \
| sed -e "s#\$OPENSTACK_CLOUD_PROVIDER_CONF#$OPENSTACK_CLOUD_PROVIDER_CONF#" \
| base64 -w0)
WORKER_USER_DATA=$(echo "$WORKER_USER_DATA_PLAIN" \
| sed -e "s/\$OPENSTACK_CLOUD_PROVIDER_CONF/$OPENSTACK_CLOUD_PROVIDER_CONF/" \
| sed -e "s#\$OPENSTACK_CLOUD_PROVIDER_CONF#$OPENSTACK_CLOUD_PROVIDER_CONF#" \
| base64 -w0)
elif [[ "$OS" =~ "Darwin" ]]; then
OPENSTACK_CLOUD_CONFIG=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN"|base64)
OPENSTACK_CLOUD_PROVIDER_CONF=$(echo "$OPENSTACK_CLOUD_PROVIDER_CONF_PLAIN"|base64)
MASTER_USER_DATA=$(echo "$MASTER_USER_DATA_PLAIN" \
| sed -e "s/\$OPENSTACK_CLOUD_PROVIDER_CONF/$OPENSTACK_CLOUD_PROVIDER_CONF/" \
| sed -e "s#\$OPENSTACK_CLOUD_PROVIDER_CONF#$OPENSTACK_CLOUD_PROVIDER_CONF#" \
| base64)
WORKER_USER_DATA=$(echo "$WORKER_USER_DATA_PLAIN" \
| sed -e "s/\$OPENSTACK_CLOUD_PROVIDER_CONF/$OPENSTACK_CLOUD_PROVIDER_CONF/" \
| sed -e "s#\$OPENSTACK_CLOUD_PROVIDER_CONF#$OPENSTACK_CLOUD_PROVIDER_CONF#" \
| base64)
else
echo "Unrecognized OS : $OS"
Expand Down Expand Up @@ -265,12 +262,9 @@ do
done

cat "$PROVIDERCOMPONENT_TEMPLATE_FILE" \
| sed -e "s/\$OPENSTACK_CLOUD_CONFIG/$OPENSTACK_CLOUD_CONFIG/" \
| sed -e "s/\$MACHINE_CONTROLLER_SSH_USER/$MACHINE_CONTROLLER_SSH_USER/" \
| sed -e "s/\$MACHINE_CONTROLLER_SSH_PUBLIC/$MACHINE_CONTROLLER_SSH_PUBLIC/" \
| sed -e "s/\$MACHINE_CONTROLLER_SSH_PRIVATE/$MACHINE_CONTROLLER_SSH_PRIVATE/" \
| sed -e "s/\$MASTER_USER_DATA/$MASTER_USER_DATA/" \
| sed -e "s/\$WORKER_USER_DATA/$WORKER_USER_DATA/" \
| sed -e "s#\$OPENSTACK_CLOUD_CONFIG#$OPENSTACK_CLOUD_CONFIG#" \
| sed -e "s#\$MASTER_USER_DATA#$MASTER_USER_DATA#" \
| sed -e "s#\$WORKER_USER_DATA#$WORKER_USER_DATA#" \
>> "$PROVIDERCOMPONENT_GENERATED_FILE"

if [[ "$OS" =~ "Linux" ]]; then
Expand Down

0 comments on commit 9cb428a

Please sign in to comment.