Refactor: Heimdall Dashboard (#9959)

* Refactor

* VED>VE
This commit is contained in:
Slaviša Arežina
2025-12-15 10:10:04 +01:00
committed by GitHub
parent 33103ad256
commit 09134d94dd
3 changed files with 31 additions and 34 deletions

View File

@ -11,7 +11,7 @@ var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-512}"
var_disk="${var_disk:-2}"
var_os="${var_os:-debian}"
var_version="${var_version:-12}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
@ -27,45 +27,45 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
if check_for_gh_release "Heimdall" "linuxserver/Heimdall"; then
msg_info "Stopping Service"
systemctl stop heimdall
sleep 1
msg_ok "Stopped Service"
msg_info "Backing up Data"
cp -R /opt/Heimdall/database database-backup
cp -R /opt/Heimdall/public public-backup
sleep 1
msg_ok "Backed up Data"
msg_info "Updating Heimdall Dashboard to ${RELEASE}"
curl -fsSL "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" -o $(basename "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz")
tar xzf "${RELEASE}".tar.gz
VER=$(curl -fsSL https://api.github.com/repos/linuxserver/Heimdall/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
cp -R Heimdall-"${VER}"/* /opt/Heimdall
setup_composer
fetch_and_deploy_gh_release "Heimdall" "linuxserver/Heimdall" "tarball"
msg_info "Updating Heimdall-Dashboard"
cd /opt/Heimdall
$STD apt-get install -y composer
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer dump-autoload
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated Heimdall Dashboard to ${RELEASE}"
msg_ok "Updated Heimdall-Dashboard"
msg_info "Restoring Data"
cd ~
cp -R database-backup/* /opt/Heimdall/database
cp -R public-backup/* /opt/Heimdall/public
sleep 1
msg_ok "Restored Data"
msg_info "Cleanup"
rm -rf {"${RELEASE}".tar.gz,Heimdall-"${VER}",public-backup,database-backup,Heimdall}
msg_info "Cleaning Up"
rm -rf {public-backup,database-backup}
sleep 1
msg_ok "Cleaned"
msg_ok "Cleaned Up"
msg_info "Starting Service"
systemctl start heimdall.service
sleep 2
msg_ok "Started Service"
msg_ok "Updated successfully!"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}."
fi
exit
}

View File

@ -23,7 +23,7 @@
"ram": 512,
"hdd": 2,
"os": "debian",
"version": "12"
"version": "13"
}
}
],

View File

@ -14,27 +14,22 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y apt-transport-https
$STD apt-get install -y composer
$STD apt-get install -y php8.2-{bz2,curl,sqlite3,zip,xml}
$STD apt install -y apt-transport-https
msg_ok "Installed Dependencies"
RELEASE=$(curl -fsSL "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]')
echo "${RELEASE}" >/opt/"${APPLICATION}"_version.txt
msg_info "Installing Heimdall Dashboard ${RELEASE}"
curl -fsSL "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" -o "${RELEASE}".tar.gz
tar xzf "${RELEASE}".tar.gz
VER=$(curl -fsSL https://api.github.com/repos/linuxserver/Heimdall/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
rm -rf "${RELEASE}".tar.gz
mv Heimdall-"${VER}" /opt/Heimdall
PHP_VERSION="8.4" PHP_MODULE="bz2,sqlite3" PHP_FPM="YES" setup_php
setup_composer
fetch_and_deploy_gh_release "Heimdall" "linuxserver/Heimdall" "tarball"
msg_info "Setting up Heimdall-Dashboard"
cd /opt/Heimdall
cp .env.example .env
$STD php artisan key:generate
msg_ok "Installed Heimdall Dashboard ${RELEASE}"
msg_ok "Setup Heimdall-Dashboard"
msg_info "Creating Service"
service_path="/etc/systemd/system/heimdall.service"
echo "[Unit]
cat <<EOF >/etc/systemd/system/heimdall.service
[Unit]
Description=Heimdall
After=network.target
@ -44,14 +39,16 @@ RestartSec=5
Type=simple
User=root
WorkingDirectory=/opt/Heimdall
ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0
ExecStart=/usr/bin/php artisan serve --port 7990 --host 0.0.0.0
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target" >$service_path
WantedBy=multi-user.target"
EOF
systemctl enable -q --now heimdall
cd /opt/Heimdall
COMPOSER_ALLOW_SUPERUSER=1 composer dump-autoload &>/dev/null
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer dump-autoload
systemctl restart heimdall.service
msg_ok "Created Service"