Ver código fonte

Modify `sed` flag based on OS. Closes #1474.

Co-authored-by: Holden Moreland <holden@hdmoreland.com>
Kailash Nadh 1 ano atrás
pai
commit
e317f2c5ff
1 arquivos alterados com 5 adições e 4 exclusões
  1. 5 4
      install-prod.sh

+ 5 - 4
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(){