From 5945e87f0f031602a6fb5eed3937401a01e6e90e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Nov 2020 14:36:05 +0100 Subject: [PATCH 01/14] [openwrt] add script to enable wifi on hp notebooks --- openwrt-add-gps.sh | 0 openwrt-add-temper.sh | 0 openwrt-hp-250-g5-add-wifi.sh | 21 +++++++++++++++++++++ 3 files changed, 21 insertions(+) mode change 100644 => 100755 openwrt-add-gps.sh mode change 100644 => 100755 openwrt-add-temper.sh create mode 100755 openwrt-hp-250-g5-add-wifi.sh diff --git a/openwrt-add-gps.sh b/openwrt-add-gps.sh old mode 100644 new mode 100755 diff --git a/openwrt-add-temper.sh b/openwrt-add-temper.sh old mode 100644 new mode 100755 diff --git a/openwrt-hp-250-g5-add-wifi.sh b/openwrt-hp-250-g5-add-wifi.sh new file mode 100755 index 0000000..adb58fb --- /dev/null +++ b/openwrt-hp-250-g5-add-wifi.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "$0 ip-address" + echo " ip-address: where to find the device" + exit 1 +fi + + +openwrt_ip=$1; shift + +ping -c3 ${openwrt_ip} +if [ $? -ne 0 ]; then + echo "Cannot reach ${openwrt_ip}, aborting" + exit 1 +fi + +cat < Date: Wed, 4 Nov 2020 14:39:32 +0100 Subject: [PATCH 02/14] also add wpa-supplicant for wpa2 support --- openwrt-hp-250-g5-add-wifi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openwrt-hp-250-g5-add-wifi.sh b/openwrt-hp-250-g5-add-wifi.sh index adb58fb..cc26bbc 100755 --- a/openwrt-hp-250-g5-add-wifi.sh +++ b/openwrt-hp-250-g5-add-wifi.sh @@ -17,5 +17,5 @@ fi cat < Date: Thu, 19 Nov 2020 19:49:00 +0100 Subject: [PATCH 03/14] [openwrt] add script to only configure the wireguard vpn --- openwrt-add-wireguard.sh | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 openwrt-add-wireguard.sh diff --git a/openwrt-add-wireguard.sh b/openwrt-add-wireguard.sh new file mode 100755 index 0000000..d44d9e9 --- /dev/null +++ b/openwrt-add-wireguard.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Nico Schottelius +# 2020-11-19 + +if [ $# -lt 4 ]; then + echo "$0 ip-address vpn-server ipv6-network [privatekey]" + echo " ip-address: where to find the OpenWRT device" + echo " vpn-server: where to connect to" + echo " vpn-server-pubkey: public key of the server" + echo " ipv6-network: which network to use for us (/48 expected)" + echo " private-key: specify wireguard key optionally" + exit 1 +fi + +my_ip=$1; shift +vpn_endpoint_host=$1; shift +vpn_endpoint_pubkey=$1; shift +network=$1; shift + +# wireguard +if [ $# -eq 1 ]; then + private_key=$1; shift +else + private_key=$(wg genkey) +fi + +my_prefix=$(echo $network | sed 's,::/.*,,') +my_wireguard_ip=${my_prefix}::42 + +public_key=$(echo $private_key | wg pubkey) + +cat < Date: Thu, 19 Nov 2020 19:49:24 +0100 Subject: [PATCH 04/14] [openwrt] camera switch to mjpg --- openwrt-add-camera.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openwrt-add-camera.sh b/openwrt-add-camera.sh index 33d5fd3..25d98a8 100755 --- a/openwrt-add-camera.sh +++ b/openwrt-add-camera.sh @@ -20,6 +20,27 @@ fi cat < Date: Thu, 19 Nov 2020 19:49:40 +0100 Subject: [PATCH 05/14] [openwrt] initial gps code --- openwrt-add-gps.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/openwrt-add-gps.sh b/openwrt-add-gps.sh index 772e1e8..ae65aa5 100755 --- a/openwrt-add-gps.sh +++ b/openwrt-add-gps.sh @@ -1,5 +1,31 @@ #!/bin/sh -opkg install kmod-usb-acm +if [ $# -lt 1 ]; then + echo "$0 ip-address" + echo " ip-address: where to find the device" + exit 1 +fi -# ugps? + +set -x + +openwrt_ip=$1; shift + +ping -c3 ${openwrt_ip} +if [ $? -ne 0 ]; then + echo "Cannot reach ${openwrt_ip}, aborting" + exit 1 +fi + +cat < Date: Mon, 30 Nov 2020 10:34:53 +0100 Subject: [PATCH 06/14] ++lte/openwrt Signed-off-by: Nico Schottelius --- openwrt-add-qmi-lte.sh | 44 ++++++++++++++++++++ openwrt-add-lte.sh => openwrt-add-usb-lte.sh | 0 2 files changed, 44 insertions(+) create mode 100755 openwrt-add-qmi-lte.sh rename openwrt-add-lte.sh => openwrt-add-usb-lte.sh (100%) diff --git a/openwrt-add-qmi-lte.sh b/openwrt-add-qmi-lte.sh new file mode 100755 index 0000000..0f4caae --- /dev/null +++ b/openwrt-add-qmi-lte.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Based on work of Samuel Hailu, 2020-09-10 + +if [ $# -ne 1 ]; then + echo "$0 ip-address interface" + echo " ip-address: where to find the OpenWRT device" + exit 1 +fi + +my_ip=$1; shift +interface=$1; shift + +cat < Date: Wed, 2 Dec 2020 13:04:08 +0100 Subject: [PATCH 07/14] ++openwrt scripts --- ...> openwrt-add-camera-with-mjpg-streamer.sh | 0 openwrt-add-camera-with-motion.sh | 52 +++++++++++++++++++ openwrt-add-jool.sh | 32 ++++++++++++ 3 files changed, 84 insertions(+) rename openwrt-add-camera.sh => openwrt-add-camera-with-mjpg-streamer.sh (100%) create mode 100755 openwrt-add-camera-with-motion.sh create mode 100644 openwrt-add-jool.sh diff --git a/openwrt-add-camera.sh b/openwrt-add-camera-with-mjpg-streamer.sh similarity index 100% rename from openwrt-add-camera.sh rename to openwrt-add-camera-with-mjpg-streamer.sh diff --git a/openwrt-add-camera-with-motion.sh b/openwrt-add-camera-with-motion.sh new file mode 100755 index 0000000..33d5fd3 --- /dev/null +++ b/openwrt-add-camera-with-motion.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "$0 ip-address" + echo " ip-address: where to find the device" + exit 1 +fi + + +set -x + +openwrt_ip=$1; shift + +ping -c3 ${openwrt_ip} +if [ $? -ne 0 ]; then + echo "Cannot reach ${openwrt_ip}, aborting" + exit 1 +fi + +cat < /etc/motion.conf < Date: Thu, 3 Dec 2020 20:03:23 +0100 Subject: [PATCH 08/14] [openwrt] update for temper support --- openwrt-add-temper.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/openwrt-add-temper.sh b/openwrt-add-temper.sh index d2ddc4d..96d6635 100755 --- a/openwrt-add-temper.sh +++ b/openwrt-add-temper.sh @@ -1,10 +1,32 @@ #!/bin/sh -opkg install kmod-usb-hid -opkg install python3-pyserial +if [ $# -ne 1 ]; then + echo "$0 ip-address" + echo " ip-address: where to find the OpenWRT device" + exit 1 +fi + +my_ip=$1; shift + + + +cat < Date: Thu, 3 Dec 2020 20:11:33 +0100 Subject: [PATCH 09/14] update temper script --- openwrt-add-temper.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openwrt-add-temper.sh b/openwrt-add-temper.sh index 96d6635..585f772 100755 --- a/openwrt-add-temper.sh +++ b/openwrt-add-temper.sh @@ -25,6 +25,10 @@ mv temper-py-0.0.1/temper.py /usr/bin rmdir temper-py-0.0.1 chmod a+rx /usr/bin/temper.py +if ! grep -q temper /etc/crontabs/root; then + echo "*/5 * * * * /usr/bin/temper.py awk '{ print $7 " " $8 }' > /www/temperature.txt" >> /etc/crontabs/root +fi + EOF exit 0 From 5914512604fa23a4257037eae2f82c3acb93e424 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 3 Dec 2020 20:12:50 +0100 Subject: [PATCH 10/14] +| --- openwrt-add-temper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openwrt-add-temper.sh b/openwrt-add-temper.sh index 585f772..3b66ac1 100755 --- a/openwrt-add-temper.sh +++ b/openwrt-add-temper.sh @@ -26,7 +26,7 @@ rmdir temper-py-0.0.1 chmod a+rx /usr/bin/temper.py if ! grep -q temper /etc/crontabs/root; then - echo "*/5 * * * * /usr/bin/temper.py awk '{ print $7 " " $8 }' > /www/temperature.txt" >> /etc/crontabs/root + echo "*/5 * * * * /usr/bin/temper.py | awk '{ print $7 " " $8 }' > /www/temperature.txt" >> /etc/crontabs/root fi EOF From 9ca5f9a96560c0451e79c41ca44d21e511d8833e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 3 Dec 2020 20:17:19 +0100 Subject: [PATCH 11/14] [openwrt] upgrade temper support to version 0.0.2 --- openwrt-add-temper.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openwrt-add-temper.sh b/openwrt-add-temper.sh index 3b66ac1..372fbcb 100755 --- a/openwrt-add-temper.sh +++ b/openwrt-add-temper.sh @@ -9,6 +9,8 @@ fi my_ip=$1; shift +temper_version=0.0.2 +temper_url=https://files.pythonhosted.org/packages/7e/1b/0579fef8482660fe194099d988a8ae82b5e5843a60070520039789b26a84/temper-py-0.0.2.tar.gz cat < Date: Thu, 3 Dec 2020 20:25:20 +0100 Subject: [PATCH 12/14] [openwrt/temper] Also restart cron --- openwrt-add-temper.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openwrt-add-temper.sh b/openwrt-add-temper.sh index 372fbcb..da44cf9 100755 --- a/openwrt-add-temper.sh +++ b/openwrt-add-temper.sh @@ -29,8 +29,10 @@ chmod a+rx /usr/bin/temper.py if ! grep -q temper /etc/crontabs/root; then echo "*/5 * * * * /usr/bin/temper.py | awk '{ print $7 " " $8 }' > /www/temperature.txt" >> /etc/crontabs/root + /etc/init.d/cron restart fi + EOF exit 0 From 568aab75e11efb917d0f71a5b17f9fc7849e1f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Mon, 7 Dec 2020 07:57:57 +0100 Subject: [PATCH 13/14] Initial devuan ONE image build script --- .../devuan-build-opennebula-image.sh | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100755 opennebula-images/devuan-build-opennebula-image.sh diff --git a/opennebula-images/devuan-build-opennebula-image.sh b/opennebula-images/devuan-build-opennebula-image.sh new file mode 100755 index 0000000..5f747b8 --- /dev/null +++ b/opennebula-images/devuan-build-opennebula-image.sh @@ -0,0 +1,163 @@ +#!/bin/sh + +# This script generates Devuan images for OpenNebula. +# +# Test image locally (without network) with: +# qemu-system-x86_64 -enable-kvm -m 1G -drive file=$IMAGE,format=qcow2 + +set -e +set -x + +# XXX: Handle command-line arguments? +RELEASE=beowulf +ARCH=amd64 +IMAGE_PATH=debian-$RELEASE-$(date --iso-8601).img.qcow2 +IMAGE_SIZE=10G +NBD_DEVICE=/dev/nbd0 +HOSTNAME=devuan +MIRROR=http://pkgmaster.devuan.org/merged + +# TODO: find the package definition and built ourself, publish in some RPM repository. +ONE_CONTEXT_DEB_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context_5.10.0-1.deb" +ONE_CONTEXT_DEB_PATH=/root/one-context.deb + +cleanup() { + # The order here is important. + umount /mnt/dev/pts 2>/dev/null || true + umount /mnt/dev/shm 2>/dev/null || true + umount /mnt/dev 2>/dev/null || true + umount /mnt/proc 2>/dev/null || true + umount /mnt/run 2>/dev/null || true + umount /mnt/sys 2>/dev/null || true + umount /mnt/boot 2>/dev/null || true + umount /mnt 2>/dev/null || true + qemu-nbd --disconnect "$NBD_DEVICE" || true +} + +run_root() { + chroot /mnt /usr/bin/env \ + PATH=/sbin:/usr/sbin:/bin:/usr/bin \ + sh -c "$*" +} + +if [ "$(whoami)" != 'root' ]; then + echo "This script must be run as root." >&2 + exit 1 +fi + +if [ $(lsb_release --short --id) != "Devuan" ]; then + echo "WARNING: this script has been designed to run on a Devuan system." >&2 + echo "WARNING: Not running Debian. Giving you 5 seconds to abort." >&2 + sleep 5 +fi + +# Create base QCOW2 image. +qemu-img create -f qcow2 "$IMAGE_PATH" "$IMAGE_SIZE" +modprobe nbd max_part=16 +qemu-nbd --connect="$NBD_DEVICE" "$IMAGE_PATH" + +# Wait for qemu-nbd to settle. +sleep 1 + +# Don't forget to cleanup, even if the script crash. +trap cleanup EXIT + +# Create partition table, format partitions. +sfdisk --no-reread "$NBD_DEVICE" < /mnt/etc/hosts << EOF +127.0.0.1 $HOSTNAME localhost localhost.localdomain localhost4 localhost4.localdomain4 +::1 $HOSTNAME localhost localhost.localdomain localhost6 localhost6.localdomain6 + +EOF + +run_root hostname $HOSTNAME + +# Configure package sources and update package index. +cat >/mnt/etc/apt/sources.list < "/mnt$ONE_CONTEXT_DEB_PATH" +run_root apt-get -y install "$ONE_CONTEXT_DEB_PATH" +run_root rm "$ONE_CONTEXT_DEB_PATH" + +# Manually install legacy network scripts used by one-context. +run_root apt-get -y install ifupdown + +run_root ln -sf /usr/share/zoneinfo/UTC /etc/localtime + +# Install kernel and bootloader. Do not autoconfigure grub. +run_root 'echo "grub-pc grub-pc/install_devices_empty boolean true" | debconf-set-selections' +run_root DEBIAN_FRONTEND=noninteractive apt-get -y install locales linux-image-amd64 grub-pc + +# Configure grub. +run_root grub-install --target=i386-pc "${NBD_DEVICE}" +run_root grub-mkconfig -o /boot/grub/grub.cfg + +# Install en configure SSH daemon. +run_root apt-get -y install openssh-server + +# Install haveged due to lack of entropy in ONE environment. +run_root apt-get -y install haveged +run_root update-rc.d haveged defaults + +# Generate locales. +run_root 'sed -i "s/^# *\(en_GB.UTF-8\)/\1/" etc/locale.gen' +run_root locale-gen + +# Generate fstab file. +boot_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p1") +root_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p2") +cat >>/mnt/etc/fstab < Date: Mon, 7 Dec 2020 08:40:01 +0100 Subject: [PATCH 14/14] Fix devuan IMAGE_PATH output --- opennebula-images/devuan-build-opennebula-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opennebula-images/devuan-build-opennebula-image.sh b/opennebula-images/devuan-build-opennebula-image.sh index 5f747b8..ab9b598 100755 --- a/opennebula-images/devuan-build-opennebula-image.sh +++ b/opennebula-images/devuan-build-opennebula-image.sh @@ -11,7 +11,7 @@ set -x # XXX: Handle command-line arguments? RELEASE=beowulf ARCH=amd64 -IMAGE_PATH=debian-$RELEASE-$(date --iso-8601).img.qcow2 +IMAGE_PATH=devuan-$RELEASE-$(date --iso-8601).img.qcow2 IMAGE_SIZE=10G NBD_DEVICE=/dev/nbd0 HOSTNAME=devuan