diff --git a/ct/netbootxyz.sh b/ct/netbootxyz.sh new file mode 100644 index 00000000..6dd2fb86 --- /dev/null +++ b/ct/netbootxyz.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/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" diff --git a/install/netbootxyz-install.sh b/install/netbootxyz-install.sh new file mode 100644 index 00000000..933167c3 --- /dev/null +++ b/install/netbootxyz-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y ansible git apache2 +msg_ok "Installed Dependencies" + +RELEASE=$(curl -sX GET "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') +msg_info "Installing netboot.xyz ${RELEASE}" +$STD curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/netbootxyz/netboot.xyz/archive/${RELEASE}.tar.gz" +$STD tar xvzf ${RELEASE}.tar.gz +VER=$(curl -s https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest | + grep "tag_name" | + awk '{print substr($2, 2, length($2)-3) }') +rm -rf ${RELEASE}.tar.gz +mv netboot.xyz-${VER} /opt/netboot.xyz +msg_ok "Installed netboot.xyz ${RELEASE}" + +msg_info "Creating Service" +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 +$STD sudo systemctl enable --now netbootxyz.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned"