Update wastebin.sh
Refactor
This commit is contained in:
parent
d073535346
commit
341e873eba
1 changed files with 25 additions and 37 deletions
|
@ -23,8 +23,8 @@ header_info
|
|||
echo -e "Loading..."
|
||||
APP="Wastebin"
|
||||
var_disk="4"
|
||||
var_cpu="4"
|
||||
var_ram="2048"
|
||||
var_cpu="1"
|
||||
var_ram="1024"
|
||||
var_os="debian"
|
||||
var_version="12"
|
||||
variables
|
||||
|
@ -58,27 +58,18 @@ function default_settings() {
|
|||
function update_script() {
|
||||
header_info
|
||||
if [[ ! -d /opt/wastebin ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
|
||||
if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then
|
||||
read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt
|
||||
[[ ${prompt,,} =~ ^(y|yes)$ ]] || exit
|
||||
fi
|
||||
RELEASE=$(curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||
msg_info "Stopping Wastebin"
|
||||
systemctl stop wastebin
|
||||
msg_ok "Wastebin Stopped"
|
||||
|
||||
msg_info "Updating Wastebin"
|
||||
RELEASE=$(curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
cd /opt
|
||||
if [ -d wastebin_bak ]; then
|
||||
rm -rf wastebin_bak
|
||||
fi
|
||||
mv wastebin wastebin_bak
|
||||
wget -q "https://github.com/matze/wastebin/archive/refs/tags/${RELEASE}.zip"
|
||||
unzip -q ${RELEASE}.zip
|
||||
mv wastebin-${RELEASE} /opt/wastebin
|
||||
cd /opt/wastebin
|
||||
cargo update -q
|
||||
cargo build -q --release
|
||||
wget -q https://github.com/matze/wastebin/releases/download/${RELEASE}/wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst
|
||||
tar -xf wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst
|
||||
cp -f wastebin /opt/wastebin/
|
||||
chmod +x /opt/wastebin/wastebin
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
msg_ok "Updated Wastebin"
|
||||
|
||||
msg_info "Starting Wastebin"
|
||||
|
@ -86,11 +77,12 @@ systemctl start wastebin
|
|||
msg_ok "Started Wastebin"
|
||||
|
||||
msg_info "Cleaning Up"
|
||||
cd /opt
|
||||
rm -R ${RELEASE}.zip
|
||||
rm -R wastebin_bak
|
||||
rm -rf wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst
|
||||
msg_ok "Cleaned"
|
||||
msg_ok "Updated Successfully"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
|
@ -98,10 +90,6 @@ start
|
|||
build_container
|
||||
description
|
||||
|
||||
msg_info "Setting Container to Normal Resources"
|
||||
pct set $CTID -cores 2
|
||||
msg_ok "Set Container to Normal Resources"
|
||||
|
||||
msg_ok "Completed Successfully!\n"
|
||||
echo -e "${APP} Setup should be reachable by going to the following URL.
|
||||
${BL}http://${IP}:8088${CL} \n"
|
||||
|
|
Loading…
Reference in a new issue