From 1b17e0e0c5034dcb83e9f0d176407f14b94bee63 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 6 Mar 2025 15:15:34 +0100 Subject: [PATCH] Migration and add .env file --- ct/wastebin.sh | 26 +++++++++++++++++++++++++- install/wastebin-install.sh | 11 +++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ct/wastebin.sh b/ct/wastebin.sh index eb2b701..e80c17b 100644 --- a/ct/wastebin.sh +++ b/ct/wastebin.sh @@ -29,9 +29,34 @@ function update_script() { fi RELEASE=$(curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') # Dirty-Fix 03/2025 for missing APP_version.txt on old installations, set to pre-latest release + msg_info "Running Migration" if [[ ! -f /opt/${APP}_version.txt ]]; then echo "2.7.1" >/opt/${APP}_version.txt + mkdir -p /opt/wastebin-data + cat </opt/wastebin-data/.env +WASTEBIN_DATABASE_PATH=/opt/wastebin-data/wastebin.db +WASTEBIN_CACHE_SIZE=1024 +WASTEBIN_HTTP_TIMEOUT=30 +WASTEBIN_SIGNING_KEY=$(openssl rand -hex 32) +WASTEBIN_PASTE_EXPIRATIONS=0,600,3600=d,86400,604800,2419200,29030400 +EOF + systemctl stop wastebin + cat </etc/systemd/system/wastebin.service +[Unit] +Description=Wastebin Service +After=network.target + +[Service] +WorkingDirectory=/opt/wastebin +ExecStart=/opt/wastebin/wastebin +EnvironmentFile=/opt/wastebin-data/.env + +[Install] +WantedBy=multi-user.target +EOF + systemctl daemon-reload fi + msg_ok "Migration Done" if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then msg_info "Stopping Wastebin" systemctl stop wastebin @@ -39,7 +64,6 @@ function update_script() { msg_info "Updating Wastebin" temp_file=$(mktemp) - RELEASE=$(curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') wget -q https://github.com/matze/wastebin/releases/download/${RELEASE}/wastebin_${RELEASE}_x86_64-unknown-linux-musl.zip -O $temp_file unzip -q $temp_file cp -f wastebin /opt/wastebin/ diff --git a/install/wastebin-install.sh b/install/wastebin-install.sh index c500e41..6002951 100644 --- a/install/wastebin-install.sh +++ b/install/wastebin-install.sh @@ -28,7 +28,17 @@ unzip -q $temp_file mkdir -p /opt/wastebin mv wastebin /opt/wastebin/ chmod +x /opt/wastebin/wastebin + +mkdir -p /opt/wastebin-data +cat </opt/wastebin-data/.env +WASTEBIN_DATABASE_PATH=/opt/wastebin-data/wastebin.db +WASTEBIN_CACHE_SIZE=1024 +WASTEBIN_HTTP_TIMEOUT=30 +WASTEBIN_SIGNING_KEY=$(openssl rand -hex 32) +WASTEBIN_PASTE_EXPIRATIONS=0,600,3600=d,86400,604800,2419200,29030400 +EOF echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" + msg_ok "Installed Wastebin" msg_info "Creating Service" @@ -40,6 +50,7 @@ After=network.target [Service] WorkingDirectory=/opt/wastebin ExecStart=/opt/wastebin/wastebin +EnvironmentFile=/opt/wastebin-data/.env [Install] WantedBy=multi-user.target