Skip to content

Commit

Permalink
feat: added optional versioning to the install script
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahBull committed Oct 25, 2022
1 parent b81eeec commit 9fdaa1f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
36 changes: 30 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash

VERSION=v1.0.0-rc
# if VERSION is set in environment, use that
if [ -n "$VERSION" ]; then
echo "Using VERSION from environment: $VERSION"
else
VERSION=$(curl -s https://api.github.com/repos/riptide-org/client/releases/latest | grep tag_name | cut -d '"' -f 4)
fi

# store current directory
DIR="$(pwd)"
Expand All @@ -9,18 +15,34 @@ DIR="$(pwd)"
mkdir -p /tmp/riptide-install-dir
cd /tmp/riptide-install-dir

# check if dnf command exists
if command -v dnf &> /dev/null
then
sudo dnf install -y curl openssl openssl-devel openssl1.1
echo "dnf complete"
# check if apt command exists
elif command -v apt &> /dev/null
then
sudo apt install -y curl openssl libssl-dev
echo "apt complete"
else
echo "Could not install packages no package manager found"
exit 1
fi

# download latest release from repo
curl -L https://github.com/riptide-org/client/releases/download/$VERSION/agent --output agent
curl -L https://github.com/riptide-org/client/releases/download/$VERSION/cli --output cli
curl -L https://github.com/riptide-org/client/releases/download/$VERSION/riptide.service --output cli
curl -sL https://github.com/riptide-org/client/releases/download/$VERSION/agent --output agent
curl -sL https://github.com/riptide-org/client/releases/download/$VERSION/cli --output cli
curl -sL https://github.com/riptide-org/client/releases/download/$VERSION/riptide.service --output riptide.service

# download the completion scripts for bash and zsh
curl -L https://github.com/riptide-org/client/releases/download/$VERSION/riptide.bash --output riptide.bash
curl -L https://github.com/riptide-org/client/releases/download/$VERSION/riptide.zsh --output riptide.zsh
curl -sL https://github.com/riptide-org/client/releases/download/$VERSION/riptide.bash --output riptide.bash
curl -sL https://github.com/riptide-org/client/releases/download/$VERSION/riptide.zsh --output riptide.zsh

# make folders for systemd
mkdir -p $HOME/.config/systemd/user
mkdir -p $HOME/.config/riptide
mkdir -p $HOME/.local/bin/

# move the service file to the user systemd directory
mv riptide.service $HOME/.config/systemd/user/riptide.service
Expand All @@ -29,7 +51,9 @@ mv riptide.service $HOME/.config/systemd/user/riptide.service
sed -i "s/\$USER/$USER/g" $HOME/.config/systemd/user/riptide.service

# replace any $HOME in the service file with the current user's home directory
sed -i "s/\$HOME/$HOME/g" $HOME/.config/systemd/user/riptide.service
# making sure to escape the / in the path
NEW_HOME=$(echo $HOME | sed 's/\//\\\//g')
sed -i "s/\$HOME/$NEW_HOME/g" $HOME/.config/systemd/user/riptide.service

# move binary to the user installation (no sudo required)
mv cli $HOME/.local/bin/riptide
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Installation can be done via a simple bash script.

```bash
curl https://raw.githubusercontent.com/riptide-org/client/main/install.sh | bash

# or if you want a specific version
curl https://raw.githubusercontent.com/riptide-org/client/main/install.sh | VERSION=v1.0.0-rc bash
```

## Development
Expand Down
6 changes: 3 additions & 3 deletions riptide_agent/riptide.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ After=syslog.target network.target remote-fs.target nss-lookup.target
Type=simple
WorkingDirectory=$HOME/.config/riptide

User=$USER
Group=$USER

ExecStart=$HOME/.local/bin/riptide-agent
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
RestartSec=30s

[Install]
WantedBy=default.target

0 comments on commit 9fdaa1f

Please sign in to comment.