diff options
-rwxr-xr-x | bootstrap | 9 | ||||
-rw-r--r-- | doc/manual.cli | 22 | ||||
-rwxr-xr-x | init | 51 |
3 files changed, 73 insertions, 9 deletions
@@ -147,7 +147,7 @@ if [ "$stage" -eq "1" ]; then pkgs+=",hdparm,btrfs-progs" pkgs+=",net-tools,iproute2,iptables,isc-dhcp-client" - pkgs+=",ifupdown,bridge-utils,dnsmasq,ntp" + pkgs+=",ifupdown,bridge-utils,dnsmasq,ntp,postfix" pkgs+=",iputils-ping,wget,curl" pkgs+=",less" @@ -240,11 +240,11 @@ chpasswd <<<'root:$passwd' # Enable IPv4 forwarding (used for private bridge NAT). # -sed -i 's/^# *\(net.ipv4.ip_forward\).*/\1=1/' /etc/sysctl.conf +sed -i -e 's/^# *\(net.ipv4.ip_forward\).*/\1=1/' /etc/sysctl.conf # Setup locale. We only support en_US.UTF-8. # -sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen +sed -i -e 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen locale-gen --purge cat <<EOF1 >/etc/default/locale @@ -386,4 +386,5 @@ sudo kvm \ -m 8G \ -netdev 'tap,id=net0,script=./qemu-ifup' \ -device "e1000,netdev=net0,mac=$macaddr" \ - -kernel buildos-image -initrd buildos-initrd + -kernel buildos-image -initrd buildos-initrd \ + -append "buildos.smtp_relay=build2.org buildos.admin_email=admin@build.org" diff --git a/doc/manual.cli b/doc/manual.cli index e5d6cf3..1140db5 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -18,7 +18,7 @@ This document describes \c{buildos}, the \c{build2} operating system. \h1#intro|Introduction| -\c{buildos} is a GNU/Linux(Debian)-based in-memory network-booted operating +\c{buildos} is a Debian GNU/Linux-based in-memory network-booted operating system specialized for autonomous building of software using the \c{build2} toolchain. It's primary purpose is to run the \c{build2} build bot (\c{bbot}), build slave (\c{bslave}), or both. @@ -69,7 +69,8 @@ timeout 50 label buildos menu label buildos kernel /buildos/buildos-image - append initrd=/buildos/buildos-initrd + initrd /buildos/buildos-initrd + append buildos.smtp_relay=example.org buildos.admin_email=admin@example.org EOF \ @@ -125,4 +126,21 @@ instance by examining \c{/etc/network/interfaces}. @@ TODO: private network parameters. +\h2#config-email|Email| + +A \c{buildos} instance sends various notifications (including all messages to +\c{root}) to the admin email address. The admin email is specified with +the \c{buildos.admin_email} kernel command line parameter. + +In order to deliver mail, the \c{postfix} MTA is configured to forward to a +relay. The relay host is specified with the \c{buildos.smtp_relay} kernel +command line parameter. + +Note that no authentication of any kind is configured for relaying. This means +that the relay host should accept emails from build hosts either because of +their network location (for example, because they are on your organization's +local network and you are using your organization's relay) or because the +relay host accepts emails send to the admin address from anyone (which is +normally the case if the relay is the final destination for the admin +address, for example, \c{example.org} and \c{admin@example.org}). " @@ -52,10 +52,35 @@ SYSTEMD_LOG_LEVEL=info /lib/systemd/systemd-udevd --daemon --resolve-names=never udevadm trigger --action=add udevadm settle || true -# Parse command line. +# Parse the kernel command line. This is complicated by the fact that the +# values can be quoted, for example: # -cmdline="$(cat /proc/cmdline)" -info "boot cmdline: $cmdline" +# foo='foo fox' +# bar="bar 'box'" +# +# First we separete quoted variables and arguments with newlines (giving +# priority to assignments). Then we replace whitespaces with newline on +# lines that don't contain quites. Finally, clean up by removing blank +# lines. +# +readarray -t cmdline < <(cat /proc/cmdline | \ + sed -r -e "s/([^ ]+=)?('[^']*'|\"[^\"]*\")/\n\1\2\n/g" | \ + sed -r -e "/['\"]/!s/ /\n/g" | + sed -r -e '/^\s*$/d') + +# Enter all buildos variables as bash variables. +# +info "command line:" +for v in "${cmdline[@]}"; do + var="$(sed -r -n -e 's/^buildos\.([^=]+)=.*$/\1/p' <<<"$v")" # Extract name. + + if [ -n "$var" ]; then + val="$(sed -r -e 's/^[^=]+=(.*)$/\1/' <<<"$v")" # Extract value. + val="$(sed -r -e "s/^('(.*)'|\"(.*)\")$/\2\3/" <<<"$val")" # Strip quoted. + info " $var=$val" + declare "$var=$val" + fi +done # Figure out network configuration and generate the corresponding # /etc/network/interfaces. @@ -200,6 +225,26 @@ bind-interfaces dhcp-range=${priv_netbase}.10,${priv_netbase}.250,12h EOF +# Configure Postfix. +# +cat <<<"$hname" >/etc/mailname + +sed -r -i \ + -e "s%^(myhostname).*%\1 = $hname%" \ + -e 's%^(mydestination).*%\1 = $myhostname, localhost.localdomain, localhost%' \ + -e 's%^(mynetworks).*%\1 = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128%' \ + -e "s%^(relayhost).*%\1 = $smtp_relay%" \ + /etc/postfix/main.cf + +# Make admin alias for buildos.admin_email, redirect root to admin. +# +cat <<EOF >>/etc/aliases +admin: $admin_email +root: admin +EOF + +newaliases + /bin/bash # Hand off to systemd. But first arrange to keep console output (which |