From 590f5ca16155bb4116b8f2ba948806a94c3c27d6 Mon Sep 17 00:00:00 2001 From: luis-munoz Date: Tue, 18 Feb 2020 12:53:26 -0500 Subject: [PATCH] added sed calls based on OS --- customize_fusion_values.sh | 34 +++++++++++++++++++++++++--------- install_prom.sh | 15 ++++++++++++--- setup_f5_k8s.sh | 33 +++++++++++++++++++++++++-------- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/customize_fusion_values.sh b/customize_fusion_values.sh index 3047719..8363ee2 100755 --- a/customize_fusion_values.sh +++ b/customize_fusion_values.sh @@ -133,27 +133,43 @@ if [ "${NODE_POOL}" == "" ]; then fi cp customize_fusion_values.yaml.example $MY_VALUES -sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$MY_VALUES" -sed -i'' -e "s|{SOLR_REPLICAS}|${SOLR_REPLICAS}|g" "$MY_VALUES" -sed -i'' -e "s|{RELEASE}|${RELEASE}|g" "$MY_VALUES" -sed -i'' -e "s|{PROMETHEUS}|${PROMETHEUS_ON}|g" "$MY_VALUES" -sed -i'' -e "s|{SOLR_DISK_GB}|${SOLR_DISK_GB}|g" "$MY_VALUES" - +if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$MY_VALUES" + sed -i -e "s|{SOLR_REPLICAS}|${SOLR_REPLICAS}|g" "$MY_VALUES" + sed -i -e "s|{RELEASE}|${RELEASE}|g" "$MY_VALUES" + sed -i -e "s|{PROMETHEUS}|${PROMETHEUS_ON}|g" "$MY_VALUES" + sed -i -e "s|{SOLR_DISK_GB}|${SOLR_DISK_GB}|g" "$MY_VALUES" +else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$MY_VALUES" + sed -i '' -e "s|{SOLR_REPLICAS}|${SOLR_REPLICAS}|g" "$MY_VALUES" + sed -i '' -e "s|{RELEASE}|${RELEASE}|g" "$MY_VALUES" + sed -i '' -e "s|{PROMETHEUS}|${PROMETHEUS_ON}|g" "$MY_VALUES" + sed -i '' -e "s|{SOLR_DISK_GB}|${SOLR_DISK_GB}|g" "$MY_VALUES" +fi echo -e "\nCreated Fusion custom values yaml: ${MY_VALUES}\n" if [ "$PROMETHEUS_ON" == "true" ]; then PROMETHEUS_VALUES="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_prom_values.yaml" if [ ! -f "${PROMETHEUS_VALUES}" ]; then cp example-values/prometheus-values.yaml $PROMETHEUS_VALUES - sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" - sed -i'' -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" + sed -i -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" + sed -i '' -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + fi echo -e "\nCreated Prometheus custom values yaml: ${PROMETHEUS_VALUES}\n" fi GRAFANA_VALUES="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_graf_values.yaml" if [ ! -f "${GRAFANA_VALUES}" ]; then cp example-values/grafana-values.yaml $GRAFANA_VALUES - sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + fi echo -e "\nCreated Grafana custom values yaml: ${GRAFANA_VALUES}\n" fi fi diff --git a/install_prom.sh b/install_prom.sh index 644bf21..de88301 100755 --- a/install_prom.sh +++ b/install_prom.sh @@ -115,15 +115,24 @@ fi PROMETHEUS_VALUES="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_prom_values.yaml" if [ ! -f "${PROMETHEUS_VALUES}" ]; then cp example-values/prometheus-values.yaml $PROMETHEUS_VALUES - sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" - sed -i'' -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" + sed -i -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" + sed -i '' -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + fi echo -e "\nCreated Prometheus custom values yaml: ${PROMETHEUS_VALUES}. Keep this file handy as you'll need it to customize your Prometheus installation.\n" fi GRAFANA_VALUES="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_graf_values.yaml" if [ ! -f "${GRAFANA_VALUES}" ]; then cp example-values/grafana-values.yaml $GRAFANA_VALUES - sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + fi echo -e "\nCreated Grafana custom values yaml: ${GRAFANA_VALUES}. Keep this file handy as you'll need it to customize your Grafana installation.\n" fi diff --git a/setup_f5_k8s.sh b/setup_f5_k8s.sh index e112fca..148c035 100755 --- a/setup_f5_k8s.sh +++ b/setup_f5_k8s.sh @@ -417,15 +417,24 @@ if [ "$UPGRADE" != "1" ] && [ "${PROMETHEUS}" != "none" ]; then PROMETHEUS_VALUES="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_prom_values.yaml" if [ ! -f "${PROMETHEUS_VALUES}" ]; then cp example-values/prometheus-values.yaml $PROMETHEUS_VALUES - sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" - sed -i'' -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" + sed -i -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$PROMETHEUS_VALUES" + sed -i '' -e "s|{NAMESPACE}|${NAMESPACE}|g" "$PROMETHEUS_VALUES" + fi echo -e "\nCreated Prometheus custom values yaml: ${PROMETHEUS_VALUES}. Keep this file handy as you'll need it to customize your Prometheus installation.\n" fi GRAFANA_VALUES="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_graf_values.yaml" if [ ! -f "${GRAFANA_VALUES}" ]; then cp example-values/grafana-values.yaml $GRAFANA_VALUES - sed -i'' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + else + sed -i '' -e "s|{NODE_POOL}|${NODE_POOL}|g" "$GRAFANA_VALUES" + fi echo -e "\nCreated Grafana custom values yaml: ${GRAFANA_VALUES}. Keep this file handy as you'll need it to customize your Grafana installation.\n" fi @@ -514,9 +523,17 @@ kubectl config set-context --current --namespace=${NAMESPACE} UPGRADE_SCRIPT="${PROVIDER}_${CLUSTER_NAME}_${RELEASE}_upgrade_fusion.sh" cp upgrade_fusion.sh.example $UPGRADE_SCRIPT -sed -i'' -e "s||${PROVIDER}|g" "$UPGRADE_SCRIPT" -sed -i'' -e "s||${CLUSTER_NAME}|g" "$UPGRADE_SCRIPT" -sed -i'' -e "s||${RELEASE}|g" "$UPGRADE_SCRIPT" -sed -i'' -e "s||${NAMESPACE}|g" "$UPGRADE_SCRIPT" -sed -i'' -e "s||${CHART_VERSION}|g" "$UPGRADE_SCRIPT" +if [[ "$OSTYPE" == "linux-gnu" ]]; then + sed -i -e "s||${PROVIDER}|g" "$UPGRADE_SCRIPT" + sed -i -e "s||${CLUSTER_NAME}|g" "$UPGRADE_SCRIPT" + sed -i -e "s||${RELEASE}|g" "$UPGRADE_SCRIPT" + sed -i -e "s||${NAMESPACE}|g" "$UPGRADE_SCRIPT" + sed -i -e "s||${CHART_VERSION}|g" "$UPGRADE_SCRIPT" +else + sed -i '' -e "s||${PROVIDER}|g" "$UPGRADE_SCRIPT" + sed -i '' -e "s||${CLUSTER_NAME}|g" "$UPGRADE_SCRIPT" + sed -i '' -e "s||${RELEASE}|g" "$UPGRADE_SCRIPT" + sed -i '' -e "s||${NAMESPACE}|g" "$UPGRADE_SCRIPT" + sed -i '' -e "s||${CHART_VERSION}|g" "$UPGRADE_SCRIPT" +fi echo -e "\nCreating $UPGRADE_SCRIPT for upgrading you Fusion cluster. Please keep this script along with your custom values yaml file(s) in version control.\n"