From e317f2c5ff100237b4881d6518dfbe8ed98b2435 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 27 Aug 2023 13:32:57 +0530 Subject: [PATCH] Modify `sed` flag based on OS. Closes #1474. Co-authored-by: Holden Moreland --- install-prod.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 install-prod.sh diff --git a/install-prod.sh b/install-prod.sh old mode 100644 new mode 100755 index 0a37dae17..c5ec52e26 --- a/install-prod.sh +++ b/install-prod.sh @@ -10,6 +10,7 @@ RED="$(tput setaf 1 2>/dev/null || printf '')" BLUE="$(tput setaf 4 2>/dev/null || printf '')" GREEN="$(tput setaf 2 2>/dev/null || printf '')" NO_COLOR="$(tput sgr0 2>/dev/null || printf '')" +SED_INPLACE=$(if [[ "$(uname)" == "Darwin" ]]; then echo "-i ''"; else echo "-i"; fi) info() { printf '%s\n' "${BLUE}> ${NO_COLOR} $*" @@ -96,15 +97,15 @@ modify_config(){ info "modifying config.toml" # Replace `db.host=localhost` with `db.host=db` in config file. - sed -i "s/host = \"localhost\"/host = \"listmonk_db\"/g" config.toml + sed $SED_INPLACE "s/host = \"localhost\"/host = \"listmonk_db\"/g" config.toml # Replace `db.password=listmonk` with `db.password={{db_password}}` in config file. # Note that `password` is wrapped with `\b`. This ensures that `admin_password` doesn't match this pattern instead. - sed -i "s/\bpassword\b = \"listmonk\"/password = \"$db_password\"/g" config.toml + sed $SED_INPLACE "s/\bpassword\b = \"listmonk\"/password = \"$db_password\"/g" config.toml # Replace `app.address=localhost:9000` with `app.address=0.0.0.0:9000` in config file. - sed -i "s/address = \"localhost:9000\"/address = \"0.0.0.0:9000\"/g" config.toml + sed $SED_INPLACE "s/address = \"localhost:9000\"/address = \"0.0.0.0:9000\"/g" config.toml info "modifying docker-compose.yml" - sed -i "s/POSTGRES_PASSWORD=listmonk/POSTGRES_PASSWORD=$db_password/g" docker-compose.yml + sed $SED_INPLACE "s/POSTGRES_PASSWORD=listmonk/POSTGRES_PASSWORD=$db_password/g" docker-compose.yml } run_migrations(){