diff --git a/jellyseerr.sh b/jellyseerr.sh index c01f662..a605eef 100755 --- a/jellyseerr.sh +++ b/jellyseerr.sh @@ -6,11 +6,20 @@ mkdir -p $HOME/.logs/ touch $HOME/.logs/jellyseerr.log export log="$HOME/.logs/jellyseerr.log" +function github_latest_version() { + # Function by Liara + # Argument expects the author/repo format + # e.g. swizzin/swizzin + repo=$1 + curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/${repo}/releases/latest | grep -o '[^/]*$' +} + function _deps() { ## Function for installing nvm. if [[ ! -d "$HOME/.nvm" ]]; then echo "Installing node" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash >> "$log" 2>&1 + nvmVersion=$(github_latest_version "nvm-sh/nvm") + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${nvmVersion}/install.sh | bash >> "$log" 2>&1 echo "nvm installed." else echo "nvm is already installed." diff --git a/lounge.sh b/lounge.sh index 2f9b0d3..1ef48bd 100755 --- a/lounge.sh +++ b/lounge.sh @@ -5,11 +5,20 @@ mkdir -p $HOME/.logs/ touch "$HOME/.logs/lounge.log" log="$HOME/.logs/lounge.log" +function github_latest_version() { + # Function by Liara + # Argument expects the author/repo format + # e.g. swizzin/swizzin + repo=$1 + curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/${repo}/releases/latest | grep -o '[^/]*$' +} + function _deps() { ## Function for installing nvm. if [[ ! -d $HOME/.nvm ]]; then echo "Installing node" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash >> "$log" 2>&1 + nvmVersion=$(github_latest_version "nvm-sh/nvm") + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${nvmVersion}/install.sh | bash >> "$log" 2>&1 echo "nvm installed." else echo "nvm is already installed." diff --git a/race-ready.sh b/race-ready.sh index 162e1e6..5e1fa1f 100755 --- a/race-ready.sh +++ b/race-ready.sh @@ -19,7 +19,8 @@ function _nvm() { ## Function for installing nvm. if [[ ! -d /home/$user/.nvm ]]; then echo "Installing node" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash >> "$log" 2>&1 + nvmVersion=$(github_latest_version "nvm-sh/nvm") + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${nvmVersion}/install.sh | bash >> "$log" 2>&1 echo "nvm installed." else echo "nvm is already installed."