renamed scripts, added zscaler
This commit is contained in:
21
build-iso.sh
21
build-iso.sh
@@ -25,8 +25,8 @@ WORK_DIR="$(mktemp -d /tmp/autoinstall-build.XXXXXX)"
|
||||
OUTPUT_ISO="autoinstall-$(date +%Y%m%d-%H%M).iso"
|
||||
SOPS_FILE="secrets.sops.yaml"
|
||||
TEMPLATE_DIR="templates"
|
||||
POST_INSTALL_SCRIPT="scripts/post-install.sh"
|
||||
TARGET_USERNAME=$(yq -e .autoinstall.identity.username templates/user-data.tmpl)
|
||||
TARGET_USER=$(yq -r .autoinstall.identity.username templates/user-data.tmpl)
|
||||
export TARGET_USER
|
||||
NOCLOUD_DIR="$WORK_DIR/iso/nocloud"
|
||||
mkdir -p "$NOCLOUD_DIR"
|
||||
|
||||
@@ -40,6 +40,12 @@ error() {
|
||||
echo -e "${RED}[✗]${NC} $*"
|
||||
exit 1
|
||||
}
|
||||
function envsubst_in_place() {
|
||||
set -x
|
||||
local _filename=$1
|
||||
envsubst "\$TARGET_USER" <"$_filename" >$_filename.tmp && mv $_filename.tmp $_filename
|
||||
set +x
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
@@ -53,6 +59,7 @@ done
|
||||
|
||||
cleanup() {
|
||||
info "Cleaning up..."
|
||||
echo "$WORK_DIR"
|
||||
rm -rf "$WORK_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
@@ -69,6 +76,9 @@ info "Decrypting secrets and rendering template..."
|
||||
sops exec-env "$SOPS_FILE" "envsubst < $TEMPLATE_DIR/user-data.tmpl > $NOCLOUD_DIR/user-data"
|
||||
sops exec-env "$SOPS_FILE" "envsubst '\$WIFI_HOUSE_PASSWORD \$NOKIA_WIFI_KEY_PASSWORD' < $TEMPLATE_DIR/user-data-wifi.tmpl > $NOCLOUD_DIR/user-data-wifi.config"
|
||||
|
||||
envsubst_in_place "$NOCLOUD_DIR/user-data"
|
||||
envsubst_in_place "$NOCLOUD_DIR/user-data-wifi.config"
|
||||
|
||||
info "Template rendered."
|
||||
|
||||
# ── Get Ubuntu ISO ─────────────────────────────────────────────────────────────
|
||||
@@ -101,11 +111,12 @@ dd if="$UBUNTU_ISO" bs=1 count=432 of="$WORK_DIR/mbr_template.bin" 2>/dev/null
|
||||
# ── Inject autoinstall files ───────────────────────────────────────────────────
|
||||
info "Injecting autoinstall config and post-install script..."
|
||||
|
||||
cp "$POST_INSTALL_SCRIPT" "$NOCLOUD_DIR/post-install.sh"
|
||||
cp "scripts/wifi.sh" "$NOCLOUD_DIR/wifi.sh"
|
||||
cp deployment/* "$NOCLOUD_DIR/"
|
||||
touch "$NOCLOUD_DIR/meta-data"
|
||||
|
||||
cp $NOCLOUD_DIR/user-data* /tmp/
|
||||
envsubst_in_place "$NOCLOUD_DIR/post-install.sh"
|
||||
|
||||
cp -r $NOCLOUD_DIR /tmp/
|
||||
|
||||
# ── Patch GRUB ────────────────────────────────────────────────────────────────
|
||||
GRUB_CFG="$WORK_DIR/iso/boot/grub/grub.cfg"
|
||||
|
||||
Reference in New Issue
Block a user