Implement user authentication and admin features in eMMC provisioning dashboard: add SQLite database for user management, create admin log functionality, and enhance session handling. Update README to reflect new public and admin access levels, and improve deployment scripts to support cloud-init images and portal files management.
This commit is contained in:
@@ -10,6 +10,9 @@ REQUEST_FILE="$PROV_DIR/build_cloudinit_request.json"
|
||||
STATUS_FILE="$PROV_DIR/build_cloudinit_status.json"
|
||||
[[ -f /opt/cm4-provisioning/env ]] && source /opt/cm4-provisioning/env
|
||||
BACKUPS_DIR="${BACKUPS_DIR:-$PROV_DIR/backups}"
|
||||
CLOUDINIT_IMAGES_DIR="${CLOUDINIT_IMAGES_DIR:-$PROV_DIR/cloudinit-images}"
|
||||
# Write built cloud-init images to CLOUDINIT_IMAGES_DIR (separate from backups)
|
||||
OUTPUT_DIR="${CLOUDINIT_IMAGES_DIR}"
|
||||
GOLDEN_IMAGE="${GOLDEN_IMAGE:-$PROV_DIR/golden.img}"
|
||||
|
||||
write_status() {
|
||||
@@ -23,7 +26,7 @@ write_status() {
|
||||
|
||||
[[ -f "$REQUEST_FILE" ]] || { echo "No request file"; exit 0; }
|
||||
|
||||
TEMP_DIR=$(mktemp -d -p "$BACKUPS_DIR" cloudinit-build.XXXXXX)
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP_DIR"; rm -f "$REQUEST_FILE"' EXIT
|
||||
|
||||
# Extract fields from JSON into temp files (handles multi-line content)
|
||||
@@ -49,7 +52,7 @@ SET_AS_GOLDEN=$(cat "$TEMP_DIR/set_golden")
|
||||
[[ -n "$URL" ]] || { write_status "error" "" "" "Missing url in request"; exit 1; }
|
||||
|
||||
OUT_NAME="raspios-${VARIANT}-cloudinit-$(date +%Y%m%d-%H%M%S).img"
|
||||
OUT_PATH="$BACKUPS_DIR/$OUT_NAME"
|
||||
OUT_PATH="$OUTPUT_DIR/$OUT_NAME"
|
||||
|
||||
write_status "downloading" "Downloading $(basename "$URL")…" "" ""
|
||||
XZ_FILE="$TEMP_DIR/image.img.xz"
|
||||
@@ -82,8 +85,8 @@ cp "$TEMP_DIR/network-config" "$MNT/network-config"
|
||||
umount "$MNT"
|
||||
losetup -d "$LOOP"
|
||||
|
||||
write_status "finalizing" "Copying image to backups…" "" ""
|
||||
mkdir -p "$BACKUPS_DIR"
|
||||
write_status "finalizing" "Copying image to cloud-init images…" "" ""
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
cp "$IMG_FILE" "$OUT_PATH"
|
||||
|
||||
if [[ "$SET_AS_GOLDEN" == "1" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user