Clean-up.

This commit is contained in:
Johanna Rührig 2025-01-01 16:14:19 +01:00
parent 816e81c49d
commit 15f995d190
2 changed files with 22 additions and 53 deletions

View File

@ -37,53 +37,26 @@ function update_script() {
fi fi
# Crawling the new version and checking whether an update is required # Crawling the new version and checking whether an update is required
RELEASE=$(curl -s https://api.github.com/repos/5etools-mirror-3/5etools-src/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') msg_info "Updating $APP..."
IMG_RELEASE=$(curl -s https://api.github.com/repos/5etools-mirror-2/5etools-img/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ "${IMG_RELEASE}" != "$(cat /opt/${APP}_IMG_version.txt)" ]] || [[ ! -f "/opt/5etools_version.txt" ]] || [[ ! -f "/opt/5etools_IMG_version.txt" ]]; then
msg_info "Updating $APP to ${RELEASE}"
apt-get update &>/dev/null apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null apt-get -y upgrade &>/dev/null
# Creating Backup # Execute Update
msg_info "Creating Backup" msg_info "Updating 5etools"
mv "/opt/${APP}" "/opt/${APP}-backup" cd /opt/5etools
msg_ok "Backup Created" git pull --recurse-submodules --jobs=10
cd ~
msg_info "Updated 5etools"
# Execute Update chown -R www-data: "/opt/${APP}"
msg_info "Setting up 5etools" chmod -R 755 "/opt/${APP}"
wget -q "https://github.com/5etools-mirror-3/5etools-src/archive/refs/tags/${RELEASE}.zip"
unzip -q "${RELEASE}.zip" -d "/opt/${APP}"
rm -rf "${RELEASE}.zip"
msg_ok "Set up 5etools"
msg_info "Setting up 5etools images"
wget -q "https://github.com/5etools-mirror-2/5etools-img/archive/refs/tags/${RELEASE}.zip"
unzip -q "${RELEASE}.zip" -d "/opt/${APP}/img"
rm -rf "${RELEASE}.zip"
msg_info "Set up 5etools images"
chown -R www-data: "/opt/${APP}" # Cleaning up
chmod -R 755 "/opt/${APP}" msg_info "Cleaning Up"
$STD apt-get -y autoremove
# Cleaning up $STD apt-get -y autoclean
msg_info "Cleaning Up" msg_ok "Cleanup Completed"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleanup Completed"
# Last Action
echo "${RELEASE}" >/opt/${APP}_version.txt
echo "${IMG_RELEASE}" >/opt/${APP}_IMG_version.txt
msg_ok "Updated $APP to ${RELEASE}"
msg_ok "Updated $APP images to ${IMG_RELEASE}"
# Starting httpd
msg_info "Starting apache"
apache2ctl start
msg_ok "Started apache"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit exit
} }

View File

@ -21,8 +21,7 @@ $STD apt-get install -y \
sudo \ sudo \
git \ git \
jq \ jq \
apache2 \ apache2
unzip
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
@ -36,17 +35,14 @@ echo "<Location /server-status>\n""\
>>/etc/apache2/apache2.conf >>/etc/apache2/apache2.conf
rm -rf /var/www/html rm -rf /var/www/html
RELEASE=$(curl -s https://api.github.com/repos/5etools-mirror-3/5etools-src/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
IMG_RELEASE=$(curl -s https://api.github.com/repos/5etools-mirror-2/5etools-img/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
msg_info "Setting up 5etools" msg_info "Setting up 5etools"
wget -q "https://github.com/5etools-mirror-3/5etools-src/archive/refs/tags/${RELEASE}.zip" git clone https://github.com/5etools-mirror-3/5etools-src /opt/5etools
unzip -q "${RELEASE}.zip" -d "/opt/5etools"
rm -rf "${RELEASE}.zip"
msg_ok "Set up 5etools" msg_ok "Set up 5etools"
msg_info "Setting up 5etools images" msg_info "Setting up 5etools images"
wget -q "https://github.com/5etools-mirror-2/5etools-img/archive/refs/tags/${IMG_RELEASE}.zip" cd /opt/5etools
unzip -q "${IMG_RELEASE}.zip" -d "/opt/5etools/img" git submodule add -f https://github.com/5etools-mirror-2/5etools-img "img"
rm -rf "${IMG_RELEASE}.zip" git pull --recurse-submodules --jobs=10
cd ~
msg_info "Set up 5etools images" msg_info "Set up 5etools images"
ln -s "/opt/5etools" /var/www/html ln -s "/opt/5etools" /var/www/html