From 23d644037a2f723ae3e533c6490111fff7bd7d58 Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Mon, 28 Sep 2015 09:00:33 -0500 Subject: [PATCH] Switch to single overlay dir Instead of tracking many directories, we'll use only one overlay directory to hold any scripts or change we want to see applied over the base image. Signed-off-by: Ryan Harper --- installer/geninstaller | 10 ++-- .../etc}/apparmor.d/sbin.dhclient | 0 .../resources/overlay/subiquity/installer.sh | 39 ++++++++++++++ .../resources/overlay/subiquity/network_up.sh | 6 +++ .../resources/user-data/installer-user-data | 52 +------------------ 5 files changed, 52 insertions(+), 55 deletions(-) rename installer/resources/{apparmor => overlay/etc}/apparmor.d/sbin.dhclient (100%) create mode 100755 installer/resources/overlay/subiquity/installer.sh create mode 100755 installer/resources/overlay/subiquity/network_up.sh diff --git a/installer/geninstaller b/installer/geninstaller index b15ddd7b..4b19cd0f 100755 --- a/installer/geninstaller +++ b/installer/geninstaller @@ -411,7 +411,7 @@ generate_img() { local bootloader=${3}; local offline=${4}; local extlinux_conf=${TOPDIR}/resources/menu/extlinux-menu.conf - local apparmor_path=${TOPDIR}/resources/apparmor + local overlay_path=${TOPDIR}/resources/overlay local grub_efi_core=${TOPDIR}/resources/grub/bootx64.efi # FIXME, ARCH local grub_conf=${TOPDIR}/resources/grub/grub.cfg local embed_conf=${TOPDIR}/resources/grub/embed_efi.cfg @@ -583,10 +583,10 @@ generate_img() { cat ${grub_conf} | sudo tee ${efimnt}/boot/grub/grub.cfg && true fi - # update apparmor policy for dhclient - log "Updating apparmor policies" - sudo rsync -avP ${apparmor_path}/apparmor.d/ ${mnt}/etc/apparmor.d/ || { - log "Failed to sync local apparmor updates"; + # syncing overlay + log "Injecting installer configuration/scripts" + sudo rsync -avP ${overlay_path}/ ${mnt}/ || { + log "Failed to sync local installer configuration/scripts"; return 1; } diff --git a/installer/resources/apparmor/apparmor.d/sbin.dhclient b/installer/resources/overlay/etc/apparmor.d/sbin.dhclient similarity index 100% rename from installer/resources/apparmor/apparmor.d/sbin.dhclient rename to installer/resources/overlay/etc/apparmor.d/sbin.dhclient diff --git a/installer/resources/overlay/subiquity/installer.sh b/installer/resources/overlay/subiquity/installer.sh new file mode 100755 index 00000000..906d959b --- /dev/null +++ b/installer/resources/overlay/subiquity/installer.sh @@ -0,0 +1,39 @@ +#!/bin/bash +LASTCON=$(cat /proc/cmdline | fmt -w 1 | grep ^console= | tail -n 1) +case $LASTCON in + console=ttyS[0-9]) + SERIAL="-o --serial" + systemctl stop serial-getty@ttyS0.service + ;; + console=tty[0-9]) + SERIAL="" + chvt 1 + systemctl stop getty@tty1.service; + ;; +esac +# generate service file +cat </lib/systemd/system/subiquity.service +[Unit] +Description=Ubuntu Servier Installer Service +After=getty@tty1.service + +[Service] +Environment=PYTHONPATH=/usr/local +ExecStart=-/sbin/agetty -n --noclear -l /usr/local/bin/subiquity ${SERIAL} console vt100 +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +KillMode=process +Type=idle +Restart=always +StandardInput=tty-force +StandardOutput=tty +StandardError=tty +TTYPath=/dev/console + +[Install] +WantedBy=default.target +EOF + +systemctl enable subiquity.service +systemctl start subiquity diff --git a/installer/resources/overlay/subiquity/network_up.sh b/installer/resources/overlay/subiquity/network_up.sh new file mode 100755 index 00000000..ffc6a6b2 --- /dev/null +++ b/installer/resources/overlay/subiquity/network_up.sh @@ -0,0 +1,6 @@ +#!/bin/bash -x + +rm -f /etc/network/interfaces +echo -e "auto lo\niface lo inet loopback\n" > /etc/network/interfaces +/bin/ls -1 /sys/class/net | grep -v ^lo$ | xargs -i bash -c 'D={}; echo -e "auto $D\niface $D inet dhcp"' | tee /etc/network/interfaces +/bin/ls -1 /sys/class/net | grep -v ^lo$ | xargs -i ifup {} diff --git a/installer/resources/user-data/installer-user-data b/installer/resources/user-data/installer-user-data index 08278d80..82c1e356 100644 --- a/installer/resources/user-data/installer-user-data +++ b/installer/resources/user-data/installer-user-data @@ -1,61 +1,13 @@ #cloud-config #http_proxy: http://my-proxy:3129/ bootcmd: - - rm -f /etc/network/interfaces - - echo -e "auto lo\niface lo inet loopback\n" > /etc/network/interfaces - - /bin/ls -1 /sys/class/net | grep -v ^lo$ | xargs -i bash -c 'D={}; echo -e "auto $D\niface $D inet dhcp"' | tee /etc/network/interfaces - - /bin/ls -1 /sys/class/net | grep -v ^lo$ | xargs -i ifup {} - - tee -a /etc/modprobe.d/blacklist.conf <<<"blacklist floppy" + - /subiquity/network_up.sh password: passw0rd chpasswd: { expire: False } output: {all: '| tee -a /var/log/cloud-init-output.log'} #packages runcmd: - tar -C /usr/local -xf /tmp/subiquity.tar - - tar -C /usr/local -xf /tmp/probert.tar - (cd /usr/local && bin/curtin-archive extract --no-execute) - - /tmp/installer.sh + - /subiquity/installer.sh write_files: -- content: | - #!/bin/bash - LASTCON=$(cat /proc/cmdline | fmt -w 1 | grep ^console= | tail -n 1) - case $LASTCON in - console=ttyS[0-9]) - SERIAL="-o --serial" - systemctl stop serial-getty@ttyS0.service - ;; - console=tty[0-9]) - SERIAL="" - chvt 1 - systemctl stop getty@tty1.service; - ;; - esac - # generate service file - cat </lib/systemd/system/subiquity.service - [Unit] - Description=Ubuntu Servier Installer Service - After=getty@tty1.service - - [Service] - Environment=PYTHONPATH=/usr/local - ExecStart=-/sbin/agetty -n --noclear -l /usr/local/bin/subiquity ${SERIAL} console vt100 - TTYReset=yes - TTYVHangup=yes - TTYVTDisallocate=yes - KillMode=process - Type=idle - Restart=always - StandardInput=tty-force - StandardOutput=tty - StandardError=tty - TTYPath=/dev/console - - [Install] - WantedBy=default.target - EOF - - systemctl enable subiquity.service - systemctl start subiquity - path: /tmp/installer.sh - owner: root:root - permissions: '0755'