#!/usr/bin/env bash source <(curl -s https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) # Copyright (c) 2021-2023 tteck # Author: tteck (tteckster) # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { clear cat <<"EOF" __ __ __ ____ ___ / /_/ /_ ____ ____ / /_ _ ____ ______ / __ \/ _ \/ __/ __ \/ __ \/ __ \/ __/ | |/_/ / / /_ / / / / / __/ /_/ /_/ / /_/ / /_/ / /__ _> /dev/null systemctl stop netbootxyz sleep 1 msg_ok "Stopped ${APP}" msg_info "Backing up Data" cp -R /opt/netboot.xyz/config config-backup cp -R /opt/netboot.xyz/assets assets-backup sleep 1 msg_ok "Backed up Data" RELEASE=$(curl -sX GET "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') msg_info "Updating netboot.xyz to ${RELEASE}" curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/netbootxyz/netboot.xyz/archive/${RELEASE}.tar.gz" &>/dev/null tar xvzf ${RELEASE}.tar.gz &>/dev/null VER=$(curl -s https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') if [ ! -d "/opt/netboot.xyz" ]; then mv netboot.xyz-${VER} /opt/netboot.xyz else cp -R netboot.xyz-${VER}/* /opt/netboot.xyz fi service_path="/etc/systemd/system/netbootxyz.service" echo "[Unit] Description=netboot.xyz After=network.target [Service] Restart=always RestartSec=5 Type=simple User=root WorkingDirectory=/opt/netboot.xyz ExecStart="ansible-playbook" -i inventory site.yml TimeoutStopSec=30 [Install] WantedBy=multi-user.target" >$service_path msg_ok "Updated netboot.xyz to ${RELEASE}" msg_info "Restoring Data" cp -R config-backup/* /opt/netboot.xyz/config cp -R assets-backup/* /opt/netboot.xyz/assets sleep 1 msg_ok "Restored Data" msg_info "Cleanup" rm -rf ${RELEASE}.tar.gz rm -rf netboot.xyz-${VER} rm -rf config-backup rm -rf assets-backup sleep 1 msg_ok "Cleaned" msg_info "Starting ${APP}" systemctl enable --now netbootxyz.service &>/dev/null sleep 2 msg_ok "Started ${APP}" msg_ok "Updated Successfully" exit } start build_container description msg_ok "Completed Successfully!\n" echo -e "${APP} should be reachable by going to the following URL. ${BL}http://${IP}:3000${CL} \n"