Compare commits
12 commits
manual-mki
...
dev
Author | SHA1 | Date | |
---|---|---|---|
fc090a010c | |||
37ad9e62a2 | |||
e9edb55a47 | |||
962493f352 | |||
986a5cc1ee | |||
4622625570 | |||
88e9406963 | |||
320e94b40d | |||
95a43f2c8b | |||
76d0f675b8 | |||
11c685fbaf | |||
f595076479 |
7 changed files with 160 additions and 9 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,4 +3,4 @@ v00001/
|
||||||
boot/
|
boot/
|
||||||
image.squashfs
|
image.squashfs
|
||||||
cache/
|
cache/
|
||||||
tmp.qcow2
|
tmp.ext4
|
||||||
|
|
|
@ -31,7 +31,7 @@ mount '{{path}}' '{{mountpoint}}' -o bind,umask=100,uid={{uid}},gid={{gid}} || e
|
||||||
local link = links[i]
|
local link = links[i]
|
||||||
string = string .. t([[
|
string = string .. t([[
|
||||||
mkdir -p '{{dirname}}' || exit 1
|
mkdir -p '{{dirname}}' || exit 1
|
||||||
ln -s '{{target}}' '{{path}}' || exit 1
|
ln -sf '{{target}}' '{{path}}' || exit 1
|
||||||
]],
|
]],
|
||||||
{ dirname = utils.dirname(link.path),
|
{ dirname = utils.dirname(link.path),
|
||||||
target = link.target, path = link.path }
|
target = link.target, path = link.path }
|
||||||
|
|
95
modules/nftables.lua
Normal file
95
modules/nftables.lua
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
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
|
||||||
|
]])
|
42
modules/ntpsec.lua
Normal file
42
modules/ntpsec.lua
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
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,6 +2,7 @@ mkdir("/etc/runit/runsvdir/default")
|
||||||
add_symlink("/etc/runit/runsvdir/current", "/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/service", "/etc/runit/runsvdir/current")
|
||||||
add_symlink("/etc/runit/stopit", "/run/runit/stopit")
|
add_symlink("/etc/runit/stopit", "/run/runit/stopit")
|
||||||
|
add_symlink("/etc/runit/reboot", "/run/runit/reboot")
|
||||||
|
|
||||||
local t = require "../utils/templater"
|
local t = require "../utils/templater"
|
||||||
local function add_executable(path, script)
|
local function add_executable(path, script)
|
||||||
|
@ -26,6 +27,7 @@ exec logger -p daemon.info -t {{name}}]], params))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
add_executable(run_script_path, script)
|
add_executable(run_script_path, script)
|
||||||
|
-- Activar servicio
|
||||||
add_symlink("/etc/runit/runsvdir/default/"..name, "/etc/sv/"..name)
|
add_symlink("/etc/runit/runsvdir/default/"..name, "/etc/sv/"..name)
|
||||||
add_symlink(
|
add_symlink(
|
||||||
t("/etc/sv/{{name}}/supervise", params),
|
t("/etc/sv/{{name}}/supervise", params),
|
||||||
|
@ -360,9 +362,17 @@ if [ -z "$VIRTUALIZATION" ]; then
|
||||||
fi
|
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" })
|
add_packages({ "runit", "eudev" })
|
||||||
modules.runit.add_service("getty-tty1", [[#!/bin/sh
|
modules.runit.add_service("getty-tty1", [[#!/bin/sh
|
||||||
exec chpst -P getty 38400 tty1 linux]], false)
|
exec chpst -P getty 38400 tty1 linux]], false)
|
||||||
modules.runit.add_service("getty-tty2", [[#!/bin/sh
|
modules.runit.add_service("getty-tty2", [[#!/bin/sh
|
||||||
exec chpst -P getty 38400 tty2 linux]], false)
|
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,12 +5,14 @@ if test "$NOGRAPHIC" = true; then
|
||||||
qemuappend="-nographic"
|
qemuappend="-nographic"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
qemu-img create -f qcow2 tmp.qcow2 1G
|
fallocate --length 1G tmp.ext4
|
||||||
mkfs.ext4 tmp.qcow2
|
mkfs.ext4 -F tmp.ext4
|
||||||
|
|
||||||
sudo chown root:$(id -u) -R boot/ && sudo chmod g+rw -R boot/
|
sudo chown root:$(id -u) -R boot/ && sudo chmod g+rw -R boot/
|
||||||
qemu-system-x86_64 -enable-kvm -m 2048 \
|
qemu-system-x86_64 -enable-kvm -m 2048 \
|
||||||
-drive file=image.squashfs,media=disk \
|
-drive file=image.squashfs,media=disk,format=raw \
|
||||||
-drive file=tmp.qcow2,media=disk \
|
-drive file=tmp.ext4,media=disk,format=raw \
|
||||||
|
-net nic,model=virtio-net-pci \
|
||||||
|
-net user,hostfwd=tcp:10.69.0.2:8080-:80 \
|
||||||
-kernel boot/vmlinuz-virt -initrd boot/initramfs-virt \
|
-kernel boot/vmlinuz-virt -initrd boot/initramfs-virt \
|
||||||
-append "root=/dev/sda rootfstype=squashfs modules=ext4 init=/sbin/runit-init $append" $qemuappend
|
-append "root=/dev/sda rootfstype=squashfs modules=ext4 quiet init=/sbin/runit-init $append" $qemuappend
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
local alpine = require("alpine")
|
local alpine = require("alpine")
|
||||||
|
|
||||||
local alpine_base_version = "3.16"
|
local alpine_base_version = "3.17"
|
||||||
local alpine_version = alpine_base_version..".0"
|
local alpine_version = alpine_base_version..".1"
|
||||||
local packages = {
|
local packages = {
|
||||||
"alpine-baselayout",
|
"alpine-baselayout",
|
||||||
-- "alpine-conf",
|
-- "alpine-conf",
|
||||||
|
@ -47,7 +47,9 @@ module "runit"
|
||||||
module "socklog"
|
module "socklog"
|
||||||
module "hostname"
|
module "hostname"
|
||||||
module "dhcpcd"
|
module "dhcpcd"
|
||||||
|
module "ntpsec"
|
||||||
module "nginx"
|
module "nginx"
|
||||||
|
module "nftables"
|
||||||
|
|
||||||
print("=> Installing and upgrading packages...")
|
print("=> Installing and upgrading packages...")
|
||||||
utils.expect_nil(alpine.make_world(root, packages))
|
utils.expect_nil(alpine.make_world(root, packages))
|
||||||
|
|
Loading…
Reference in a new issue