home · contact · privacy
Fix.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 14 May 2025 06:39:46 +0000 (08:39 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 14 May 2025 06:39:46 +0000 (08:39 +0200)
trixie/aptmark/minimal_server [new symlink]
trixie/aptmark/reform_qemu [new file with mode: 0644]
trixie/copy/reform_qemu/etc/nftables.conf [new file with mode: 0755]
trixie/copy/reform_qemu/home/plom/run.sh [new file with mode: 0755]
trixie/scripts/setup_reform_qemu.sh [new file with mode: 0644]

diff --git a/trixie/aptmark/minimal_server b/trixie/aptmark/minimal_server
new file mode 120000 (symlink)
index 0000000..647c77d
--- /dev/null
@@ -0,0 +1 @@
+../../bookworm/aptmark/minimal_server
\ No newline at end of file
diff --git a/trixie/aptmark/reform_qemu b/trixie/aptmark/reform_qemu
new file mode 100644 (file)
index 0000000..6a06dee
--- /dev/null
@@ -0,0 +1,6 @@
+# for getting images
+wget 
+# qemu stuff
+qemu-system-aarch64
+ipxe-qemu
+#
diff --git a/trixie/copy/reform_qemu/etc/nftables.conf b/trixie/copy/reform_qemu/etc/nftables.conf
new file mode 100755 (executable)
index 0000000..56b3db1
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/sbin/nft -f
+
+flush ruleset
+
+table inet filter {
+    chain input {
+        type filter \
+            hook input \
+            priority 0;
+        policy drop;
+        iif lo \
+            accept \
+            comment "accept localhost traffic";
+        ct state invalid \
+            drop \
+            comment "drop invalid connections";
+        ct state established, related \
+            accept \
+            comment "accept traffic originated from us";
+        tcp dport 22 \
+            accept \
+            comment "accept SSH on default port";
+        tcp dport 5994 \
+            accept \
+            comment "accept VNC";
+        ip protocol icmp \
+            icmp type echo-request \
+            accept \
+            comment "accept ICMP for pinging";
+    }
+    chain forward {
+        type filter \
+            hook forward \
+            priority 0;
+        policy drop;
+    }
+    chain output {
+        type filter \
+            hook output \
+            priority 0;
+        policy accept;
+    }
+}
diff --git a/trixie/copy/reform_qemu/home/plom/run.sh b/trixie/copy/reform_qemu/home/plom/run.sh
new file mode 100755 (executable)
index 0000000..1d0d842
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+NAME_REPO='reform-system-image'
+URL_REPO="https://source.mnt.re/reform/${NAME_REPO}"
+NAME_IMG='pocket-reform-system-rk3588.img'
+NAME_IMG_GZ="${NAME_IMG}.gz"
+URL_IMG="${URL_REPO}/-/jobs/9939/artifacts/raw/${NAME_IMG_GZ}?inline=false"
+PATH_EMULATE_SH="${NAME_REPO}/emulate.sh"
+
+cd
+if [ ! -e "${NAME_REPO}" ]; then
+    git clone "${URL_REPO}"
+    sed -i 's/-vnc :94,share=force-shared/-vnc :94,share=ignore/' "${PATH_EMULATE_SH}"
+fi
+if [ ! -e "${NAME_IMG}" ]; then
+    wget "${POCKET_IMG}"
+    gunzip "${NAME_IMG_GZ}"
+fi
+"${PATH_EMULATE_SH}" "${NAME_IMG}"
+
diff --git a/trixie/scripts/setup_reform_qemu.sh b/trixie/scripts/setup_reform_qemu.sh
new file mode 100644 (file)
index 0000000..8d35db9
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/sh
+set -e
+cd $(dirname "$0")
+. lib/apt_get_digested
+. lib/constants_etc  # PATH_ETC
+. lib/constants_ssh  # PATH_REL_SSH, PATH_USER_SSH
+. lib/copy_dirtrees_of_tags
+. lib/core_setup
+. lib/expect_n_args
+. lib/path_tmp_timestamped
+. lib/prefixed_msg
+. lib/put_finished_marker
+
+prefixed_msg_init
+prefixed_msg 'starting'
+
+INSTALL_TAGS='all minimal_server user keep_if_installed:systemd-resolved reform-qemu'
+
+expect_n_args 1 2 'HOSTNAME, [FQDN]' $@
+HOSTNAME="$1"
+FQDN="$2"
+
+prefixed_msg_no_nl 'Determining external IP …'
+for _CANDIDATE in $(hostname -I); do
+    _START=$(echo ${_CANDIDATE} | cut -d'.' -f1)
+    if [ "$(echo -n ${_START} | wc -c)" -gt 3 ]; then  # ignore IPv6
+        continue
+    fi 
+    if [ "${_START}" = "127" -o "${_START}" = "192" -o "${_START}" = "172" ]; then
+        continue
+    fi
+    EXTERNAL_IP="${_CANDIDATE}"
+    break
+done
+echo " it's: ${EXTERNAL_IP}"
+
+if [ ! -z "${FQDN}" ]; then
+    prefixed_msg "Ensuring provided FQDN ${FQDN} maps to it …"
+    IP_BY_DNS=$(getent ahostsv4 "${FQDN}" | head -1 | cut -d' ' -f1)
+    if [ ! "${IP_BY_DNS}" = "${EXTERNAL_IP}" ]; then
+        abort "DNS mapping provided FQDN '${FQDN}' to ${IP_BY_DNS} rather than this system's external IP ${EXTERNAL_IP}."
+    fi
+fi
+
+core_setup "${HOSTNAME}" "${FQDN}" "${EXTERNAL_IP}" "${INSTALL_TAGS}"
+
+prefixed_msg 'Moving SSH data from root to user …'
+mkdir -p "${PATH_USER_SSH}"
+mv "/root/${PATH_REL_SSH}/authorized_keys" "${PATH_USER_SSH}/"
+chown -R "${USERNAME}:${USERNAME}" "${PATH_USER_SSH}"
+
+prefixed_msg 'Enabling firewall …'
+systemctl --quiet enable --now nftables
+
+put_finished_marker 'setup_reform_qemu'
+prefixed_msg_exit