Skip to content

Commit

Permalink
Update README add curl install script (#87)
Browse files Browse the repository at this point in the history
* Update README
* Add install script to repo
* Do not segfault when run with no subcommand

---------

Co-authored-by: endline <[email protected]>
  • Loading branch information
endline and endline authored Feb 27, 2024
1 parent 52b0f3d commit 791a708
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 124 deletions.
129 changes: 11 additions & 118 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,104 +3,20 @@
Run your own node.

## Installation
### Latest release

Download from the [releases page](https://github.com/AudiusProject/audius-d/releases), **OR** run the following:

```bash
curl -L "https://github.com/AudiusProject/audius-d/releases/latest/download/audius-ctl-$(uname -m)" -o ~/.local/bin/audius-ctl && chmod +x ~/.local/bin/audius-ctl
```

### From build

```bash
make

make install # installs to ~/.local/bin/

## OR ##

sudo make install # installs to /usr/local/bin/
```

### Uninstall

```bash
sudo make uninstall
```

#### Build macos version with statusbar feature (Experimental)

```bash
make audius-ctl-arm-mac
```

## Quickstart

### Run a local devnet

Run Audius nodes and chains in a sandbox on your local machine.

Devnet uses a local nginx container on 80/443 to act as a layer 7 load balancer. Hence we need to add the hosts so we may intelligently route on localhost.
```
sudo sh -c 'echo "127.0.0.1 creator-1.devnet.audius-d discovery-1.devnet.audius-d identity.devnet.audius-d eth-ganache.devnet.audius-d acdc-ganache.devnet.audius-d solana-test-validator.devnet.audius-d" >> /etc/hosts'
```

Instruct audius-ctl what services to create and how to configure them. More on this concept below.
```
audius-ctl config create-context devnet -f configs/templates/devnet.yaml
```

Install the devnet certificate to avoid https warnings when connecting to local nodes
```
# MacOS
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain deployments/tls/devnet-cert.pem
# Ubuntu
sudo cp deployments/tls/devnet-cert.pem /usr/local/share/ca-certificates/devnet.audius-d.crt
sudo update-ca-certificates
```

Stand up audius nodes
```
audius-ctl up
```

Test context to verify it is all working.
```
audius-ctl status
...
https://creator-1.audius-d [ /health_check .data.healthy ] true
https://discovery-1.audius-d [ /health_check .data.discovery_provider_healthy ] true
https://identity.audius-d [ /health_check .healthy ] true
```

## Run

### Run installed binary

```bash
audius-ctl help
curl -sSL https://install.audius.org | sh
```

### Run built binary (without installation)

From git project directory:
#### Uninstall

```bash
# automatically builds and runs the correct binary for your system
./audius-ctl help

## OR ##

# Manually select binary after running `make`
bin/audius-ctl-x86_64 help # linux
bin/audius-ctl-arm64 help # mac
rm -f $(which audius-ctl)
```

## Usage
## Run a Node

### Create a content node
#### Content Node

On your local computer

Expand Down Expand Up @@ -135,39 +51,16 @@ Tear down the node
audius-ctl down my.domain.example.com
```

### Switch between contexts

Contexts are modeled after `kubectl`. See:

```bash
audius-ctl config --help
```

Switch contexts

```bash
audius-ctl config use-context my-existing-context
```

Create new contexts

```bash
audius-ctl config create-context my-new-sandbox-context -f configs/templates/devnet.toml
```

Use contexts to experiment with different setups without clobbering changes.

### Migrate from audius-docker-compose to audius-d
## Migrate from audius-docker-compose

Already running audius via [audius-docker-compose](https://github.com/AudiusProject/audius-docker-compose)?
Use the below to create an audius-ctl [context](./docs/development.md#contexts) based on your audius-docker-compose environment configuration.

```bash
audius-ctl config migrate-context my-new-migrated-context path/to/audius-docker-compose
audius-ctl config migrate-context default path/to/audius-docker-compose
```

## Releases
## Contributing

1. Commit (and ideally push, review, land) changes
1. Ensure you are authenticated with the github cli (`gh auth status || gh auth login`)
1. Run `make release-audius-ctl`
1. Check the [releases page](https://github.com/AudiusProject/audius-d/releases)
- [Development](./docs/development.md)
- [Releases](./docs/releases.md)
12 changes: 6 additions & 6 deletions cmd/audius-ctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ var (
)

func main() {
rootCmd := &cobra.Command{
var rootCmd = &cobra.Command{
Use: "audius-ctl [command]",
Short: "CLI for provisioning and interacting with audius nodes",
RunE: func(cmd *cobra.Command, args []string) error {
Run: func(cmd *cobra.Command, args []string) {
if displayVersion {
logger.Out(Version)
} else {
upCmd.RunE(cmd, args)
return
}
return nil
cmd.Help()
},
}
rootCmd.Flags().BoolVar(&displayVersion, "version", false, "Display version info")

rootCmd.Flags().BoolVarP(&displayVersion, "version", "v", false, "Display version info")
rootCmd.AddCommand(configCmd, devnetCmd, downCmd, registerCmd, sbCmd, testCmd, upCmd)

if err := rootCmd.Execute(); err != nil {
Expand Down
61 changes: 61 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

# Development

Run Audius nodes and chains in a sandbox on your local machine.

### Contexts

Use contexts to experiment with different setups without clobbering changes.
Contexts are modeled after `kubectl`. See:

```bash
audius-ctl config --help
```

Switch contexts

```bash
audius-ctl config use-context my-existing-context
```

Create new contexts

```bash
audius-ctl config create-context devnet -f ./configs/templates/devnet.yaml
```

### Devnet

Devnet uses a local nginx container on 80/443 to act as a layer 7 load balancer. Hence we need to add the hosts so we may intelligently route on localhost.
```
sudo sh -c 'echo "127.0.0.1 creator-1.devnet.audius-d discovery-1.devnet.audius-d identity.devnet.audius-d eth-ganache.devnet.audius-d acdc-ganache.devnet.audius-d solana-test-validator.devnet.audius-d" >> /etc/hosts'
```

Instruct audius-ctl what services to create and how to configure them. More on this concept below.
```
audius-ctl config create-context devnet -f configs/templates/devnet.yaml
```

Install the devnet certificate to avoid https warnings when connecting to local nodes
```
# MacOS
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain deployments/tls/devnet-cert.pem
# Ubuntu
sudo cp deployments/tls/devnet-cert.pem /usr/local/share/ca-certificates/devnet.audius-d.crt
sudo update-ca-certificates
```

Stand up audius nodes
```
audius-ctl up
```

Test context to verify it is all working.
```
audius-ctl status
...
https://creator-1.audius-d [ /health_check .data.healthy ] true
https://discovery-1.audius-d [ /health_check .data.discovery_provider_healthy ] true
https://identity.audius-d [ /health_check .healthy ] true
```
6 changes: 6 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Releases

1. Commit (and ideally push, review, land) changes
1. Ensure you are authenticated with the github cli (`gh auth status || gh auth login`)
1. Run `make release-audius-ctl`
1. Check the [releases page](https://github.com/AudiusProject/audius-d/releases)
47 changes: 47 additions & 0 deletions install.audius.org.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

# This script is intended to be invoked via
# curl -sSL https://install.audius.org | sh

set -e

# Determine architecture
ARCH=$(uname -m)
BINARY_NAME="audius-ctl-${ARCH}"
BINARY_URL="https://github.com/AudiusProject/audius-d/releases/latest/download/${BINARY_NAME}"

# Try to determine the target directory
if [ -w /usr/local/bin ]; then
TARGET_DIR="/usr/local/bin"
elif echo "$PATH" | grep -q "$HOME/.local/bin"; then
TARGET_DIR="$HOME/.local/bin"
elif echo "$PATH" | grep -q "$HOME/bin"; then
TARGET_DIR="$HOME/bin"
else
echo 'Insufficient permissions and/or no suitable directory found in $PATH.'
echo 'Please manually add $HOME/.local/bin or $HOME/bin to your $PATH, then rerun this script.'
exit 1
fi

# Create target directory if it doesn't exist
if [ ! -d "$TARGET_DIR" ]; then
echo "Creating directory $TARGET_DIR"
mkdir -p "$TARGET_DIR"
fi

# Download the binary
echo "Downloading ${BINARY_NAME} to ${TARGET_DIR}"
curl -sSL "$BINARY_URL" -o "${TARGET_DIR}/audius-ctl"
chmod +x "${TARGET_DIR}/audius-ctl"

echo "${BINARY_NAME} has been installed to ${TARGET_DIR}/audius-ctl"
echo "You can run it using: audius-ctl"

# Inform user about PATH addition if necessary
if ! echo ":$PATH:" | grep -q ":$TARGET_DIR:" ; then
echo "To use audius-ctl from any location, add ${TARGET_DIR} to your PATH."
echo "For bash users, add this line to your ~/.bash_profile or ~/.bashrc:"
echo "export PATH=\"\$PATH:${TARGET_DIR}\""
echo "For zsh users, add the line to your ~/.zshrc instead."
echo "After adding the line, restart your terminal or run 'source <file>' on the modified file to update your current session."
fi

0 comments on commit 791a708

Please sign in to comment.