Skip to content

Install.sh fails on sed replace commands due to -i '' #32

@JayJamieson

Description

@JayJamieson

Describe the bug
Running install.sh fails on non Ubuntu with the following error

Cloning the repository...
sed: can't read s/AUTHORIZATION_TOKEN = "[^"]*"/AUTHORIZATION_TOKEN = "redacted"/: No such file or directory

Please enter your Cloudflare account_id (from 'wrangler whoami' or the Cloudflare dashboard):
redacted
sed: can't read s/^account_id = .*/account_id = "redacted"/: No such file or directory
sed: can't read s/# STUDIO_USER = "admin"/STUDIO_USER = "admin"/: No such file or directory
sed: can't read s/# STUDIO_PASS = "123456"/STUDIO_PASS = "redacted"/: No such file or directory

To Reproduce
Run curl https://starbasedb.com/install.sh | bash on non BSD system and see error output.

Expected behavior
Install script runs without error and starbasedb deployed without error on Either BSD or Linux based system.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context
I believe the fix is simple enough, perform system check for BSD or Linux based system and use appropriate command syntax.

Something to the effect of this should be robust enough to handle different environments.

OS_TYPE=$(uname -s)

case "$OS_TYPE" in
    Linux*)
        # GNU utilities
        SED_INPLACE="sed -i"
        ;;
    Darwin*)
        # BSD utilities (macOS)
        SED_INPLACE="sed -i ''"
        ;;
    *BSD*)
        # Other BSD variants (FreeBSD, OpenBSD, etc)
        SED_INPLACE="sed -i ''"
        ;;
    *)
        echo "Unknown operating system: $OS_TYPE"
        exit 1
        ;;
esac

# run as following
$SED_INPLACE 's/# STUDIO_PASS = "123456"/STUDIO_PASS = "'"$ADMIN_PASS"'"/' wrangler.toml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions