Skip to content

Commit

Permalink
fix: entire remover
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sausages committed Aug 22, 2021
1 parent a79210e commit 6015bac
Showing 1 changed file with 12 additions and 71 deletions.
83 changes: 12 additions & 71 deletions scripts/remove/lazylibrarian.sh
Original file line number Diff line number Diff line change
@@ -1,80 +1,21 @@
#!/bin/bash
# LazyLibrarian remove script for swizzin
# Author: Aethaeran

##########################################################################
# Import Sources
##########################################################################

. /etc/swizzin/sources/functions/utils

##########################################################################
# Variables
##########################################################################
# Author: Aethaeran 2021
# GPLv3

app_name="lazylibrarian"
pretty_name="LazyLibrarian"
app_dir="/opt/$app_name"
master=$(_get_master_username)
config_dir="/home/$master/.config/$app_name"
venv_dir="/opt/.venv/$app_name"
user="$(swizdb get $app_name/owner)"

##########################################################################
# Main
##########################################################################
rm -rf "/opt/.venv/$app_name"
rm -rf "/opt/$app_name"
rm -rf "/home/$user/.config/$app_name"

if [[ -e "$venv_dir" ]]; then
echo_progress_start "Removing $pretty_name venv..."
# shellcheck disable=2154 # log variable is inherited from box itself.
rm -rv "$venv_dir" >> "$log" 2>&1
echo_progress_done
else
echo_info "$pretty_name venv_dir didn't exist."
fi

if [[ -e "$app_dir" ]]; then
echo_progress_start "Removing $pretty_name installation..."
# shellcheck disable=2154 # log variable is inherited from box itself.
rm -rv "$app_dir" >> "$log" 2>&1
echo_progress_done
else
echo_info "$pretty_name app_dir didn't exist."
fi
systemctl disable --now "$app_name" --quiet
rm -rf "/etc/systemd/system/$app_name.service"

if [[ -e "$config_dir" ]]; then
echo_progress_start "Removing $pretty_name configuration..."
rm -rv "$config_dir" >> "$log" 2>&1
echo_progress_done
else
echo_info "$pretty_name config_dir didn't exist."
if [[ -f /install/.nginx.lock ]]; then
rm -rf "/etc/nginx/apps/$app_name.conf"
systemctl reload nginx
fi

if [[ -e "/etc/systemd/system/$app_name.service" ]]; then
echo_progress_start "Removing $pretty_name systemd service..."
if [[ $(systemctl is-active "$app_name") == "active" ]]; then
systemctl stop "$app_name" --quiet
fi
if [[ $(systemctl is-enabled "$app_name") == "enabled" ]]; then
systemctl disable "$app_name" --quiet
fi
rm -v "/etc/systemd/system/$app_name.service" >> "$log" 2>&1
echo_progress_done
else
echo_info "$pretty_name systemd service didn't exist."
fi

if [[ -e "/etc/nginx/apps/$app_name.conf" ]]; then
echo_progress_start "Removing $pretty_name nginx configuration..."
rm -v "/etc/nginx/apps/$app_name.conf" >> "$log" 2>&1
echo_progress_done
else
echo_info "$pretty_name nginx configuration didn't exist."
fi

if [[ -e "/install/.$app_name.lock" ]]; then
echo_progress_start "Removing $pretty_name lock..."
rm -v "/install/.$app_name.lock" >> "$log" 2>&1
echo_progress_done
else
echo_info "$pretty_name lock didn't exist."
fi
rm "/install/.$app_name.lock"

0 comments on commit 6015bac

Please sign in to comment.