Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: box upgrade --all #724

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 23 additions & 2 deletions scripts/box
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,30 @@ We URGE you to migrate to a supported release if/while you still have the chance

function _upgrade() {
arg=("$@")
packages=("${arg[@]:1}")
if [[ "${arg[*]}" == *--all* ]]; then
package_string="$(find /install -type f -name '.*.lock' | awk -F. '{print $2}')"
blacklist=("rtorrent" "qbittorrent" "deluge" "libtorrent" "panel" "transmission" "curl" "nginx")
for blocker in "${blacklist[@]}"; do
package_string="$(echo "$package_string" | sed "/$blocker/d")"
done
echo_info "Upgrading all packages, EXCEPT torrent clients and packages with alternative upgrade methods (apt/built-in)\nAttempting packages: '${package_string//$'\n'/, }'"
readarray -t packages < <(echo "$package_string")
else
packages=("${arg[@]:1}")
fi

repo=($(find /usr/local/bin/swizzin/upgrade -type f -printf "%f\n" | cut -d "." -f 1))
for i in "${packages[@]}"; do
app=${i}
flying-sausages marked this conversation as resolved.
Show resolved Hide resolved
if [[ "${repo[*]}" =~ $i ]]; then
bash /usr/local/bin/swizzin/upgrade/"$i".sh || exit 1
else
echo_warn "Upgrade script for $i does not exist"
if [ -f /usr/local/bin/swizzin/install/"$i".sh ]; then
echo_warn "Please upgrade $i via its suggested upgrade method."
echo_docs "applications/$i"
else
echo_error "Upgrade script for $i does not exist"
fi
fi
done
}
Expand Down Expand Up @@ -428,6 +444,11 @@ function _deluser() {

function _chpasswd() {
user="$2"
if ! id "$user"; then
echo_error "User $user does not exist."
exit 1
fi

[[ -n $3 ]] && pass="$3"
. /etc/swizzin/sources/functions/utils
password_check
Expand Down
5 changes: 3 additions & 2 deletions scripts/upgrade/airsonic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ if [[ ! -f /install/.airsonic.lock ]]; then
echo_error "Airsonic not installed"
exit 1
fi

current_v="$(unzip -p /opt/airsonic/airsonic.war META-INF/MANIFEST.MF | grep -i Implementation-Version | cut -d' ' -f 2)"
release_v="$(curl -s https://api.github.com/repos/airsonic/airsonic/releases/latest | jq -r .'tag_name')"
echo_info "Installed = $current_v\nAvailable = $release_v"
if ! ask "Upgrade Airsonic package?"; then
echo_info "Airsonic versions:\n\tInstalled = $current_v\n\tAvailable = $release_v"
if ! ask "Install Airsonic $release_v?"; then
exit 0
fi

Expand Down
5 changes: 5 additions & 0 deletions scripts/upgrade/autodl.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

if [[ ! -f /install/.autodl.lock ]]; then
echo_error "Autodl not installed"
exit 1
fi

#shellcheck source=sources/functions/utils
. /etc/swizzin/sources/functions/utils
readarray -t users < <(_get_user_list)
Expand Down
5 changes: 5 additions & 0 deletions scripts/upgrade/emby.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
# Simple tool to grab the latest release of emby

if [[ ! -f /install/.emby.lock ]]; then
echo_error "Emby not installed"
exit 1
fi

current=$(curl -L -s -H 'Accept: application/json' https://github.com/MediaBrowser/Emby.Releases/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
cd /tmp
wget -q -O emby.dpkg https://github.com/MediaBrowser/Emby.Releases/releases/download/${current}/emby-server-deb_${current}_amd64.deb
Expand Down
5 changes: 5 additions & 0 deletions scripts/upgrade/flood.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

users=($(cut -d: -f1 < /etc/htpasswd))

if [ ! -f /install/.flood.lock ]; then
echo_warn "Flood is not installed"
exit 0
fi

if [[ ! $(which node-gyp) ]]; then
npm install -g node-gyp >> $log 2>&1
fi
Expand Down
28 changes: 15 additions & 13 deletions scripts/upgrade/lounge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ if [[ ! -f /install/.lounge.lock ]]; then
exit 1
fi

if [[ $(systemctl is-active lounge) == "active" ]]; then
wasActive="true"
echo_progress_start "Shutting down lounge"
systemctl stop lounge
echo_progress_done
fi
if ! npm outdated --global thelounge >> $log 2>&1; then # `npm outdated <package>` returns 0 if package is up to date, and 1 if an update is available
echo_progress_start "Shutting down and upgrading lounge"
if [[ $(systemctl is-active lounge) == "active" ]]; then
wasActive="true"
systemctl stop lounge
fi

if ! npm update -g thelounge >> "$log"; then
echo_error "Lounge failed to update, please investigate the logs"
fi
if ! npm update -g thelounge >> "$log"; then
echo_error "Lounge failed to update, please investigate the logs"
fi

if [[ $wasActive = "true" ]]; then
echo_progress_start "Restarting lounge"
systemctl start lounge
echo_progress_done
if [[ $wasActive = "true" ]]; then
systemctl start lounge
fi
echo_progress_done "Lounge upgraded and restarted"
else
echo_info "Lounge is up to date"
fi
2 changes: 1 addition & 1 deletion scripts/upgrade/mango.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# flying_sausages for swizzin 2020

if [[ ! -f /install/.mango.lock ]]; then
echo_error "Mango not installed "
echo_error "Mango not installed"
exit 1
fi

Expand Down
5 changes: 5 additions & 0 deletions scripts/upgrade/nzbhydra.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if [[ ! -f /install/.nzbhydra.lock ]]; then
echo_error "nzbhydra not installed"
exit 1
fi

. /etc/swizzin/sources/functions/utils
active=$(systemctl is-active nzbhydra)
username=$(_get_master_username)
Expand Down
12 changes: 8 additions & 4 deletions scripts/upgrade/sonarr.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/bin/bash

if [[ ! -f /install/.sonarrold.lock ]]; then
echo_error "Sonarr v2 not detected. Exiting!"
if [[ -f /install/.sonarrold.lock ]]; then
box install sonarr
else
if [[ -f /install/sonarr.lock ]]; then
echo_warn "Please upgrade Sonarr from within the UI"
exit
fi
echo_warn "Cannot perform sonarr v2 to v3 migration."
exit 1
fi

box install sonarr