Brayden / starbasedb

HTTP SQLite scale-to-zero database on the edge built on Cloudflare Durable Objects.
https://starbasedb.com
GNU Affero General Public License v3.0
644 stars 14 forks source link

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

Open JayJamieson opened 2 days ago

JayJamieson commented 2 days ago

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
Brayden commented 1 day ago

Great find. To be honest I should have tested on more OS's. I'll prioritize getting a fix for this available!