Skip to content

Instantly share code, notes, and snippets.

@OmegaRogue
Created December 15, 2021 23:11
Show Gist options
  • Save OmegaRogue/08d9d060cf1a3b012af9f1d4b101556a to your computer and use it in GitHub Desktop.
Save OmegaRogue/08d9d060cf1a3b012af9f1d4b101556a to your computer and use it in GitHub Desktop.
image:
distribution: "alpinelinux"
release: edge
source:
downloader: alpinelinux-http
same_as: 3.15
url: http://dl-cdn.alpinelinux.org/alpine/
keys:
- 0482D84022F52DF1C4E7CD43293ACD0907D9495A
targets:
lxc:
create_message: |
You just created an {{ image.description }} container.
config:
- type: all
before: 5
content: |-
lxc.include = LXC_TEMPLATE_CONFIG/alpine.common.conf
- type: user
before: 5
content: |-
lxc.include = LXC_TEMPLATE_CONFIG/alpine.userns.conf
- type: all
after: 4
content: |-
lxc.include = LXC_TEMPLATE_CONFIG/common.conf
- type: user
after: 4
content: |-
lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
- type: all
content: |-
lxc.arch = {{ image.architecture_personality }}
lxd:
vm:
filesystem: ext4
files:
- path: /etc/hostname
generator: hostname
- path: /etc/hosts
generator: hosts
- generator: fstab
types:
- vm
- generator: lxd-agent
types:
- vm
- path: /etc/default/grub
generator: dump
pongo: true
content: |-
# Set the recordfail timeout
GRUB_RECORDFAIL_TIMEOUT=0
# Do not wait on grub prompt
GRUB_TIMEOUT=0
# Set the default commandline
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0 modules=sd-mod,usb-storage,{{ targets.lxd.vm.filesystem }} rootfstype={{ targets.lxd.vm.filesystem }}"
# Set the grub console type
GRUB_TERMINAL=console
# Disable os-prober
GRUB_DISABLE_OS_PROBER=true
types:
- vm
- path: /etc/network/interfaces
generator: dump
content: |-
auto eth0
iface eth0 inet dhcp
hostname $(hostname)
- path: /etc/inittab
generator: dump
content: |-
# /etc/inittab
::sysinit:/sbin/openrc sysinit
::sysinit:/sbin/openrc boot
::wait:/sbin/openrc default
# Set up a couple of getty's
::respawn:/sbin/getty 38400 console
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/sbin/openrc shutdown
- path: /etc/inittab
generator: template
name: inittab
content: |-
# /etc/inittab
::sysinit:/sbin/openrc sysinit
::sysinit:/sbin/openrc boot
::wait:/sbin/openrc default
# Set up a couple of getty's
::respawn:/sbin/getty 38400 console
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/sbin/openrc shutdown
packages:
manager: apk
update: true
cleanup: true
sets:
- action: install
packages:
- alpine-base
- doas
- neovim
- tmux
- git
- openssh
- man-pages
- mandoc
- mandoc-apropos
- docs
- gcompat
- action: remove
packages:
- vim
- packages:
- acpi
- gcc
- grub-efi
- linux-virt
- udev
action: install
types:
- vm
actions:
- trigger: post-packages
action: |-
#!/bin/sh
set -eux
# Rewrite configuration for LXC
sed -i 's/#rc_sys=""/rc_sys="lxc"/' /etc/rc.conf
# Enable services
for svc_name in bootmisc syslog; do
ln -s /etc/init.d/${svc_name} /etc/runlevels/boot/${svc_name}
done
for svc_name in networking crond; do
ln -s /etc/init.d/${svc_name} /etc/runlevels/default/${svc_name}
done
types:
- container
- trigger: post-packages
action: |-
#!/bin/sh
set -eux
# Rewrite configuration for LXC
- trigger: post-files
action: |-
#!/bin/sh
set -eux
for svc_name in acpid bootmisc hostname hwclock loadkmap modules networking swap sysctl syslog urandom; do
ln -fs /etc/init.d/${svc_name} /etc/runlevels/boot/${svc_name}
done
for svc_name in devfs dmesg hwdrivers mdev udev udev-settle udev-trigger; do
ln -fs /etc/init.d/${svc_name} /etc/runlevels/sysinit/${svc_name}
done
target=/boot/grub/grub.cfg
grub-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
TARGET="x86_64"
[ "$(uname -m)" = "aarch64" ] && TARGET="arm64"
grub-install --target=${TARGET}-efi --no-nvram --removable
grub-install --target=${TARGET}-efi --no-nvram
types:
- vm
mappings:
architecture_map: alpinelinux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment