diff --git a/Justfile b/Justfile index 904149c..498f65e 100644 --- a/Justfile +++ b/Justfile @@ -32,5 +32,7 @@ dist: aws s3 cp ./mailsherpa-linux-arm64.tar.gz $CLOUDFLARE_R2_BUCKET/mailsherpa-linux-arm64.tar.gz --endpoint-url $CLOUDFLARE_R2_ENDPOINT just clean + aws s3 cp ./install.py $CLOUDFLARE_R2_BUCKET/install.py --endpoint-url $CLOUDFLARE_R2_ENDPOINT + test: go test ./... diff --git a/README.md b/README.md index 1dbf84f..244c7e7 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,16 @@ This is open-source, but we also offer a hosted API that's simple to use. If you
-## Quickstart +## Installation -1. Download the appropriate CLI tarball for your OS: +If you want to use our install script, you can run the following command: + +``` +curl -sSL https://mailsherpa.sh/install.py | python3 +``` +otherwise, follow the diretions below: + +Download the appropriate CLI tarball for your OS: ``` wget mailsherpa.sh/mailsherpa-linux-arm64.tar.gz @@ -22,24 +29,27 @@ wget mailsherpa.sh/mailsherpa-linux-amd64.tar.gz wget mailsherpa.sh/mailsherpa-macos.tar.gz ``` -2. Extract the binary: +Extract the binary: ``` tar -xzf filename.tar.gz ``` -3. Set the `MAIL_SERVER_DOMAIN` environment variable. See the `Mail Server setup guide` section below for more details: +4. Test to make sure everything is working ``` -export MAIL_SERVER_DOMAIN=example.com +./mailsherpa version ``` -4. Test to make sure everything is working +## Set env variables + +Set the `MAIL_SERVER_DOMAIN` environment variable. See the `Mail Server setup guide` section below for more details: ``` -./mailsherpa version +export MAIL_SERVER_DOMAIN=example.com ``` + ## Mail Server setup guide You might be asking why you need to setup a mail server... diff --git a/install.py b/install.py new file mode 100644 index 0000000..7432b0c --- /dev/null +++ b/install.py @@ -0,0 +1,61 @@ +import os +import platform +import subprocess +import tarfile + + +def get_platform(): + system = platform.system().lower() + machine = platform.machine().lower() + + if system == 'darwin': + return 'macos' + elif system == 'linux': + if 'arm' in machine or 'aarch64' in machine: + return 'linux-arm64' + elif 'x86_64' in machine: + return 'linux-amd64' + + raise ValueError(f"Unsupported platform: {system} {machine}") + +def download_file(url): + subprocess.run(['wget', url], check=True) + +def extract_tar(filename): + with tarfile.open(filename, 'r:gz') as tar: + tar.extractall() + +def main(): + try: + # 1. Detect OS platform + platform = get_platform() + + # 2. Download the correct file + base_url = "https://mailsherpa.sh" + filename = f"mailsherpa-{platform}.tar.gz" + url = f"{base_url}/{filename}" + + print(f"Downloading {url}") + download_file(url) + + # 3. Extract the binary + print(f"Extracting {filename}") + extract_tar(filename) + + # 4. Rename the binary + original_name = f"mailsherpa-{platform}" + new_name = "mailsherpa" + print(f"Renaming {original_name} to {new_name}") + os.rename(original_name, new_name) + + # 5. Remove the tarball + print(f"Removing {filename}") + os.remove(filename) + + print("Operation completed successfully") + + except Exception as e: + print(f"An error occurred: {e}") + +if __name__ == "__main__": + main()