Last active
September 30, 2021 21:26
-
-
Save bencord0/7c7c0fe5e2c3971fd7d16078f63f2d78 to your computer and use it in GitHub Desktop.
Custom Gentoo Openstack Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/guestfish -f | |
!echo "Modifying gentoo-openstack.qcow2" | |
# Fetch the image from the mirrors. | |
# wget -O gentoo-openstack.qcow2 \ | |
# https://distfiles.gentoo.org/experimental/amd64/openstack/gentoo-openstack-amd64-systemd-latest.qcow2 | |
add gentoo-openstack.qcow2 | |
!echo "Starting libguestfs" | |
run | |
mount /dev/sda3 / | |
# Allow root to login locally | |
command 'sed -e s#root:\*:#root::# -i /etc/shadow' | |
!echo "-----> Enabled local root logins" | |
# Allow boot consoles (over VNC) | |
upload -<<EOF /etc/default/grub | |
GRUB_DISTRIBUTOR="Gentoo" | |
GRUB_DEVICE=LABEL=cloudimg-rootfs | |
GRUB_DISABLE_LINUX_UUID=true | |
GRUB_TIMEOUT=5 | |
GRUB_TERMINAL="serial console" | |
GRUB_GFXPAYLOAD_LINUX=auto | |
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=tty1 console=ttyS0,115200 console=ttyS1,115200 no_timer_check nofb nomodeset gfxpayload=text" | |
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" | |
EOF | |
command 'grub-mkconfig -o /boot/grub/grub.cfg' | |
!echo "-----> Updated Bootloader" | |
# Install ssh key (a generic setup would use cloud-init) | |
mkdir-mode /root/.ssh/ 500 | |
upload -<<EOF /root/.ssh/authorized_keys | |
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGZgUM37ngXvI1QHDXbWW2ZuqxOJVDBEpksSV14fyZHw | |
EOF | |
!echo "-----> Installed Authorized SSH key" | |
# Configure the package manager | |
mkdir /etc/portage/repos.conf/ | |
upload -<<EOF /etc/portage/repos.conf/gentoo.conf | |
[DEFAULT] | |
main-repo = gentoo | |
[gentoo] | |
location = /var/db/repos/gentoo | |
sync-type = git | |
sync-uri = https://github.com/gentoo-mirror/gentoo.git | |
[bencord0] | |
location = /var/db/repos/bencord0 | |
sync-type = git | |
sync-uri = https://github.com/bencord0/portage-overlay | |
EOF | |
!echo "-----> /etc/portage/repos.conf" | |
upload -<<EOF /etc/portage/binrepos.conf | |
[binhost] | |
sync-uri = https://portage.condi.me/x86_64-pc-linux-gnu/packages/ | |
EOF | |
!echo "-----> /etc/portage/binrepos.conf" | |
upload -<<EOF /etc/portage/make.conf | |
ACCEPT_KEYWORDS="amd64" | |
FEATURES="buildpkg binpkg-multi-instance getbinpkg" | |
LC_MESSAGES=C | |
EOF | |
!echo "-----> /etc/portage/make.conf" | |
# Setting up DNS | |
rm /etc/resolv.conf | |
ln-s /run/systemd/resolve/resolv.conf /etc/resolv.conf | |
# Enabling services | |
command 'systemctl enable systemd-resolved' | |
!echo '-----> Enabling System Services' | |
!echo "All Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First run commands
The sync will use a shallow git clone from github. My personal overlay is also fetched.
Other profiles can be chosen, e.g. https://github.com/bencord0/portage-overlay/blob/master/profiles/profiles.desc
which is why syncing the tree and selecting a specific profile is not part of the script.
Additional provisioning tools, e.g. ansible, can now take over.