From 864fc1c2e0597606ec8e2e04ae3150144aa3ed39 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 25 Mar 2017 15:03:59 +0200 Subject: Add buildos monitor --- bootstrap | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap b/bootstrap index d2c2be0..16b42b5 100755 --- a/bootstrap +++ b/bootstrap @@ -140,7 +140,7 @@ if [ "$stage" -eq "1" ]; then # # - systemd-container seems to be required by host systemd-nspawn. # - pkgs="locales,klibc-utils,systemd-container" + pkgs="locales,klibc-utils,sudo,systemd-container" pkgs+=",linux-image-amd64,irqbalance,pciutils" @@ -281,6 +281,12 @@ trap "exit 1" ERR set -x +# Create the build user, /build home directory. Make a password-less sudo'er. +# +adduser --home /build --gecos "" --disabled-password build +echo "build ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/build +chmod 0440 /etc/sudoers.d/build + # Clean up package cache. # apt-get clean @@ -301,9 +307,9 @@ EOF # Note that when started via systemd-nspawn, we get /dev/console, not # /dev/tty0. # - write < "$owd/buildos-rootfs.cpio.gz" - cd "$owd" subvol_snapshot -r "$root" "$root-4" @@ -361,14 +366,25 @@ fi # if [ "$stage" -le "5" ]; then - # @@ TODO: init location + # Install init and buildos monitor. # - sudo cp -f ./init "$root/" + sudo install -m 755 ./init "$root/" + sudo install -m 755 ./buildos "$root/usr/sbin/" + sudo install -m 755 ./buildos.service "$root/usr/lib/systemd/system/" + sudo ln -sf "$root/usr/lib/systemd/system/buildos.service" \ + "$root/usr/lib/systemd/system/default.target.wants/buildos.service" info "generating buildos-init.cpio.gz..." - sudo echo 'init' | \ - sudo cpio -o -H newc | \ + + cd "$root" + sudo cpio -o -H newc < "$owd/buildos-init.cpio.gz" +init +usr/sbin/buildos +usr/lib/systemd/system/buildos.service +usr/lib/systemd/system/default.target.wants/buildos.service +EOF + cd "$owd" cat buildos-rootfs.cpio.gz buildos-init.cpio.gz >buildos-initrd @@ -396,4 +412,4 @@ sudo kvm \ -device "scsi-hd,drive=disk1" \ -drive "if=none,id=disk1,file=/tmp/buildos-disk,format=raw" \ -kernel buildos-image -initrd buildos-initrd \ - -append "buildos.smtp_relay=build2.org buildos.admin_email=admin@build.org" + -append "buildos.smtp_relay=build2.org buildos.admin_email=admin@build2.org" -- cgit v1.1