Added kms.in.
authorZoltán Felleg <zoltan.felleg@userrendszerhaz.hu>
Fri, 1 Dec 2023 19:55:42 +0000 (20:55 +0100)
committerZoltán Felleg <zoltan.felleg@userrendszerhaz.hu>
Fri, 1 Dec 2023 19:55:42 +0000 (20:55 +0100)
sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh [new file with mode: 0755]
sources/kms.in/c3d/firstboot/scripts/02_settimezone.sh [new file with mode: 0755]
sources/kms.in/c3d/firstboot/scripts/03_getupdkms.sh [new file with mode: 0755]
sources/kms.in/c3d/firstboot/scripts/90_setupservices.sh [new file with mode: 0755]
sources/kms.in/c3d/mode.txt [new file with mode: 0644]
sources/kms.in/c3d/owner.txt [new file with mode: 0644]
sources/kms.in/c3d/postinstall/install-data/etc/systemd/system/py-kms.service [new file with mode: 0644]
sources/kms.in/c3d/postinstall/scripts/10_setupservices.sh [new file with mode: 0755]
sources/kms.in/config [new file with mode: 0644]
sources/kms.in/envvars [new file with mode: 0644]

diff --git a/sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh
new file mode 100755 (executable)
index 0000000..bf205ea
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+
+export PAGER=
+
+
+sleep 1
+systemctl --quiet is-active NetworkManager.service
+NM_RC=$?
+CYCLES_WAITED=0
+while [ $NM_RC -ne 0 ]
+do
+    if [ $CYCLES_WAITED -ge 10 ]
+    then
+        exit 1
+    fi
+    if [ $CYCLES_WAITED -eq 0 ]
+    then
+        echo -n "Waiting for NetworkManager"
+    fi
+    echo -n .
+    sleep 1
+    CYCLES_WAITED=$(( $CYCLES_WAITED + 1 ))
+    systemctl --quiet is-active NetworkManager.service
+    NM_RC=$?
+done
+[ $CYCLES_WAITED -gt 0 ] && echo
+
+# wait for the two network connections to come up
+CONNECTION_DEVICES_UP=$(nmcli --terse connection show \
+                            | grep --invert-match ':$' | wc -l)
+CYCLES_WAITED=0
+while [ $CONNECTION_DEVICES_UP -lt 2 ]
+do
+    if [ $CYCLES_WAITED -ge 10 ]
+    then
+        nmcli connection show
+        exit 1
+    fi
+    if [ $CYCLES_WAITED -eq 0 ]
+    then
+        echo -n "Waiting for the network connection"
+    fi
+    echo -n .
+    sleep 1
+    CYCLES_WAITED=$(( $CYCLES_WAITED + 1 ))
+    CONNECTION_DEVICES_UP=$(nmcli --terse connection show \
+                                | grep --invert-match ':$' | wc -l)
+done
+[ $CYCLES_WAITED -gt 0 ] && echo
+
+CONNECTIONS=$(nmcli --terse connection show | wc -l)
+if [ $CONNECTIONS -ne 2 ]
+then
+    echo "Number of connections: $CONNECTIONS instead of 2" >&2
+    exit 1
+fi
+
+CONNECTION_LINE=$(nmcli --terse connection show | grep ':eth0$')
+CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':')
+CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':')
+
+nmcli connection delete uuid "$CONNECTION_UUID"
+
+nmcli connection add \
+    connection.autoconnect yes \
+    connection.id internal \
+    connection.interface-name $CONNECTION_DEVICE \
+    connection.type 802-3-ethernet \
+    ipv4.addresses "10.228.109.225/16" \
+    ipv4.dns "10.228.109.159, 10.228.92.159" \
+    ipv4.dns-search "in.useribm.hu" \
+    ipv4.gateway "10.228.109.254" \
+    ipv4.method "manual" \
+    ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6de1/64" \
+    ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \
+    ipv6.dns-search "in.useribm.hu" \
+    ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \
+    ipv6.method "manual" \
+    save yes
+
+nmcli connection show
+
+hostnamectl hostname kms.in.useribm.hu
+hostnamectl
diff --git a/sources/kms.in/c3d/firstboot/scripts/02_settimezone.sh b/sources/kms.in/c3d/firstboot/scripts/02_settimezone.sh
new file mode 100755 (executable)
index 0000000..0ec1bcc
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+
+sleep 1
+systemctl --quiet is-active dbus.service
+DBUS_RC=$?
+WAITED=0
+while [ $DBUS_RC -ne 0 ]
+do
+    echo -n .
+    sleep 1
+    WAITED=1
+    systemctl --quiet is-active dbus.service
+    DBUS_RC=$?
+done
+[ $WAITED -ne 0 ] && echo
+timedatectl set-timezone Europe/Budapest
diff --git a/sources/kms.in/c3d/firstboot/scripts/03_getupdkms.sh b/sources/kms.in/c3d/firstboot/scripts/03_getupdkms.sh
new file mode 100755 (executable)
index 0000000..250e8ab
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+
+REAL_PATH=$(realpath $(dirname $0))
+DATA_PATH=$(realpath $REAL_PATH/../data)
+
+
+if [ -d /kms/py-kms ]
+then
+    cd /kms/py-kms
+    git pull
+else
+    cd /kms
+    git clone https://github.com/Py-KMS-Organization/py-kms.git
+fi
diff --git a/sources/kms.in/c3d/firstboot/scripts/90_setupservices.sh b/sources/kms.in/c3d/firstboot/scripts/90_setupservices.sh
new file mode 100755 (executable)
index 0000000..6716253
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+
+systemctl enable py-kms.service
+systemctl start py-kms.service
+systemctl enable NetworkManager-wait-online.service
+systemctl start NetworkManager-wait-online.service
+
+systemctl enable logrotate.timer
+systemctl start logrotate.timer
diff --git a/sources/kms.in/c3d/mode.txt b/sources/kms.in/c3d/mode.txt
new file mode 100644 (file)
index 0000000..d0ff0b1
--- /dev/null
@@ -0,0 +1,3 @@
+# mode file (relative to /c3d)
+755 firstboot/scripts/*.sh
+755 postinstall/scripts/*.sh
diff --git a/sources/kms.in/c3d/owner.txt b/sources/kms.in/c3d/owner.txt
new file mode 100644 (file)
index 0000000..49158bf
--- /dev/null
@@ -0,0 +1 @@
+# owner file (relative to /c3d)
diff --git a/sources/kms.in/c3d/postinstall/install-data/etc/systemd/system/py-kms.service b/sources/kms.in/c3d/postinstall/install-data/etc/systemd/system/py-kms.service
new file mode 100644 (file)
index 0000000..9d7fe7d
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=py-kms
+After=network.target
+StartLimitIntervalSec=0
+
+[Service]
+Type=simple
+Restart=always
+RestartSec=1
+KillMode=process
+User=root
+ExecStart=/usr/bin/python3 /kms/py-kms/py-kms/pykms_Server.py :: 1688 -V DEBUG -F /kms/py-kms.log
+
+[Install]
+WantedBy=multi-user.target
diff --git a/sources/kms.in/c3d/postinstall/scripts/10_setupservices.sh b/sources/kms.in/c3d/postinstall/scripts/10_setupservices.sh
new file mode 100755 (executable)
index 0000000..f40ec65
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+
+systemctl disable py-kms.service
+systemctl disable NetworkManager-wait-online.service
+
+systemctl disable logrotate.timer
diff --git a/sources/kms.in/config b/sources/kms.in/config
new file mode 100644 (file)
index 0000000..5afc9d2
--- /dev/null
@@ -0,0 +1,26 @@
+lxc.include = /usr/share/lxc/config/common.conf
+
+lxc.arch = x86_64
+lxc.uts.name = kms.in.useribm.hu
+lxc.rootfs.path = __CONTAINER_PATH__/rootfs
+lxc.rootfs.options = idmap=container
+lxc.mount.auto = proc:rw sys:ro
+lxc.mount.entry = __CONTAINER_FILESYSTEMS_PATH__ kms none bind,create=dir 0 0
+
+lxc.net.0.type = veth
+lxc.net.0.flags = up
+lxc.net.0.link = brci-dev
+lxc.net.0.hwaddr = 02:0c:18:03:6d:e1
+
+lxc.autodev = 1
+
+lxc.cgroup2.devices.allow = a
+
+lxc.idmap = u 0 100000 100000
+lxc.idmap = g 0 100000 100000
+
+lxc.signal.halt = SIGRTMIN+4
+
+lxc.start.auto = 1
+lxc.start.order = __CONTAINER_START_ORDER__
+lxc.start.delay = 5
diff --git a/sources/kms.in/envvars b/sources/kms.in/envvars
new file mode 100644 (file)
index 0000000..4af4752
--- /dev/null
@@ -0,0 +1,7 @@
+DISTRIBUTION=Fedora
+DISTRIBUTION_VERSION=39
+SPEC_PACKAGES="git \
+               python3-dns \
+               python3-pytz \
+               python3-tzlocal \
+               python-unversioned-command"