commit c87d70ca1e4b2b0beb7bace55cd06ed6e414a2cf Author: Eliezer Croitoru Date: Sun Jul 2 23:41:33 2023 +0000 1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8bcb04f --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: + echo OK +clean: + rm -vf alpine-cloud-init-frr_vm.qcow2;true + rm -vf alpine-cloud-init-data.iso;true +build: + bash build.sh + +vhdx: + qemu-img convert -p alpine-cloud-init-frr_vm.qcow2 -O vhdx alpine-cloud-init-frr_vm.vhdx diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..449dac0 --- /dev/null +++ b/build.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +export DEBIAN_FRONTEND=noninteractive + +# install ubuntu dependenices for image building +apt update +apt install -y libvirt-daemon qemu-utils qemu wget genisoimage + +stat alpine-make-vm-image || wget https://raw.githubusercontent.com/alpinelinux/alpine-make-vm-image/master/alpine-make-vm-image -O alpine-make-vm-image +chmod +x alpine-make-vm-image +echo '0d5d3e375cb676d6eb5c1a52109a3a0a8e4cd7ac alpine-make-vm-image' | sha1sum -c +if [ "$?" -gt "0" ];then + echo "alpine-make-vm-image checksum is bad, check for an update at:" + echo "https://github.com/alpinelinux/alpine-make-vm-image" + exit 1 +fi + +PACKAGES_FILE="os/packages" +INIT_SCRIPT="os/configure.sh" +IMAGES_FILENAME="alpine-cloud-init-frr_vm.qcow2" +ALPINE_BRANCH="3.17" +DISK_SIZE="20G" +IMAGE_FORMAT="qcow2" + +bash alpine-make-vm-image -b ${ALPINE_BRANCH} -p "$( cat ${PACKAGES_FILE} | xargs) " -s ${DISK_SIZE} -f ${IMAGE_FORMAT} ${IMAGES_FILENAME} --script-chroot ${INIT_SCRIPT} + +cd seed +mkisofs -output ../alpine-cloud-init-data.iso -volid cidata -joliet -rock user-data meta-data +cd - diff --git a/os/configure.sh b/os/configure.sh new file mode 100755 index 0000000..a629095 --- /dev/null +++ b/os/configure.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +_step_counter=0 +step() { + _step_counter=$(( _step_counter + 1 )) + printf '\n\033[1;36m%d) %s\033[0m\n' $_step_counter "$@" >&2 # bold cyan +} + + +step 'Set up timezone' +setup-timezone -z Asia/Jerusalem + +#step 'Set up keymap' +#setup-keymap fr fr-azerty + +step 'Set up networking' +cat > /etc/network/interfaces <<-EOF + auto lo + iface lo inet loopback + + auto eth0 + iface eth0 inet dhcp +EOF + +# FIXME: remove root and alpine password +step 'Set cloud configuration' +sed -e '/disable_root:/ s/true/false/' \ + -e '/ssh_pwauth:/ s/0/no/' \ + -e '/name: alpine/a \ passwd: "*"' \ + -e '/lock_passwd:/ s/True/False/' \ + -i /etc/cloud/cloud.cfg + +# To have oh-my-zsh working on first boot +cat >> /etc/cloud/cloud.cfg <> /etc/ssh/sshd_config + +step 'Remove password for users' +usermod -p '*' root + +step 'Adjust rc.conf' +sed -Ei \ + -e 's/^[# ](rc_depend_strict)=.*/\1=NO/' \ + -e 's/^[# ](rc_logger)=.*/\1=YES/' \ + -e 's/^[# ](unicode)=.*/\1=YES/' \ + /etc/rc.conf + +# see https://gitlab.alpinelinux.org/alpine/aports/-/issues/8861 +step 'Enable cloud-init configuration via NoCloud iso image' + +echo "iso9660" >> /etc/filesystems + +step 'Enable services' +/sbin/rc-update add acpid default +/sbin/rc-update add chronyd default +/sbin/rc-update add crond default +/sbin/rc-update add networking boot +/sbin/rc-update add termencoding boot +/sbin/rc-update add sshd default +/sbin/rc-update add cloud-init default +/sbin/rc-update add cloud-config default +/sbin/rc-update add cloud-final default +/sbin/rc-update add frr default diff --git a/os/packages b/os/packages new file mode 100644 index 0000000..f1396f5 --- /dev/null +++ b/os/packages @@ -0,0 +1,21 @@ +acpi +frr +iproute2 +ruby +ruby-dev +curl +wget +htop +bash +ca-certificates +chrony +cloud-init +e2fsprogs-extra +less +logrotate +openssh +py3-netifaces +py3-pyserial +ssl_client +sudo +vim diff --git a/os/repositories b/os/repositories new file mode 100644 index 0000000..5f2522a --- /dev/null +++ b/os/repositories @@ -0,0 +1,3 @@ +http://dl-cdn.alpinelinux.org/alpine/v3.17/main +http://dl-cdn.alpinelinux.org/alpine/v3.17/community +http://dl-cdn.alpinelinux.org/alpine/edge/testing diff --git a/seed/meta-data b/seed/meta-data new file mode 100644 index 0000000..77da86d --- /dev/null +++ b/seed/meta-data @@ -0,0 +1,2 @@ +instance-id: iid-local01 +local-hostname: cloudimg diff --git a/seed/user-data b/seed/user-data new file mode 100644 index 0000000..9d4107f --- /dev/null +++ b/seed/user-data @@ -0,0 +1,4 @@ +#cloud-config +password: passw0rd +chpasswd: { expire: False } +ssh_pwauth: True