Add multi-boot PXE menu, Clonezilla backup management, and GE Aerospace branding
- iPXE boot menu with WinPE, Clonezilla, Blancco Drive Eraser, Memtest86+ - prepare-boot-tools.sh to download/extract boot tool binaries - Clonezilla backup management in webapp (upload, download, delete) - Clonezilla Samba share for network backup/restore - GE Aerospace logo and favicon in webapp - Updated playbook with boot tool directories and webapp env vars Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -22,6 +22,12 @@ WestJeff*/
|
||||
# Offline packages (built by download-packages.sh)
|
||||
offline-packages/
|
||||
|
||||
# Boot tool binaries (built by prepare-boot-tools.sh)
|
||||
boot-tools/
|
||||
|
||||
# Deployment images (imported via webapp or USB)
|
||||
geastandardpbr/
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
16
SETUP.md
16
SETUP.md
@@ -115,14 +115,14 @@ pxe-server/
|
||||
|
||||
## Image Types
|
||||
|
||||
| Image Type | Domain |
|
||||
|-------------------|-----------------|
|
||||
| geastandardpbr | geaerospace.com |
|
||||
| geaengineerpbr | geaerospace.com |
|
||||
| geashopfloorpbr | geaerospace.com |
|
||||
| gestandardlegacy | ge.com |
|
||||
| geengineerlegacy | ge.com |
|
||||
| geshopfloorlegacy | ge.com |
|
||||
| Image Type | Domain | Description |
|
||||
|---------------|-----------------|---------------------|
|
||||
| gea-standard | geaerospace.com | Standard desktop |
|
||||
| gea-engineer | geaerospace.com | Engineering desktop |
|
||||
| gea-shopfloor | geaerospace.com | Shop floor kiosk |
|
||||
| ge-standard | ge.com | Standard desktop |
|
||||
| ge-engineer | ge.com | Engineering desktop |
|
||||
| ge-shopfloor | ge.com | Shop floor kiosk |
|
||||
|
||||
## Network Configuration
|
||||
|
||||
|
||||
10
build-usb.sh
10
build-usb.sh
@@ -185,6 +185,16 @@ if [ -d "$WEBAPP_DIR" ]; then
|
||||
echo " Copied webapp/"
|
||||
fi
|
||||
|
||||
# Copy boot tools (Clonezilla, Blancco, Memtest) if prepared
|
||||
BOOT_TOOLS_DIR="$SCRIPT_DIR/boot-tools"
|
||||
if [ -d "$BOOT_TOOLS_DIR" ]; then
|
||||
cp -r "$BOOT_TOOLS_DIR" "$MOUNT_POINT/boot-tools"
|
||||
TOOLS_SIZE=$(du -sh "$MOUNT_POINT/boot-tools" | cut -f1)
|
||||
echo " Copied boot-tools/ ($TOOLS_SIZE)"
|
||||
else
|
||||
echo " No boot-tools/ found (run prepare-boot-tools.sh first)"
|
||||
fi
|
||||
|
||||
# Optionally copy WinPE deployment images
|
||||
if [ -n "$WINPE_SOURCE" ] && [ -d "$WINPE_SOURCE" ]; then
|
||||
echo " Copying WinPE deployment content from $WINPE_SOURCE..."
|
||||
|
||||
@@ -32,12 +32,13 @@
|
||||
samba_share: "/srv/samba/winpeapps"
|
||||
usb_mount: "/mnt/usb/playbook" # where your USB is mounted
|
||||
image_types:
|
||||
- geastandardpbr
|
||||
- geaengineerpbr
|
||||
- geashopfloorpbr
|
||||
- gestandardlegacy
|
||||
- geengineerlegacy
|
||||
- geshopfloorlegacy
|
||||
- gea-standard
|
||||
- gea-engineer
|
||||
- gea-shopfloor
|
||||
- ge-standard
|
||||
- ge-engineer
|
||||
- ge-shopfloor-lockdown
|
||||
- ge-shopfloor-mce
|
||||
deploy_subdirs:
|
||||
- Applications
|
||||
- Control
|
||||
@@ -114,7 +115,17 @@
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: "Create GetPxeScript.aspx"
|
||||
- name: "Create boot tool directories"
|
||||
file:
|
||||
path: "{{ web_root }}/{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop:
|
||||
- clonezilla
|
||||
- blancco
|
||||
- memtest
|
||||
|
||||
- name: "Create GetPxeScript.aspx (iPXE boot menu)"
|
||||
copy:
|
||||
dest: "{{ web_root }}/Altiris/iPXE/GetPxeScript.aspx"
|
||||
backup: yes
|
||||
@@ -123,16 +134,50 @@
|
||||
|
||||
set server 10.9.100.1
|
||||
|
||||
kernel http://${server}/win11/wimboot gui
|
||||
:menu
|
||||
menu GE Aerospace PXE Boot Menu
|
||||
item --gap -- ---- Windows Deployment ----
|
||||
item winpe Windows PE (Image Deployment)
|
||||
item --gap -- ---- Utilities ----
|
||||
item clonezilla Clonezilla Live (Disk Imaging)
|
||||
item blancco Blancco Drive Eraser
|
||||
item memtest Memtest86+ (Memory Diagnostics)
|
||||
item --gap -- ----
|
||||
item reboot Reboot
|
||||
item exit Exit to BIOS
|
||||
choose --default winpe --timeout 30000 target && goto ${target}
|
||||
|
||||
:winpe
|
||||
kernel http://${server}/win11/wimboot gui
|
||||
initrd http://${server}/win11/EFI/Microsoft/Boot/boot.stl EFI/Microsoft/Boot/Boot.stl
|
||||
initrd http://${server}/win11/EFI/Microsoft/Boot/BCD EFI/Microsoft/Boot/BCD
|
||||
initrd http://${server}/win11/EFI/Boot/bootx64.efi EFI/Boot/bootx64.efi
|
||||
initrd http://${server}/win11/Boot/boot.sdi Boot/boot.sdi
|
||||
initrd http://${server}/win11/sources/boot.wim sources/boot.wim
|
||||
|
||||
boot
|
||||
|
||||
:clonezilla
|
||||
set base http://${server}/clonezilla
|
||||
kernel ${base}/vmlinuz boot=live username=user union=overlay config components noswap edd=on nomodeset nodmraid locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=${base}/filesystem.squashfs
|
||||
initrd ${base}/initrd.img
|
||||
boot
|
||||
|
||||
:blancco
|
||||
set bbase http://${server}/blancco
|
||||
kernel ${bbase}/vmlinuz-bde-linux archisobasedir=arch archiso_http_srv=http://${server}/blancco/ copytoram=y cow_spacesize=50% memtest=00 vmalloc=400M ip=dhcp quiet nomodeset libata.allow_tpm=1
|
||||
initrd ${bbase}/intel-ucode.img ${bbase}/amd-ucode.img ${bbase}/config.img ${bbase}/initramfs-bde-linux.img
|
||||
boot
|
||||
|
||||
:memtest
|
||||
kernel http://${server}/memtest/memtest.efi
|
||||
boot
|
||||
|
||||
:reboot
|
||||
reboot
|
||||
|
||||
:exit
|
||||
exit
|
||||
|
||||
- name: "Ensure Apache listens on port 4433"
|
||||
lineinfile:
|
||||
path: /etc/apache2/ports.conf
|
||||
@@ -171,7 +216,13 @@
|
||||
state: directory
|
||||
mode: '0777'
|
||||
|
||||
- name: "Configure Samba share"
|
||||
- name: "Create Clonezilla backup share directory"
|
||||
file:
|
||||
path: /srv/samba/clonezilla
|
||||
state: directory
|
||||
mode: '0777'
|
||||
|
||||
- name: "Configure Samba shares"
|
||||
blockinfile:
|
||||
path: /etc/samba/smb.conf
|
||||
backup: yes
|
||||
@@ -182,6 +233,13 @@
|
||||
read only = no
|
||||
guest ok = yes
|
||||
|
||||
[clonezilla]
|
||||
path = /srv/samba/clonezilla
|
||||
browseable = yes
|
||||
read only = no
|
||||
guest ok = yes
|
||||
comment = Clonezilla backup images
|
||||
|
||||
- name: "Create image-type top-level directories"
|
||||
file:
|
||||
path: "{{ samba_share }}/{{ item }}"
|
||||
@@ -219,6 +277,15 @@
|
||||
loop:
|
||||
- ipxe.efi
|
||||
|
||||
- name: "Copy boot tool files from USB (Clonezilla, Blancco, Memtest)"
|
||||
shell: >
|
||||
cp -r "{{ usb_mount }}/../boot-tools/{{ item }}/"* "{{ web_root }}/{{ item }}/" 2>/dev/null ||
|
||||
cp -r "{{ usb_mount }}/boot-tools/{{ item }}/"* "{{ web_root }}/{{ item }}/" 2>/dev/null || true
|
||||
loop:
|
||||
- clonezilla
|
||||
- blancco
|
||||
- memtest
|
||||
|
||||
- name: "Check for WinPE deployment content on USB"
|
||||
stat:
|
||||
path: "{{ usb_mount }}/images"
|
||||
@@ -306,6 +373,7 @@
|
||||
User=root
|
||||
WorkingDirectory=/opt/pxe-webapp
|
||||
Environment=SAMBA_SHARE={{ samba_share }}
|
||||
Environment=CLONEZILLA_SHARE=/srv/samba/clonezilla
|
||||
ExecStart=/opt/pxe-webapp/venv/bin/python app.py
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
175
prepare-boot-tools.sh
Executable file
175
prepare-boot-tools.sh
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# prepare-boot-tools.sh — Download/extract boot files for PXE boot tools
|
||||
#
|
||||
# Downloads Clonezilla Live and Memtest86+ for PXE booting,
|
||||
# and extracts Blancco Drive Eraser from its ISO.
|
||||
#
|
||||
# Usage:
|
||||
# ./prepare-boot-tools.sh [/path/to/blancco.iso]
|
||||
#
|
||||
# Output directories:
|
||||
# boot-tools/clonezilla/ — vmlinuz, initrd.img, filesystem.squashfs
|
||||
# boot-tools/blancco/ — extracted boot files or ISO for memdisk
|
||||
# boot-tools/memtest/ — memtest.efi
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
OUT_DIR="$SCRIPT_DIR/boot-tools"
|
||||
BLANCCO_ISO="${1:-}"
|
||||
|
||||
# Auto-detect Blancco ISO in project directory
|
||||
if [ -z "$BLANCCO_ISO" ]; then
|
||||
BLANCCO_ISO=$(find "$SCRIPT_DIR" -maxdepth 1 -name '*DriveEraser*.iso' -o -name '*blancco*.iso' 2>/dev/null | head -1)
|
||||
fi
|
||||
|
||||
mkdir -p "$OUT_DIR"/{clonezilla,blancco,memtest}
|
||||
|
||||
echo "============================================"
|
||||
echo "PXE Boot Tools Preparation"
|
||||
echo "============================================"
|
||||
|
||||
# --- Clonezilla Live ---
|
||||
echo ""
|
||||
echo "[1/3] Clonezilla Live"
|
||||
|
||||
CLONEZILLA_VERSION="3.2.1-6"
|
||||
CLONEZILLA_FILE="clonezilla-live-${CLONEZILLA_VERSION}-amd64.zip"
|
||||
CLONEZILLA_URL="https://sourceforge.net/projects/clonezilla/files/clonezilla_live_stable/${CLONEZILLA_VERSION}/${CLONEZILLA_FILE}/download"
|
||||
|
||||
if [ -f "$OUT_DIR/clonezilla/vmlinuz" ] && [ -f "$OUT_DIR/clonezilla/filesystem.squashfs" ]; then
|
||||
echo " Already prepared, skipping. Delete boot-tools/clonezilla/ to re-download."
|
||||
else
|
||||
echo " Downloading Clonezilla Live ${CLONEZILLA_VERSION}..."
|
||||
TMPDIR=$(mktemp -d)
|
||||
|
||||
wget -q --show-progress -O "$TMPDIR/$CLONEZILLA_FILE" "$CLONEZILLA_URL" || {
|
||||
echo " ERROR: Download failed. Trying alternative URL..."
|
||||
# Fallback: try OSDN mirror
|
||||
wget -q --show-progress -O "$TMPDIR/$CLONEZILLA_FILE" \
|
||||
"https://free.nchc.org.tw/clonezilla-live/stable/${CLONEZILLA_FILE}" || {
|
||||
echo " ERROR: Could not download Clonezilla. Download manually and place in boot-tools/clonezilla/"
|
||||
echo " Need: vmlinuz, initrd.img, filesystem.squashfs from the live ZIP"
|
||||
}
|
||||
}
|
||||
|
||||
if [ -f "$TMPDIR/$CLONEZILLA_FILE" ]; then
|
||||
echo " Extracting PXE boot files..."
|
||||
unzip -o -j "$TMPDIR/$CLONEZILLA_FILE" "live/vmlinuz" -d "$OUT_DIR/clonezilla/"
|
||||
unzip -o -j "$TMPDIR/$CLONEZILLA_FILE" "live/initrd.img" -d "$OUT_DIR/clonezilla/"
|
||||
unzip -o -j "$TMPDIR/$CLONEZILLA_FILE" "live/filesystem.squashfs" -d "$OUT_DIR/clonezilla/"
|
||||
rm -rf "$TMPDIR"
|
||||
echo " Done."
|
||||
fi
|
||||
fi
|
||||
|
||||
ls -lh "$OUT_DIR/clonezilla/" 2>/dev/null | grep -E 'vmlinuz|initrd|squashfs' | sed 's/^/ /'
|
||||
|
||||
# --- Blancco Drive Eraser ---
|
||||
echo ""
|
||||
echo "[2/3] Blancco Drive Eraser"
|
||||
|
||||
if [ -n "$BLANCCO_ISO" ] && [ -f "$BLANCCO_ISO" ]; then
|
||||
echo " Extracting from: $BLANCCO_ISO"
|
||||
echo " Using 7z to extract (no root required)..."
|
||||
|
||||
# Blancco is Arch Linux-based. We need:
|
||||
# arch/boot/x86_64/vmlinuz-bde-linux
|
||||
# arch/boot/x86_64/initramfs-bde-linux.img
|
||||
# arch/boot/intel-ucode.img
|
||||
# arch/boot/amd-ucode.img
|
||||
# arch/boot/config.img
|
||||
# arch/x86_64/airootfs.sfs
|
||||
TMPDIR=$(mktemp -d)
|
||||
7z x -o"$TMPDIR" "$BLANCCO_ISO" \
|
||||
"arch/boot/x86_64/vmlinuz-bde-linux" \
|
||||
"arch/boot/x86_64/initramfs-bde-linux.img" \
|
||||
"arch/boot/intel-ucode.img" \
|
||||
"arch/boot/amd-ucode.img" \
|
||||
"arch/boot/config.img" \
|
||||
"arch/x86_64/airootfs.sfs" \
|
||||
-r 2>/dev/null || {
|
||||
echo " 7z extraction failed. Install p7zip-full: apt install p7zip-full"
|
||||
}
|
||||
|
||||
# Flatten into blancco/ directory for HTTP serving
|
||||
if [ -f "$TMPDIR/arch/boot/x86_64/vmlinuz-bde-linux" ]; then
|
||||
cp "$TMPDIR/arch/boot/x86_64/vmlinuz-bde-linux" "$OUT_DIR/blancco/"
|
||||
cp "$TMPDIR/arch/boot/x86_64/initramfs-bde-linux.img" "$OUT_DIR/blancco/"
|
||||
cp "$TMPDIR/arch/boot/intel-ucode.img" "$OUT_DIR/blancco/"
|
||||
cp "$TMPDIR/arch/boot/amd-ucode.img" "$OUT_DIR/blancco/"
|
||||
cp "$TMPDIR/arch/boot/config.img" "$OUT_DIR/blancco/"
|
||||
# airootfs.sfs needs to be in arch/x86_64/ path relative to HTTP root
|
||||
mkdir -p "$OUT_DIR/blancco/arch/x86_64"
|
||||
cp "$TMPDIR/arch/x86_64/airootfs.sfs" "$OUT_DIR/blancco/arch/x86_64/"
|
||||
echo " Extracted Blancco boot files."
|
||||
else
|
||||
echo " Could not extract boot files from ISO."
|
||||
fi
|
||||
rm -rf "$TMPDIR"
|
||||
else
|
||||
echo " No Blancco ISO found. Provide path as argument or place in project directory."
|
||||
echo " Usage: $0 /path/to/DriveEraser.iso"
|
||||
fi
|
||||
|
||||
ls -lh "$OUT_DIR/blancco/" 2>/dev/null | grep -v '^total' | sed 's/^/ /'
|
||||
|
||||
# --- Memtest86+ ---
|
||||
echo ""
|
||||
echo "[3/3] Memtest86+"
|
||||
|
||||
MEMTEST_VERSION="7.20"
|
||||
MEMTEST_URL="https://memtest.org/download/${MEMTEST_VERSION}/mt86plus_${MEMTEST_VERSION}.binaries.zip"
|
||||
|
||||
if [ -f "$OUT_DIR/memtest/memtest.efi" ]; then
|
||||
echo " Already prepared, skipping."
|
||||
else
|
||||
echo " Downloading Memtest86+ v${MEMTEST_VERSION}..."
|
||||
TMPDIR=$(mktemp -d)
|
||||
|
||||
wget -q --show-progress -O "$TMPDIR/memtest.zip" "$MEMTEST_URL" || {
|
||||
echo " ERROR: Download failed. Download manually from https://memtest.org"
|
||||
TMPDIR=""
|
||||
}
|
||||
|
||||
if [ -n "$TMPDIR" ] && [ -f "$TMPDIR/memtest.zip" ]; then
|
||||
echo " Extracting EFI binary..."
|
||||
unzip -o -j "$TMPDIR/memtest.zip" "memtest64.efi" -d "$OUT_DIR/memtest/" 2>/dev/null || \
|
||||
unzip -o -j "$TMPDIR/memtest.zip" "mt86plus_${MEMTEST_VERSION}.x64.efi" -d "$OUT_DIR/memtest/" 2>/dev/null || \
|
||||
unzip -o "$TMPDIR/memtest.zip" -d "$TMPDIR/extract/"
|
||||
|
||||
# Find the EFI file regardless of exact name
|
||||
EFI_FILE=$(find "$TMPDIR" "$OUT_DIR/memtest" -name '*.efi' -name '*64*' 2>/dev/null | head -1)
|
||||
if [ -n "$EFI_FILE" ] && [ ! -f "$OUT_DIR/memtest/memtest.efi" ]; then
|
||||
cp "$EFI_FILE" "$OUT_DIR/memtest/memtest.efi"
|
||||
fi
|
||||
rm -rf "$TMPDIR"
|
||||
echo " Done."
|
||||
fi
|
||||
fi
|
||||
|
||||
ls -lh "$OUT_DIR/memtest/" 2>/dev/null | grep -v '^total' | sed 's/^/ /'
|
||||
|
||||
# --- Summary ---
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo "Boot tools prepared in: $OUT_DIR/"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
|
||||
for tool in clonezilla blancco memtest; do
|
||||
COUNT=$(find "$OUT_DIR/$tool" -type f 2>/dev/null | wc -l)
|
||||
SIZE=$(du -sh "$OUT_DIR/$tool" 2>/dev/null | cut -f1)
|
||||
printf " %-15s %s (%d files)\n" "$tool" "$SIZE" "$COUNT"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "These files need to be copied to the PXE server's web root:"
|
||||
echo " /var/www/html/clonezilla/"
|
||||
echo " /var/www/html/blancco/"
|
||||
echo " /var/www/html/memtest/"
|
||||
echo ""
|
||||
echo "The build-usb.sh script will include them automatically,"
|
||||
echo "or copy them manually to the server."
|
||||
echo ""
|
||||
112
webapp/app.py
112
webapp/app.py
@@ -14,34 +14,40 @@ from flask import (
|
||||
redirect,
|
||||
render_template,
|
||||
request,
|
||||
send_file,
|
||||
url_for,
|
||||
)
|
||||
from lxml import etree
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.environ.get("FLASK_SECRET_KEY", "pxe-manager-dev-key-change-in-prod")
|
||||
app.config["MAX_CONTENT_LENGTH"] = 16 * 1024 * 1024 * 1024 # 16 GB max upload
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
SAMBA_SHARE = os.environ.get("SAMBA_SHARE", "/srv/samba/winpeapps")
|
||||
CLONEZILLA_SHARE = os.environ.get("CLONEZILLA_SHARE", "/srv/samba/clonezilla")
|
||||
|
||||
IMAGE_TYPES = [
|
||||
"geastandardpbr",
|
||||
"geaengineerpbr",
|
||||
"geashopfloorpbr",
|
||||
"gestandardlegacy",
|
||||
"geengineerlegacy",
|
||||
"geshopfloorlegacy",
|
||||
"gea-standard",
|
||||
"gea-engineer",
|
||||
"gea-shopfloor",
|
||||
"ge-standard",
|
||||
"ge-engineer",
|
||||
"ge-shopfloor-lockdown",
|
||||
"ge-shopfloor-mce",
|
||||
]
|
||||
|
||||
FRIENDLY_NAMES = {
|
||||
"geastandardpbr": "GEA Standard PBR",
|
||||
"geaengineerpbr": "GEA Engineer PBR",
|
||||
"geashopfloorpbr": "GEA Shop Floor PBR",
|
||||
"gestandardlegacy": "GE Standard Legacy",
|
||||
"geengineerlegacy": "GE Engineer Legacy",
|
||||
"geshopfloorlegacy": "GE Shop Floor Legacy",
|
||||
"gea-standard": "GE Aerospace Standard",
|
||||
"gea-engineer": "GE Aerospace Engineer",
|
||||
"gea-shopfloor": "GE Aerospace Shop Floor",
|
||||
"ge-standard": "GE Legacy Standard",
|
||||
"ge-engineer": "GE Legacy Engineer",
|
||||
"ge-shopfloor-lockdown": "GE Legacy Shop Floor Lockdown",
|
||||
"ge-shopfloor-mce": "GE Legacy Shop Floor MCE",
|
||||
}
|
||||
|
||||
NS = "urn:schemas-microsoft-com:unattend"
|
||||
@@ -561,6 +567,77 @@ def unattend_editor(image_type):
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Routes — Clonezilla Backups
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@app.route("/backups")
|
||||
def clonezilla_backups():
|
||||
backups = []
|
||||
if os.path.isdir(CLONEZILLA_SHARE):
|
||||
for f in sorted(os.listdir(CLONEZILLA_SHARE)):
|
||||
fpath = os.path.join(CLONEZILLA_SHARE, f)
|
||||
if os.path.isfile(fpath) and f.lower().endswith(".zip"):
|
||||
stat = os.stat(fpath)
|
||||
backups.append({
|
||||
"filename": f,
|
||||
"machine": os.path.splitext(f)[0],
|
||||
"size": stat.st_size,
|
||||
"modified": stat.st_mtime,
|
||||
})
|
||||
return render_template(
|
||||
"backups.html",
|
||||
backups=backups,
|
||||
image_types=IMAGE_TYPES,
|
||||
friendly_names=FRIENDLY_NAMES,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/backups/upload", methods=["POST"])
|
||||
def clonezilla_upload():
|
||||
if "backup_file" not in request.files:
|
||||
flash("No file selected.", "danger")
|
||||
return redirect(url_for("clonezilla_backups"))
|
||||
|
||||
f = request.files["backup_file"]
|
||||
if not f.filename:
|
||||
flash("No file selected.", "danger")
|
||||
return redirect(url_for("clonezilla_backups"))
|
||||
|
||||
filename = secure_filename(f.filename)
|
||||
if not filename.lower().endswith(".zip"):
|
||||
flash("Only .zip files are accepted.", "danger")
|
||||
return redirect(url_for("clonezilla_backups"))
|
||||
|
||||
os.makedirs(CLONEZILLA_SHARE, exist_ok=True)
|
||||
dest = os.path.join(CLONEZILLA_SHARE, filename)
|
||||
f.save(dest)
|
||||
flash(f"Uploaded {filename} successfully.", "success")
|
||||
return redirect(url_for("clonezilla_backups"))
|
||||
|
||||
|
||||
@app.route("/backups/download/<filename>")
|
||||
def clonezilla_download(filename):
|
||||
filename = secure_filename(filename)
|
||||
fpath = os.path.join(CLONEZILLA_SHARE, filename)
|
||||
if not os.path.isfile(fpath):
|
||||
flash(f"Backup not found: {filename}", "danger")
|
||||
return redirect(url_for("clonezilla_backups"))
|
||||
return send_file(fpath, as_attachment=True)
|
||||
|
||||
|
||||
@app.route("/backups/delete/<filename>", methods=["POST"])
|
||||
def clonezilla_delete(filename):
|
||||
filename = secure_filename(filename)
|
||||
fpath = os.path.join(CLONEZILLA_SHARE, filename)
|
||||
if os.path.isfile(fpath):
|
||||
os.remove(fpath)
|
||||
flash(f"Deleted {filename}.", "success")
|
||||
else:
|
||||
flash(f"Backup not found: {filename}", "danger")
|
||||
return redirect(url_for("clonezilla_backups"))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Routes — API
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -611,6 +688,17 @@ def api_save_unattend(image_type):
|
||||
return jsonify({"status": "ok", "path": xml_file})
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Template filters
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@app.template_filter("timestamp_fmt")
|
||||
def timestamp_fmt(ts):
|
||||
"""Format a Unix timestamp to a human-readable date string."""
|
||||
from datetime import datetime
|
||||
return datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Context processor — make data available to all templates
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
BIN
webapp/static/favicon.ico
Normal file
BIN
webapp/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
8
webapp/static/ge-aerospace-logo.svg
Normal file
8
webapp/static/ge-aerospace-logo.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
131
webapp/templates/backups.html
Normal file
131
webapp/templates/backups.html
Normal file
@@ -0,0 +1,131 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Clonezilla Backups - PXE Server Manager{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="mb-0"><i class="bi bi-archive me-2"></i>Clonezilla Backups</h2>
|
||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#uploadModal">
|
||||
<i class="bi bi-upload me-1"></i> Upload Backup
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header d-flex align-items-center">
|
||||
<i class="bi bi-hdd-stack me-2"></i> Machine Backups
|
||||
<span class="badge bg-secondary ms-2">{{ backups|length }}</span>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
{% if backups %}
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Machine #</th>
|
||||
<th>Filename</th>
|
||||
<th>Size</th>
|
||||
<th>Last Modified</th>
|
||||
<th class="text-end">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for b in backups %}
|
||||
<tr>
|
||||
<td><strong>{{ b.machine }}</strong></td>
|
||||
<td><code>{{ b.filename }}</code></td>
|
||||
<td>{{ "%.1f"|format(b.size / 1073741824) }} GB</td>
|
||||
<td>{{ b.modified | timestamp_fmt }}</td>
|
||||
<td class="text-end text-nowrap">
|
||||
<a href="{{ url_for('clonezilla_download', filename=b.filename) }}"
|
||||
class="btn btn-sm btn-outline-primary" title="Download">
|
||||
<i class="bi bi-download"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger"
|
||||
data-bs-toggle="modal" data-bs-target="#deleteModal"
|
||||
data-filename="{{ b.filename }}" data-machine="{{ b.machine }}" title="Delete">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="text-center text-muted py-5">
|
||||
<i class="bi bi-archive" style="font-size: 3rem;"></i>
|
||||
<p class="mt-2">No backups found. Upload a Clonezilla backup .zip to get started.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-3">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title"><i class="bi bi-info-circle me-1"></i> Backup Naming Convention</h6>
|
||||
<p class="card-text mb-0">
|
||||
Name backup files with the machine number (e.g., <code>6501.zip</code>).
|
||||
The Samba share <code>\\pxe-server\clonezilla</code> is also available on the network for direct Clonezilla save/restore operations.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Upload Modal -->
|
||||
<div class="modal fade" id="uploadModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="{{ url_for('clonezilla_upload') }}" method="post" enctype="multipart/form-data">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="bi bi-upload me-2"></i>Upload Backup</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label for="backupFile" class="form-label">Backup File (.zip)</label>
|
||||
<input type="file" class="form-control" id="backupFile" name="backup_file"
|
||||
accept=".zip" required>
|
||||
<div class="form-text">
|
||||
Name the file with the machine number (e.g., <code>6501.zip</code>).
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary"><i class="bi bi-upload me-1"></i> Upload</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form id="deleteForm" method="post">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="bi bi-exclamation-triangle me-2 text-danger"></i>Confirm Delete</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete the backup for machine <strong id="deleteMachine"></strong>?</p>
|
||||
<p class="text-muted mb-0">This action cannot be undone.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-danger"><i class="bi bi-trash me-1"></i> Delete</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
document.getElementById('deleteModal').addEventListener('show.bs.modal', function (event) {
|
||||
var btn = event.relatedTarget;
|
||||
var filename = btn.getAttribute('data-filename');
|
||||
var machine = btn.getAttribute('data-machine');
|
||||
document.getElementById('deleteMachine').textContent = machine;
|
||||
document.getElementById('deleteForm').action = '/backups/delete/' + encodeURIComponent(filename);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}PXE Server Manager{% endblock %}</title>
|
||||
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YcnS49cn91B2HOwP4cMpe1bBMnos9GBsYl7a"
|
||||
@@ -115,7 +116,7 @@
|
||||
<!-- Sidebar -->
|
||||
<nav class="sidebar d-flex flex-column">
|
||||
<div class="brand">
|
||||
<i class="bi bi-hdd-network"></i>
|
||||
<img src="{{ url_for('static', filename='ge-aerospace-logo.svg') }}" alt="GE Aerospace" style="height: 28px; filter: brightness(0) invert(1);">
|
||||
PXE Manager
|
||||
</div>
|
||||
<ul class="nav flex-column mt-2">
|
||||
@@ -134,9 +135,20 @@
|
||||
</ul>
|
||||
|
||||
<div class="nav-section-divider"></div>
|
||||
<div class="sidebar-heading">PBR Images</div>
|
||||
<div class="sidebar-heading">Tools</div>
|
||||
<ul class="nav flex-column">
|
||||
{% for it in ['geastandardpbr', 'geaengineerpbr', 'geashopfloorpbr'] %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.endpoint == 'clonezilla_backups' %}active{% endif %}"
|
||||
href="{{ url_for('clonezilla_backups') }}">
|
||||
<i class="bi bi-archive"></i> Clonezilla Backups
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="nav-section-divider"></div>
|
||||
<div class="sidebar-heading">GE Aerospace Images</div>
|
||||
<ul class="nav flex-column">
|
||||
{% for it in ['gea-standard', 'gea-engineer', 'gea-shopfloor'] %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.endpoint == 'unattend_editor' and image_type is defined and image_type == it %}active{% endif %}"
|
||||
href="{{ url_for('unattend_editor', image_type=it) }}">
|
||||
@@ -147,9 +159,9 @@
|
||||
</ul>
|
||||
|
||||
<div class="nav-section-divider"></div>
|
||||
<div class="sidebar-heading">Legacy Images</div>
|
||||
<div class="sidebar-heading">GE Legacy Images</div>
|
||||
<ul class="nav flex-column">
|
||||
{% for it in ['gestandardlegacy', 'geengineerlegacy', 'geshopfloorlegacy'] %}
|
||||
{% for it in ['ge-standard', 'ge-engineer', 'ge-shopfloor-lockdown', 'ge-shopfloor-mce'] %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.endpoint == 'unattend_editor' and image_type is defined and image_type == it %}active{% endif %}"
|
||||
href="{{ url_for('unattend_editor', image_type=it) }}">
|
||||
|
||||
Reference in New Issue
Block a user