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_ram="${var_ram:-512}"
var_disk="${var_disk:-2}" var_disk="${var_disk:-2}"
var_os="${var_os:-debian}" var_os="${var_os:-debian}"
var_version="${var_version:-12}" var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}" var_unprivileged="${var_unprivileged:-1}"
header_info "$APP" header_info "$APP"
@ -27,45 +27,45 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi 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" msg_info "Stopping Service"
systemctl stop heimdall systemctl stop heimdall
sleep 1 sleep 1
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Backing up Data" msg_info "Backing up Data"
cp -R /opt/Heimdall/database database-backup cp -R /opt/Heimdall/database database-backup
cp -R /opt/Heimdall/public public-backup cp -R /opt/Heimdall/public public-backup
sleep 1 sleep 1
msg_ok "Backed up Data" 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") setup_composer
tar xzf "${RELEASE}".tar.gz fetch_and_deploy_gh_release "Heimdall" "linuxserver/Heimdall" "tarball"
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 msg_info "Updating Heimdall-Dashboard"
cd /opt/Heimdall cd /opt/Heimdall
$STD apt-get install -y composer
export COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
$STD composer dump-autoload $STD composer dump-autoload
echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated Heimdall-Dashboard"
msg_ok "Updated Heimdall Dashboard to ${RELEASE}"
msg_info "Restoring Data" msg_info "Restoring Data"
cd ~ cd ~
cp -R database-backup/* /opt/Heimdall/database cp -R database-backup/* /opt/Heimdall/database
cp -R public-backup/* /opt/Heimdall/public cp -R public-backup/* /opt/Heimdall/public
sleep 1 sleep 1
msg_ok "Restored Data" 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 sleep 1
msg_ok "Cleaned" msg_ok "Cleaned Up"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start heimdall.service systemctl start heimdall.service
sleep 2 sleep 2
msg_ok "Started Service" msg_ok "Started Service"
msg_ok "Updated successfully!" msg_ok "Updated successfully!"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}."
fi fi
exit exit
} }

View File

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

View File

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