diff --git a/README.md b/README.md index dcddd25..cff13bd 100644 --- a/README.md +++ b/README.md @@ -129,13 +129,16 @@ To enable automatic updates, the agent must be distributed through an S3 storage Rack Manage uses Cloudflare R2 rather than AWS S3 for distribution. While `oclif` supports non-AWS S3 storage, there is some additional configuration required to use it. -First, you must set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables to the Cloudflare R2 credentials. You must also set the `AWS_S3_ENDPOINT` and `AWS_ENDPOINT_URL` environment variables to the Cloudflare R2 endpoint. +### Cloudflare R2 Configuration + +The Rack Manage Agent R2 server is configured to use the `rmagent` bucket on the `agent.rackmanage.io` domain. This domain is registered in the Rack Manage Subdomain Router and is excluded in the banned names list of the cloud functions repository. + +First, you must set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables to the Cloudflare R2 credentials. You must also set the `AWS_ENDPOINT_URL_S3` variable to the Cloudflare R2 endpoint. ```bash export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= -export AWS_S3_ENDPOINT=https://.r2.cloudflarestorage.com -export AWS_ENDPOINT_URL=https://.r2.cloudflarestorage.com +export AWS_ENDPOINT_URL_S3=https://.r2.cloudflarestorage.com ``` Once these environment variables are set, you can upload the agent to Cloudflare R2 by running the following command: @@ -154,21 +157,31 @@ oclif promote --channel --version --sha --indexes --xz Where `` is the release channel to publish to, such as `stable` or `beta`, `` is the version number, and `` is the 7 character git commit hash. -By default, this command will only publish tarballs. To publish other types of files, you must specify the type with the `-m`, or `-w` flags for deb, macos, and win files, respectively. +By default, this command will only publish tarballs. To publish other types of files, you must specify the type with the `-m`, or `-w` flags for macos, and win files, respectively. ### Debian Packages -The Debian commands `oclif upload deb` and `oclif promote -d` do not work properly (see [oclif issue #1074](https://github.com/oclif/oclif/issues/1074)) due to the improper use of `./` as the Debian distribution. +The Debian commands `oclif upload deb` and `oclif promote -d` do not work properly (see [oclif issue #1074](https://github.com/oclif/oclif/issues/1074)) due to the use of `./` as the Debian distribution, where S3 does not support folders named `.`. To work around this, you can manually upload the Debian package to Cloudflare R2 through the `aws` CLI with the following command: ```bash -aws s3 cp dist/deb s3://rmagent/channels/stable/apt --recursive +aws s3 cp dist/deb s3://rmagent/apt --recursive ``` -In order to handle the cases where Debian attempts to download the package from the `./` directory, a redirect is setup in the Rack Manage Subdomain Router to redirect requests from `https://rmagent-assets.rackmanage.io/channels/stable/apt/./` to `https://rmagent-assets.rackmanage.io/channels/stable/apt/`. +In order to handle the cases where Debian attempts to download the package from the `./` directory, a redirect is setup in the Rack Manage Subdomain Router to redirect requests from `https://agent.rackmanage.io/apt/./` to `https://agent.rackmanage.io/apt/`. Note that the apt reposity does not support release channels and only the latest version is available. + +The Debian repository also includes two additional files, `Release.key` and `install.sh` which are used to add the GPG key to the system, and automate the installation of the package. These are manually uploaded to the repository and are not generated by `oclif`. `install.sh` is located in the `scripts` directory and `Release.key` is not included in the repository. -The Debian repository also includes two additional files, `Release.key` and `install.sh` which are used to add the GPG key to the system, and automate the installation of the package. These are manually uploaded to the repository and are not generated by `oclif`. +To update `install.sh` and `Release.key`, run the following commands: + +```bash +aws s3 cp scripts/install.sh s3://rmagent/install.sh +``` + +```bash +aws s3 cp Release.key s3://rmagent/apt/Release.key +``` ## Service Management This agent is designed to run as a service in both user and system contexts (on login and on boot) for Linux, Windows, and MacOS, using systemd, launchd, and the Windows Service Manager, respectively. The service is configured to run the agent in the background and restart it if it crashes. diff --git a/package.json b/package.json index 95d22fb..6ca4dce 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "update": { "s3": { - "host": "https://rmagent-assets.rackmanage.io", + "host": "https://agent.rackmanage.io", "bucket": "rmagent", "xz": true } diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..1be4a20 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +{ + set -e + SUDO='' + if [ "$(id -u)" != "0" ]; then + SUDO='sudo' + echo "This script requires superuser access." + echo "You will be prompted for your password by sudo." + sudo -k + fi + + $SUDO sh <