Compare commits
1 commit
dev
...
manual-mki
Author | SHA1 | Date | |
---|---|---|---|
296213448d |
8 changed files with 28 additions and 164 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,4 +3,4 @@ v00001/
|
|||
boot/
|
||||
image.squashfs
|
||||
cache/
|
||||
tmp.ext4
|
||||
tmp.qcow2
|
||||
|
|
|
@ -31,7 +31,7 @@ mount '{{path}}' '{{mountpoint}}' -o bind,umask=100,uid={{uid}},gid={{gid}} || e
|
|||
local link = links[i]
|
||||
string = string .. t([[
|
||||
mkdir -p '{{dirname}}' || exit 1
|
||||
ln -sf '{{target}}' '{{path}}' || exit 1
|
||||
ln -s '{{target}}' '{{path}}' || exit 1
|
||||
]],
|
||||
{ dirname = utils.dirname(link.path),
|
||||
target = link.target, path = link.path }
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
modules.kernel = {}
|
||||
local t = require("../utils/templater")
|
||||
|
||||
add_packages({ "linux-virt" })
|
||||
modules.kernel = {
|
||||
flavor = "virt",
|
||||
mkinitfs = function(rootfs_path)
|
||||
local status = os.execute(t("sudo sed -i 's/^esac/esac;comp=zstd/' '{{rootfs_path}}'/sbin/mkinitfs && sudo chroot '{{rootfs_path}}' mkinitfs -o /boot/initramfs-{{flavor}} $(cat '{{rootfs_path}}'/usr/share/kernel/'{{flavor}}'/kernel.release)", {
|
||||
rootfs_path = rootfs_path,
|
||||
flavor = modules.kernel.flavor,
|
||||
}))
|
||||
if not (status == 0) then return status end
|
||||
end,
|
||||
}
|
||||
|
||||
add_packages({ "linux-" .. modules.kernel.flavor, "zstd" })
|
||||
add_file("/etc/update-extlinux.conf", [[# configuration for extlinux config builder
|
||||
|
||||
# Overwrite current /boot/extlinux.conf.
|
||||
|
@ -26,5 +37,7 @@ timeout=3
|
|||
default=lts
|
||||
]])
|
||||
|
||||
add_file("/etc/mkinitfs/mkinitfs.conf",
|
||||
'features="squashfs ata base cdrom ext4 keymap kms mmc nvme scsi usb virtio"')
|
||||
add_file("/etc/mkinitfs/mkinitfs.conf", [[
|
||||
features="squashfs ata base cdrom ext4 keymap kms mmc nvme scsi usb virtio"
|
||||
disable_trigger=yes
|
||||
]])
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
modules.nftables = {}
|
||||
add_packages({ "nftables" })
|
||||
add_file("/etc/nftables.nft", [[
|
||||
#!/usr/sbin/nft -f
|
||||
|
||||
flush ruleset
|
||||
|
||||
table inet filter {
|
||||
chain input {
|
||||
type filter hook input priority 0; policy drop;
|
||||
|
||||
iifname lo accept \
|
||||
comment "Accept any localhost traffic"
|
||||
|
||||
ct state { established, related } accept \
|
||||
comment "Accept traffic originated from us"
|
||||
|
||||
ct state invalid drop \
|
||||
comment "Drop invalid connections"
|
||||
|
||||
tcp dport 113 reject with icmpx type port-unreachable \
|
||||
comment "Reject AUTH to make it fail fast"
|
||||
|
||||
ip protocol icmp icmp type {
|
||||
echo-reply, # type 0
|
||||
destination-unreachable, # type 3
|
||||
echo-request, # type 8
|
||||
time-exceeded, # type 11
|
||||
parameter-problem, # type 12
|
||||
} accept \
|
||||
comment "Accept ICMP"
|
||||
|
||||
ip6 nexthdr icmpv6 icmpv6 type {
|
||||
destination-unreachable, # type 1
|
||||
packet-too-big, # type 2
|
||||
time-exceeded, # type 3
|
||||
parameter-problem, # type 4
|
||||
echo-request, # type 128
|
||||
echo-reply, # type 129
|
||||
} accept \
|
||||
comment "Accept basic IPv6 functionality"
|
||||
|
||||
ip6 nexthdr icmpv6 icmpv6 type {
|
||||
nd-router-solicit, # type 133
|
||||
nd-router-advert, # type 134
|
||||
nd-neighbor-solicit, # type 135
|
||||
nd-neighbor-advert, # type 136
|
||||
} ip6 hoplimit 255 accept \
|
||||
comment "Allow IPv6 SLAAC"
|
||||
|
||||
ip6 nexthdr icmpv6 icmpv6 type {
|
||||
mld-listener-query, # type 130
|
||||
mld-listener-report, # type 131
|
||||
mld-listener-reduction, # type 132
|
||||
mld2-listener-report, # type 143
|
||||
} ip6 saddr fe80::/10 accept \
|
||||
comment "Allow IPv6 multicast listener discovery on link-local"
|
||||
|
||||
ip6 saddr fe80::/10 udp sport 547 udp dport 546 accept \
|
||||
comment "Accept DHCPv6 replies from IPv6 link-local addresses"
|
||||
|
||||
tcp dport 80 counter accept \
|
||||
comment "Allow HTTP"
|
||||
}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy drop;
|
||||
}
|
||||
|
||||
chain output {
|
||||
type filter hook output priority 0; policy accept;
|
||||
}
|
||||
}
|
||||
|
||||
# The state of stateful objects saved on the nftables service stop.
|
||||
include "/var/lib/nftables/*.nft"
|
||||
|
||||
]])
|
||||
|
||||
modules.runit.add_service("nftables", [[#!/bin/sh
|
||||
if [ ! -r /etc/nftables.nft ]; then
|
||||
echo "No config, dropping everything"
|
||||
nft -f /dev/stdin <<-EOF
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
chain input { type filter hook input priority 0; policy drop; }
|
||||
chain forward { type filter hook forward priority 0; policy drop; }
|
||||
chain output { type filter hook output priority 0; policy drop; }
|
||||
}
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
nft -f /etc/nftables.nft
|
||||
exec sleep infinity
|
||||
]])
|
|
@ -1,42 +0,0 @@
|
|||
add_packages({ "ntpsec" })
|
||||
|
||||
-- In the ntpsec-doc package, open in browser:
|
||||
-- file:///usr/share/doc/ntpsec/quick.html
|
||||
-- file:///usr/share/doc/ntpsec/NTS-QuickStart.html
|
||||
|
||||
add_file("/etc/ntp.conf", [[
|
||||
driftfile /var/lib/ntp/ntp.drift
|
||||
|
||||
restrict default kod limited nomodify nopeer noquery
|
||||
restrict 127.0.0.1
|
||||
restrict ::1
|
||||
|
||||
# https://gist.github.com/jauderho/2ad0d441760fc5ed69d8d4e2d6b35f8d
|
||||
|
||||
server time.cloudflare.com nts iburst
|
||||
server nts.ntp.se nts iburst
|
||||
|
||||
# https://nts.time.nl/
|
||||
server ntppool1.time.nl nts iburst
|
||||
server ntppool2.time.nl nts iburst
|
||||
|
||||
# https://system76.com/time/
|
||||
server paris.time.system76.com nts iburst
|
||||
server brazil.time.system76.com nts iburst
|
||||
|
||||
# https://www.netnod.se/netnod-time/how-to-use-nts
|
||||
server sth1.nts.netnod.se nts iburst
|
||||
server sth2.nts.netnod.se nts iburst
|
||||
|
||||
# https://ntp.br/guia/linux/
|
||||
server a.st1.ntp.br nts iburst
|
||||
server b.st1.ntp.br nts iburst
|
||||
server c.st1.ntp.br nts iburst
|
||||
server d.st1.ntp.br nts iburst
|
||||
server gps.ntp.br nts iburst
|
||||
|
||||
]])
|
||||
|
||||
modules.runit.add_service("ntpsec", [[#!/bin/sh
|
||||
exec ntpd --nice --nofork --panicgate
|
||||
]])
|
|
@ -2,7 +2,6 @@ mkdir("/etc/runit/runsvdir/default")
|
|||
add_symlink("/etc/runit/runsvdir/current", "/etc/runit/runsvdir/default")
|
||||
add_symlink("/etc/service", "/etc/runit/runsvdir/current")
|
||||
add_symlink("/etc/runit/stopit", "/run/runit/stopit")
|
||||
add_symlink("/etc/runit/reboot", "/run/runit/reboot")
|
||||
|
||||
local t = require "../utils/templater"
|
||||
local function add_executable(path, script)
|
||||
|
@ -27,7 +26,6 @@ exec logger -p daemon.info -t {{name}}]], params))
|
|||
)
|
||||
end
|
||||
add_executable(run_script_path, script)
|
||||
-- Activar servicio
|
||||
add_symlink("/etc/runit/runsvdir/default/"..name, "/etc/sv/"..name)
|
||||
add_symlink(
|
||||
t("/etc/sv/{{name}}/supervise", params),
|
||||
|
@ -362,17 +360,9 @@ if [ -z "$VIRTUALIZATION" ]; then
|
|||
fi
|
||||
]])
|
||||
|
||||
-- https://wiki.gentoo.org/wiki/Runit#Reboot_and_shutdown
|
||||
add_executable("/usr/local/sbin/rpoweroff", [[#!/bin/sh
|
||||
runit-init 0]])
|
||||
add_executable("/usr/local/sbin/rreboot", [[#!/bin/sh
|
||||
runit-init 6]])
|
||||
|
||||
add_packages({ "runit", "eudev" })
|
||||
modules.runit.add_service("getty-tty1", [[#!/bin/sh
|
||||
exec chpst -P getty 38400 tty1 linux]], false)
|
||||
modules.runit.add_service("getty-tty2", [[#!/bin/sh
|
||||
exec chpst -P getty 38400 tty2 linux]], false)
|
||||
modules.runit.add_service("getty-ttyS0", [[#!/bin/sh
|
||||
exec chpst -P getty 38400 ttyS0 linux]], false)
|
||||
|
||||
|
|
12
qemu.sh
12
qemu.sh
|
@ -5,14 +5,12 @@ if test "$NOGRAPHIC" = true; then
|
|||
qemuappend="-nographic"
|
||||
fi
|
||||
|
||||
fallocate --length 1G tmp.ext4
|
||||
mkfs.ext4 -F tmp.ext4
|
||||
qemu-img create -f qcow2 tmp.qcow2 1G
|
||||
mkfs.ext4 tmp.qcow2
|
||||
|
||||
sudo chown root:$(id -u) -R boot/ && sudo chmod g+rw -R boot/
|
||||
qemu-system-x86_64 -enable-kvm -m 2048 \
|
||||
-drive file=image.squashfs,media=disk,format=raw \
|
||||
-drive file=tmp.ext4,media=disk,format=raw \
|
||||
-net nic,model=virtio-net-pci \
|
||||
-net user,hostfwd=tcp:10.69.0.2:8080-:80 \
|
||||
-drive file=image.squashfs,media=disk \
|
||||
-drive file=tmp.qcow2,media=disk \
|
||||
-kernel boot/vmlinuz-virt -initrd boot/initramfs-virt \
|
||||
-append "root=/dev/sda rootfstype=squashfs modules=ext4 quiet init=/sbin/runit-init $append" $qemuappend
|
||||
-append "root=/dev/sda rootfstype=squashfs modules=ext4 init=/sbin/runit-init $append" $qemuappend
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local utils = require("utils")
|
||||
local alpine = require("alpine")
|
||||
|
||||
local alpine_base_version = "3.17"
|
||||
local alpine_version = alpine_base_version..".1"
|
||||
local alpine_base_version = "3.16"
|
||||
local alpine_version = alpine_base_version..".0"
|
||||
local packages = {
|
||||
"alpine-baselayout",
|
||||
-- "alpine-conf",
|
||||
|
@ -47,12 +47,12 @@ module "runit"
|
|||
module "socklog"
|
||||
module "hostname"
|
||||
module "dhcpcd"
|
||||
module "ntpsec"
|
||||
module "nginx"
|
||||
module "nftables"
|
||||
|
||||
print("=> Installing and upgrading packages...")
|
||||
utils.expect_nil(alpine.make_world(root, packages))
|
||||
print("=> Generating initramfs...")
|
||||
utils.expect_nil(modules.kernel.mkinitfs(root))
|
||||
print("=> Setting password...")
|
||||
utils.expect_nil(alpine.set_password(root, "root", "1"))
|
||||
print("=> Moving boot...")
|
||||
|
|
Loading…
Reference in a new issue