From 9fdaa1fca5ef3c4f9284ec4846f3d7dd6efb270f Mon Sep 17 00:00:00 2001 From: Josiah Bull Date: Tue, 25 Oct 2022 22:30:04 +1300 Subject: [PATCH] feat: added optional versioning to the install script --- install.sh | 36 +++++++++++++++++++++++++++++------ readme.md | 3 +++ riptide_agent/riptide.service | 6 +++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index e486330..99e117b 100644 --- a/install.sh +++ b/install.sh @@ -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)" @@ -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 @@ -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 diff --git a/readme.md b/readme.md index 12c5408..31be51e 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/riptide_agent/riptide.service b/riptide_agent/riptide.service index f259acd..3879baa 100644 --- a/riptide_agent/riptide.service +++ b/riptide_agent/riptide.service @@ -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 \ No newline at end of file