From 529e7cd54c4dbb49ee670cb2eb5ed340e8c23bac Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Wed, 7 Apr 2021 13:02:07 +0000 Subject: [PATCH 01/17] added ne defconfig --- configs/nonlinear_wifi_usbrescue_defconfig | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 configs/nonlinear_wifi_usbrescue_defconfig diff --git a/configs/nonlinear_wifi_usbrescue_defconfig b/configs/nonlinear_wifi_usbrescue_defconfig new file mode 100644 index 0000000000..832e8907a8 --- /dev/null +++ b/configs/nonlinear_wifi_usbrescue_defconfig @@ -0,0 +1,88 @@ +BR2_arm=y +BR2_cortex_a8=y +BR2_PRIMARY_SITE="http://sources.buildroot.net" +BR2_CCACHE=y +BR2_OPTIMIZE_3=y +BR2_KERNEL_HEADERS_4_4=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_GLIBC_VERSION_2_23=y +BR2_GCC_VERSION_5_X=y +BR2_EXTRA_GCC_CONFIG_OPTIONS="--with-fpu=vfpv3 --with-float=hard" +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_GENERATE_LOCALE="en_US" +BR2_TARGET_GENERIC_HOSTNAME="nonlinux" +BR2_TARGET_GENERIC_ISSUE="Nonlinux by Nonlinear-Labs" +BR2_INIT_SYSTEMD=y +BR2_SYSTEM_BIN_SH_BASH=y +BR2_ROOTFS_OVERLAY="nonlinear/fs-overlay-usbrescue" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/nonlinear-labs-dev/linux.git" +BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="nonlinear-am33xx-4.4.50" +BR2_LINUX_KERNEL_DEFCONFIG="nonlinear" +BR2_LINUX_KERNEL_UIMAGE=y +BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x80008000" +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_INTREE_DTS_NAME="am335x-boneblack" +BR2_PACKAGE_BUSYBOX_SELINUX=y +BR2_PACKAGE_BZIP2=y +BR2_PACKAGE_LINUX_FIRMWARE=y +BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT61=y +BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT73=y +BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y +BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y +BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y +BR2_PACKAGE_AVRDUDE=y +BR2_PACKAGE_FREETYPE=y +BR2_PACKAGE_DTC=y +BR2_PACKAGE_DTC_PROGRAMS=y +BR2_PACKAGE_TSLIB=y +BR2_PACKAGE_LIBSOUP=y +BR2_PACKAGE_LIBSOUP_SSL=y +BR2_PACKAGE_GLIBMM=y +BR2_PACKAGE_NCURSES_TARGET_PANEL=y +BR2_PACKAGE_NCURSES_TARGET_FORM=y +BR2_PACKAGE_NCURSES_TARGET_MENU=y +BR2_PACKAGE_DHCP=y +BR2_PACKAGE_DHCP_SERVER=y +BR2_PACKAGE_HOSTAPD=y +BR2_PACKAGE_HOSTAPD_EAP=y +BR2_PACKAGE_HOSTAPD_WPS=y +BR2_PACKAGE_IW=y +BR2_PACKAGE_NETWORK_MANAGER=y +BR2_PACKAGE_OPENSSH=y +BR2_PACKAGE_RSYNC=y +BR2_PACKAGE_SOCAT=y +BR2_PACKAGE_SSHPASS=y +BR2_PACKAGE_THTTPD=y +BR2_PACKAGE_WPA_SUPPLICANT=y +BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y +BR2_PACKAGE_WPA_SUPPLICANT_EAP=y +BR2_PACKAGE_WPA_SUPPLICANT_HOTSPOT=y +BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG=y +BR2_PACKAGE_WPA_SUPPLICANT_WPS=y +BR2_PACKAGE_WPA_SUPPLICANT_CLI=y +BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y +BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y +BR2_PACKAGE_WPA_SUPPLICANT_DBUS_OLD=y +BR2_PACKAGE_WPA_SUPPLICANT_DBUS_NEW=y +BR2_PACKAGE_WPA_SUPPLICANT_DBUS_INTROSPECTION=y +BR2_PACKAGE_UTIL_LINUX_LOGIN_UTILS=y +BR2_PACKAGE_ESPI_DRIVER=y +BR2_PACKAGE_PLAYCONTROLLER_DRIVER=y +BR2_PACKAGE_MXLI=y +BR2_PACKAGE_NLIMAGEMAKER=y +BR2_TARGET_ROOTFS_INITRAMFS=y +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y +BR2_TARGET_UBOOT_CUSTOM_GIT=y +BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/nonlinear-labs-dev/u-boot.git" +BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="nonlinear_v2016.11" +BR2_TARGET_UBOOT_BOARD_DEFCONFIG="nonlinear" +BR2_TARGET_UBOOT_FORMAT_IMG=y +BR2_TARGET_UBOOT_SPL=y +BR2_TARGET_UBOOT_SPL_NAME="MLO" +BR2_PACKAGE_HOST_DTC=y +BR2_PACKAGE_HOST_MKE2IMG=y +BR2_PACKAGE_HOST_UBOOT_TOOLS=y +BR2_PACKAGE_HOST_UTIL_LINUX=y From 6edcd70421961f4eb5f4e77aa583a44a8a5f22d6 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Wed, 7 Apr 2021 14:04:27 +0000 Subject: [PATCH 02/17] copied fs-overlays --- .../etc/dhcpd-usbnet.conf | 11 ++ .../fs-overlay-usbrescue/etc/dhcpd-wlan.conf | 11 ++ nonlinear/fs-overlay-usbrescue/etc/fstab | 9 ++ .../fs-overlay-usbrescue/etc/hostapd.conf | 10 ++ .../etc/init.d/S50setup_nonlinear | 32 ----- nonlinear/fs-overlay-usbrescue/etc/inittab | 38 ------ .../etc/modules-load.d/espi_driver.conf | 2 + .../etc/modules-load.d/lpc_bb_driver.conf | 2 + .../etc/network/interfaces | 8 ++ .../fs-overlay-usbrescue/etc/ssh/sshd_config | 124 ++++++++++++++++++ .../etc/systemd/journald.conf | 35 +++++ .../etc/systemd/system/accesspoint.service | 9 ++ .../etc/systemd/system/dhcpd-usbnet.service | 10 ++ .../etc/systemd/system/dhcpd-wlan.service | 12 ++ .../redirect-to-epc.service | 1 + .../multi-user.target.wants/sshd.service | 1 + .../systemd/system/redirect-to-epc.service | 13 ++ .../etc/systemd/system/sshd.service | 11 ++ .../etc/systemd/system/usbnet.service | 11 ++ .../etc/udev/rules.d/100-accesspoint.rules | 2 + .../etc/udev/rules.d/100-gether.rules | 1 + .../etc/udev/rules.d/100-usbnet.rules | 2 + .../root/.ssh/authorized_keys | 2 + nonlinear/fs-overlay-usbrescue/root/uEnv.txt | 3 + .../usr/bin/install_to_emmc.sh | 16 +++ .../fs-overlay-usbrescue/usr/bin/setup.sh | 106 --------------- .../lib/systemd/system/remount-rootfs.service | 19 +++ nonlinear/fs-overlay-usbrescue/var/log/anker | 1 + 28 files changed, 326 insertions(+), 176 deletions(-) create mode 100644 nonlinear/fs-overlay-usbrescue/etc/dhcpd-usbnet.conf create mode 100644 nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf create mode 100644 nonlinear/fs-overlay-usbrescue/etc/fstab create mode 100644 nonlinear/fs-overlay-usbrescue/etc/hostapd.conf delete mode 100755 nonlinear/fs-overlay-usbrescue/etc/init.d/S50setup_nonlinear delete mode 100644 nonlinear/fs-overlay-usbrescue/etc/inittab create mode 100644 nonlinear/fs-overlay-usbrescue/etc/modules-load.d/espi_driver.conf create mode 100644 nonlinear/fs-overlay-usbrescue/etc/modules-load.d/lpc_bb_driver.conf create mode 100644 nonlinear/fs-overlay-usbrescue/etc/network/interfaces create mode 100644 nonlinear/fs-overlay-usbrescue/etc/ssh/sshd_config create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/journald.conf create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-usbnet.service create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service create mode 120000 nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service create mode 120000 nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/sshd.service create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/redirect-to-epc.service create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/sshd.service create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/usbnet.service create mode 100644 nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules create mode 100644 nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-gether.rules create mode 100644 nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-usbnet.rules create mode 100644 nonlinear/fs-overlay-usbrescue/root/.ssh/authorized_keys create mode 100755 nonlinear/fs-overlay-usbrescue/root/uEnv.txt create mode 100755 nonlinear/fs-overlay-usbrescue/usr/bin/install_to_emmc.sh delete mode 100755 nonlinear/fs-overlay-usbrescue/usr/bin/setup.sh create mode 100644 nonlinear/fs-overlay-usbrescue/usr/lib/systemd/system/remount-rootfs.service create mode 100644 nonlinear/fs-overlay-usbrescue/var/log/anker diff --git a/nonlinear/fs-overlay-usbrescue/etc/dhcpd-usbnet.conf b/nonlinear/fs-overlay-usbrescue/etc/dhcpd-usbnet.conf new file mode 100644 index 0000000000..4e5600fe4d --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/dhcpd-usbnet.conf @@ -0,0 +1,11 @@ +default-lease-time 600; +max-lease-time 7200; +option domain-name "nonlinear-labs.de"; +option broadcast-address 192.168.7.3; +option subnet-mask 255.255.255.252; + +subnet 192.168.7.0 netmask 255.255.255.252 + { + range 192.168.7.1 192.168.7.1; + } + diff --git a/nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf b/nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf new file mode 100644 index 0000000000..b8609e8942 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf @@ -0,0 +1,11 @@ +default-lease-time 600; +max-lease-time 7200; +option domain-name "nonlinear-labs.de"; +option broadcast-address 192.168.8.31; +option subnet-mask 255.255.255.224; + +subnet 192.168.8.0 netmask 255.255.255.224 + { + range 192.168.8.3 192.168.8.30; + } + diff --git a/nonlinear/fs-overlay-usbrescue/etc/fstab b/nonlinear/fs-overlay-usbrescue/etc/fstab new file mode 100644 index 0000000000..c9df47d8a1 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/fstab @@ -0,0 +1,9 @@ +# +/dev/root / ext2 rw,noauto 0 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 +tmpfs /dev/shm tmpfs mode=0777 0 0 +tmpfs /tmp tmpfs mode=1777 0 0 +tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 +sysfs /sys sysfs defaults 0 0 +/dev/sda1 /mnt/usb-stick auto rw,auto,nofail,user,umask=0000 0 0 diff --git a/nonlinear/fs-overlay-usbrescue/etc/hostapd.conf b/nonlinear/fs-overlay-usbrescue/etc/hostapd.conf new file mode 100644 index 0000000000..ee9a6aa710 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/hostapd.conf @@ -0,0 +1,10 @@ +ssid=NonLinearInstrument +interface=wlan0 +channel=7 +hw_mode=g +wpa_passphrase=88888888 +wpa=2 +rsn_preauth=1 +rsn_preauth_interfaces=wlan0 +wpa_key_mgmt=WPA-PSK +rsn_pairwise=CCMP diff --git a/nonlinear/fs-overlay-usbrescue/etc/init.d/S50setup_nonlinear b/nonlinear/fs-overlay-usbrescue/etc/init.d/S50setup_nonlinear deleted file mode 100755 index cec9239140..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/init.d/S50setup_nonlinear +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# Setup Nonlinear Labs Ecosystem -# - -start() { - printf "Setup Nonlinear Labs Ecosystem...." - /usr/bin/setup.sh -} - - -stop() { - printf "Setup Nonlinear Labs Ecosystem....Done" -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac - -exit $? diff --git a/nonlinear/fs-overlay-usbrescue/etc/inittab b/nonlinear/fs-overlay-usbrescue/etc/inittab deleted file mode 100644 index 43bacc6580..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/inittab +++ /dev/null @@ -1,38 +0,0 @@ -# /etc/inittab -# -# Copyright (C) 2001 Erik Andersen -# -# Note: BusyBox init doesn't support runlevels. The runlevels field is -# completely ignored by BusyBox init. If you want runlevels, use -# sysvinit. -# -# Format for each entry: ::: -# -# id == tty to run on, or empty for /dev/console -# runlevels == ignored -# action == one of sysinit, respawn, askfirst, wait, and once -# process == program to run - -# Startup the system -null::sysinit:/bin/mount -t proc proc /proc -null::sysinit:/bin/mount -o remount,rw / -null::sysinit:/bin/mkdir -p /dev/pts -null::sysinit:/bin/mkdir -p /dev/shm -null::sysinit:/bin/mount -a -null::sysinit:/bin/hostname -F /etc/hostname -# now run any rc scripts -::sysinit:/etc/init.d/rcS - -# /sbin/getty invocation for tty0 -tty0::respawn:/sbin/getty 115200 tty0 - -# Put a getty on the serial port -console::respawn:/sbin/getty -L console 0 vt100 - -# Stuff to do for the 3-finger salute -::ctrlaltdel:/sbin/reboot - -# Stuff to do before rebooting -::shutdown:/etc/init.d/rcK -::shutdown:/sbin/swapoff -a -::shutdown:/bin/umount -a -r diff --git a/nonlinear/fs-overlay-usbrescue/etc/modules-load.d/espi_driver.conf b/nonlinear/fs-overlay-usbrescue/etc/modules-load.d/espi_driver.conf new file mode 100644 index 0000000000..f7f5386703 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/modules-load.d/espi_driver.conf @@ -0,0 +1,2 @@ +# Load NonlinearLabs espi_driver.ko for emphase devices at boot +espi_driver diff --git a/nonlinear/fs-overlay-usbrescue/etc/modules-load.d/lpc_bb_driver.conf b/nonlinear/fs-overlay-usbrescue/etc/modules-load.d/lpc_bb_driver.conf new file mode 100644 index 0000000000..7a5b9610bd --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/modules-load.d/lpc_bb_driver.conf @@ -0,0 +1,2 @@ +# Load NonlinearLabs lpc_bb_driver.ko for emphase devices at boot +lpc_bb_driver diff --git a/nonlinear/fs-overlay-usbrescue/etc/network/interfaces b/nonlinear/fs-overlay-usbrescue/etc/network/interfaces new file mode 100644 index 0000000000..5a3ce71b6e --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/network/interfaces @@ -0,0 +1,8 @@ +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet static + address 192.168.10.11 + netmask 255.255.255.0 + diff --git a/nonlinear/fs-overlay-usbrescue/etc/ssh/sshd_config b/nonlinear/fs-overlay-usbrescue/etc/ssh/sshd_config new file mode 100644 index 0000000000..c4a3f5acd9 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/ssh/sshd_config @@ -0,0 +1,124 @@ +# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ + +# This is the sshd server system-wide configuration file. See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin + +# The strategy used for options in the default sshd_config shipped with +# OpenSSH is to specify options with their default value where +# possible, but leave them commented. Uncommented options change a +# default value. + +#Port 22 +#AddressFamily any +#ListenAddress 0.0.0.0 +#ListenAddress :: + +# Disable legacy (protocol version 1) support in the server for new +# installations. In future the default will change to require explicit +# activation of protocol 1 +Protocol 2 + +# HostKey for protocol version 1 +#HostKey /etc/ssh_host_key +# HostKeys for protocol version 2 +#HostKey /etc/ssh_host_rsa_key +#HostKey /etc/ssh_host_dsa_key + +# Lifetime and size of ephemeral version 1 server key +#KeyRegenerationInterval 1h +#ServerKeyBits 1024 + +# Logging +# obsoletes QuietMode and FascistLogging +#SyslogFacility AUTH +#LogLevel INFO + +# Authentication: + +#LoginGraceTime 2m +PermitRootLogin yes +#StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 + +#RSAAuthentication yes +#PubkeyAuthentication yes +AuthorizedKeysFile .ssh/authorized_keys + +# For this to work you will also need host keys in /etc/ssh_known_hosts +#RhostsRSAAuthentication no +# similar for protocol version 2 +#HostbasedAuthentication no +# Change to yes if you don't trust ~/.ssh/known_hosts for +# RhostsRSAAuthentication and HostbasedAuthentication +#IgnoreUserKnownHosts no +# Don't read the user's ~/.rhosts and ~/.shosts files +#IgnoreRhosts yes + +# To disable tunneled clear text passwords, change to no here! +#PasswordAuthentication yes +PermitEmptyPasswords yes + +# Change to no to disable s/key passwords +#ChallengeResponseAuthentication yes + +# Kerberos options +#KerberosAuthentication no +#KerberosOrLocalPasswd yes +#KerberosTicketCleanup yes +#KerberosGetAFSToken no + +# GSSAPI options +#GSSAPIAuthentication no +#GSSAPICleanupCredentials yes + +# Set this to 'yes' to enable PAM authentication, account processing, +# and session processing. If this is enabled, PAM authentication will +# be allowed through the ChallengeResponseAuthentication and +# PasswordAuthentication. Depending on your PAM configuration, +# PAM authentication via ChallengeResponseAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# PAM authentication, then enable this but set PasswordAuthentication +# and ChallengeResponseAuthentication to 'no'. +#UsePAM no + +#AllowAgentForwarding yes +#AllowTcpForwarding yes +#GatewayPorts no +X11Forwarding no +#X11DisplayOffset 10 +#X11UseLocalhost yes +#PrintMotd yes +PrintMotd no +#PrintLastLog yes +#TCPKeepAlive yes +#UseLogin no +#UsePrivilegeSeparation yes +#PermitUserEnvironment no +#Compression delayed +#ClientAliveInterval 0 +#ClientAliveCountMax 3 +UseDNS no +#PidFile /var/run/sshd.pid +#MaxStartups 10 +#PermitTunnel no +#ChrootDirectory none + +# no default banner path +#Banner none + +ClientAliveInterval 15 +ClientAliveCountMax 4 +AcceptEnv LANG LC_* + +# override default of no subsystems +Subsystem sftp /usr/libexec/sftp-server + +# Example of overriding settings on a per-user basis +#Match User anoncvs +# X11Forwarding no +# AllowTcpForwarding no +# ForceCommand cvs server diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/journald.conf b/nonlinear/fs-overlay-usbrescue/etc/systemd/journald.conf new file mode 100644 index 0000000000..eae6ec1268 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/journald.conf @@ -0,0 +1,35 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# See journald.conf(5) for details + +[Journal] +Storage=persistent +#Compress=yes +#Seal=yes +#SplitMode=uid +#SyncIntervalSec=5m +#RateLimitInterval=30s +#RateLimitBurst=1000 +#SystemMaxUse= +#SystemKeepFree= +#SystemMaxFileSize= +#RuntimeMaxUse= +#RuntimeKeepFree= +#RuntimeMaxFileSize= +#MaxRetentionSec= +#MaxFileSec=1month +#ForwardToSyslog=no +#ForwardToKMsg=no +#ForwardToConsole=no +#ForwardToWall=yes +#TTYPath=/dev/console +#MaxLevelStore=debug +#MaxLevelSyslog=debug +#MaxLevelKMsg=notice +#MaxLevelConsole=info +#MaxLevelWall=emerg diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service new file mode 100644 index 0000000000..25e5f3063a --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service @@ -0,0 +1,9 @@ +[Unit] +Description=AccessPoint daemon +After=syslog.target network.target + +[Service] +ExecStart=/usr/sbin/hostapd /etc/hostapd.conf + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-usbnet.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-usbnet.service new file mode 100644 index 0000000000..c0fb29900d --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-usbnet.service @@ -0,0 +1,10 @@ +[Unit] +Description=DHCP Server for usbnet +After=syslog.target network.target + +[Service] +ExecStartPre=/bin/touch /tmp/dhcpd-usbnet.leases +ExecStart=/usr/sbin/dhcpd -d -q -cf /etc/dhcpd-usbnet.conf -lf /tmp/dhcpd-usbnet.leases -pf /tmp/usbnet.pid usb0 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service new file mode 100644 index 0000000000..543ac49cef --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service @@ -0,0 +1,12 @@ +[Unit] +Description=DHCP Server for wlan +After=syslog.target network.target + +[Service] +ExecStartPre=/bin/touch /tmp/dhcpd-wlan.leases +ExecStart=/usr/sbin/dhcpd -d -q -cf /etc/dhcpd-wlan.conf -lf /tmp/dhcpd-wlan.leases -pf /tmp/wlan.pid wlan0 +Restart=on-failure +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service new file mode 120000 index 0000000000..57001c5d59 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/redirect-to-epc.service @@ -0,0 +1 @@ +nonlinear/fs-overlay/etc/systemd/system/redirect-to-epc.service \ No newline at end of file diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/sshd.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/sshd.service new file mode 120000 index 0000000000..d41264ec26 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/sshd.service @@ -0,0 +1 @@ +../sshd.service \ No newline at end of file diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/redirect-to-epc.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/redirect-to-epc.service new file mode 100644 index 0000000000..c9fc602f4d --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/redirect-to-epc.service @@ -0,0 +1,13 @@ +[Unit] +Description=Redirect all incoming http traffic to ePC +After=syslog.target network.target + +[Service] +ExecStart=/bin/socat TCP-LISTEN:80,fork TCP:192.168.10.10:80 +Restart=always +RestartSec=1 +StartLimitInterval=200 +StartLimitBurst=5 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/sshd.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/sshd.service new file mode 100644 index 0000000000..b5e96b3a25 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/sshd.service @@ -0,0 +1,11 @@ +[Unit] +Description=OpenSSH server daemon +After=syslog.target network.target auditd.service + +[Service] +ExecStartPre=/usr/bin/ssh-keygen -A +ExecStart=/usr/sbin/sshd -D -e +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/usbnet.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/usbnet.service new file mode 100644 index 0000000000..6c79a07785 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/usbnet.service @@ -0,0 +1,11 @@ +[Unit] +Description=Load Ethernet over USB module +After=syslog.target network.target + +[Service] +Type=idle +ExecStart=/sbin/modprobe g_ether +TimeoutStartSec=30 + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules new file mode 100644 index 0000000000..cb7c0369a6 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="net",ACTION=="add",KERNEL=="wlan0",RUN+="/sbin/ifconfig wlan0 192.168.8.2 netmask 255.255.255.224",RUN+="/bin/systemctl start accesspoint.service",RUN+="/bin/systemctl start dhcpd-wlan.service" +SUBSYSTEM=="net",ACTION=="remove",KERNEL=="wlan0",RUN+="/bin/systemctl stop accesspoint.service",RUN+="/bin/systemctl stop dhcpd-wlan.service" diff --git a/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-gether.rules b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-gether.rules new file mode 100644 index 0000000000..ee5521d0be --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-gether.rules @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", ATTR{idProduct}=="0002", ACTION=="add", RUN+="/bin/systemctl start usbnet.service" diff --git a/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-usbnet.rules b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-usbnet.rules new file mode 100644 index 0000000000..b5f3dc9d39 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-usbnet.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="net",ACTION=="add",KERNEL=="usb0",RUN+="/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252",RUN+="/bin/systemctl start dhcpd-usbnet.service" +SUBSYSTEM=="net",ACTION=="remove",KERNEL=="usb0",RUN+="/bin/systemctl stop dhcpd.service" diff --git a/nonlinear/fs-overlay-usbrescue/root/.ssh/authorized_keys b/nonlinear/fs-overlay-usbrescue/root/.ssh/authorized_keys new file mode 100644 index 0000000000..3c128beb2c --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/root/.ssh/authorized_keys @@ -0,0 +1,2 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlxMKSV0nN1BR5kbfCjzgWcBP/737m2/zWUN39A/w2ye8C/IC0n20KgfuqtURj9wH2e40OZ/9DHz0r5vfmuUtr4NPtsmclOSXHMVKJrVySgXEnDyoKZYjQm4jU+j0jeNb3PQLiwqjuX8zxmMB4NuTSIHlI6bqh96kg18X7gD+Oxm5krIT+bRlA1YHkxjsohC5KEQ70O9TNp/waIdz713e+iSAfJ3MlrCcefDpLag10K2cncuzNqregW0LcIQ7e7I7EYbRnoTwb80YuFyc/Ru60KVoFjEAJAsJ9AQoRAQaq0vr9KCcnA0t5GKvegZBpD+9IXf0pvxdqJ1x67VCiAisHQ== hhoegelo@hho +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5Zf7MemvmDPZBXCt3NS52PCV1+cUK4Fkcuya56peiPNgjx8ZSc6zh5FJCfpI6VwwYO7ZxMqBbXf1rLfJagcYOwhwFrq/9F3VZzGmLBR5Rzv4vCnaYBxoWCThn8DB3VeRX3WCdxcDndwfLDB3DkLXdiF+FVTgLrtwPoCUJlntcsCRiJGeQbBKHgSKKeNLkB6WRQF3PPFb6WKCewsnk81hLwyDJOVW5gb2sQHtNUi+PZJbP6X+33Z5o0hX20kelWkh7I61EQdzbxhny+kj/RpnFMcM2JR5jYDlVwGbxWY/MzN4xGwo5CZQx/3M9mQcmRq2pMrjj/+5puSFYM5WFOy07 billserver@localhost.localdomain diff --git a/nonlinear/fs-overlay-usbrescue/root/uEnv.txt b/nonlinear/fs-overlay-usbrescue/root/uEnv.txt new file mode 100755 index 0000000000..6d6135fa5b --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/root/uEnv.txt @@ -0,0 +1,3 @@ +uenvcmd=mmc rescan; load mmc 1:2 ${loadaddr} boot/uImage; load mmc 1:2 ${fdtaddr} boot/nonlinear-labs-2D.dtb; setenv mmcroot /dev/mmcblk0p2 ro; setenv mmcrootfstype ext4 rootwait; setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}; bootm ${loadaddr} - ${fdtaddr} +uname_r=nonlinear +uname_boot=mmc rescan; load mmc 1:2 ${loadaddr} boot/uImage; load mmc 1:2 ${fdtaddr} boot/nonlinear-labs-2D.dtb; setenv mmcroot /dev/mmcblk0p2 ro; setenv mmcrootfstype ext4 rootwait; setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}; bootm ${loadaddr} - ${fdtaddr} diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/install_to_emmc.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/install_to_emmc.sh new file mode 100755 index 0000000000..ee602025ba --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/install_to_emmc.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +systemctl stop playground +umount /internalstorage +mkfs.ext3 -F /dev/mmcblk1p2 +mkdir -p /tmp/rootfs +mount /dev/mmcblk1p2 /tmp/rootfs +tar -C /tmp/rootfs -xf /rootfs.tar +rm /tmp/rootfs/etc/systemd/system/internalstorage.mount +cp /tmp/rootfs/boot/nonlinear-labs-2D.dtb /tmp/rootfs/boot/am335x-boneblack.dtb +cp /tmp/rootfs/boot/nonlinear-labs-2D.dtb /tmp/rootfs/boot/ + +cp /root/uEnv.txt /tmp/rootfs/boot/uEnv.txt + + +sync diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/setup.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/setup.sh deleted file mode 100755 index b849809ebb..0000000000 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/setup.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -COUNT=0 - -row_on() { - R0=$1 - R1=$((R0*4)) - R2=$((R1+1)) - R3=$((R2+1)) - R4=$((R3+1)) - led_on $R1 - led_on $R2 - led_on $R3 - led_on $R4 -} - -row_off() { - R0=$1 - R1=$((R0*4)) - R2=$((R1+1)) - R3=$((R2+1)) - R4=$((R3+1)) - led_off $R1 - led_off $R2 - led_off $R3 - led_off $R4 -} - - -led_on() { - ADDR=$1 - R=$((ADDR+128)); T=$(printf "\\x%x" "$R"); echo -e $T > /dev/espi_led -} - -led_off() { - ADDR=$1 - R=$((ADDR+0)); T=$(printf "\\x%x" "$R"); echo -e $T > /dev/espi_led -} - -inc_progress() { - row_on $COUNT - COUNT=$((COUNT+1)) -} - -mount_stick() { - mounted=false - - while [ "$mounted" = false ]; do - - if (lsblk | grep sda); then - echo "Found /dev/sda1. Mounting to /media" - mount /dev/sda1 /media || mount /dev/sda /media - mounted=true; - else - echo "Waiting for /dev/sda1 to appear..." - sleep 1 - fi - done -} - -mount_stick -echo "this is a test!" >> /media/message.txt -exit - - - -modprobe espi_driver -inc_progress - -echo -e ',50M,c,*,,700M,83,,,,83\n' > sfdisk -f /dev/mmcblk0 -inc_progress -mkfs.fat /dev/mmcblk0p1 -inc_progress -mkfs.ext4 -L rootfs /dev/mmcblk0p2 -inc_progress -mkfs.ext4 -L data /dev/mmcblk0p3 -inc_progress - -mkdir -p /mnt/stick -mkdir -p /mnt/boot -mkdir -p /mnt/data -mkdir -p /mnt/rootfs -inc_progress - -mount /dev/sda1 /mnt/stick -mount /dev/mmcblk0p1 /mnt/boot -mount /dev/mmcblk0p2 /mnt/rootfs -mount /dev/mmcblk0p3 /mnt/data -inc_progress - -gunzip -c /mnt/stick/rootfs.tar.gz | tar -C /mnt/rootfs/ -xvf - -sync -inc_progress - -cp /mnt/stick/u-boot.img /mnt/boot -cp /mnt/stick/MLO /mnt/boot -sync -inc_progress - -umount /dev/sda1 -umount /dev/mmcblk0p1 -umount /dev/mmcblk0p2 -umount /dev/mmcblk0p3 -inc_progress - - diff --git a/nonlinear/fs-overlay-usbrescue/usr/lib/systemd/system/remount-rootfs.service b/nonlinear/fs-overlay-usbrescue/usr/lib/systemd/system/remount-rootfs.service new file mode 100644 index 0000000000..fe01c4fe98 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/usr/lib/systemd/system/remount-rootfs.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Remount Root FS +DefaultDependencies=no +Conflicts=shutdown.target +After=systemd-readahead-collect.service systemd-readahead-replay.service fsck-root.service +Before=local-fs-pre.target local-fs.target shutdown.target +Wants=local-fs-pre.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/mount -o remount,rw / diff --git a/nonlinear/fs-overlay-usbrescue/var/log/anker b/nonlinear/fs-overlay-usbrescue/var/log/anker new file mode 100644 index 0000000000..81c2bde2bf --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/var/log/anker @@ -0,0 +1 @@ +This file is just here, so the fs-overlay replaces the symlink for /var/log in order to get persistent logging From 168977220b2b6638bfead2a4d8296b415b48ccb9 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Wed, 7 Apr 2021 14:13:47 +0000 Subject: [PATCH 03/17] deleted wifi host services and files --- nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf | 11 ----------- nonlinear/fs-overlay-usbrescue/etc/hostapd.conf | 10 ---------- .../etc/systemd/system/accesspoint.service | 9 --------- .../etc/systemd/system/dhcpd-wlan.service | 12 ------------ 4 files changed, 42 deletions(-) delete mode 100644 nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf delete mode 100644 nonlinear/fs-overlay-usbrescue/etc/hostapd.conf delete mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service delete mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service diff --git a/nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf b/nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf deleted file mode 100644 index b8609e8942..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/dhcpd-wlan.conf +++ /dev/null @@ -1,11 +0,0 @@ -default-lease-time 600; -max-lease-time 7200; -option domain-name "nonlinear-labs.de"; -option broadcast-address 192.168.8.31; -option subnet-mask 255.255.255.224; - -subnet 192.168.8.0 netmask 255.255.255.224 - { - range 192.168.8.3 192.168.8.30; - } - diff --git a/nonlinear/fs-overlay-usbrescue/etc/hostapd.conf b/nonlinear/fs-overlay-usbrescue/etc/hostapd.conf deleted file mode 100644 index ee9a6aa710..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/hostapd.conf +++ /dev/null @@ -1,10 +0,0 @@ -ssid=NonLinearInstrument -interface=wlan0 -channel=7 -hw_mode=g -wpa_passphrase=88888888 -wpa=2 -rsn_preauth=1 -rsn_preauth_interfaces=wlan0 -wpa_key_mgmt=WPA-PSK -rsn_pairwise=CCMP diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service deleted file mode 100644 index 25e5f3063a..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/accesspoint.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=AccessPoint daemon -After=syslog.target network.target - -[Service] -ExecStart=/usr/sbin/hostapd /etc/hostapd.conf - -[Install] -WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service deleted file mode 100644 index 543ac49cef..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/dhcpd-wlan.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=DHCP Server for wlan -After=syslog.target network.target - -[Service] -ExecStartPre=/bin/touch /tmp/dhcpd-wlan.leases -ExecStart=/usr/sbin/dhcpd -d -q -cf /etc/dhcpd-wlan.conf -lf /tmp/dhcpd-wlan.leases -pf /tmp/wlan.pid wlan0 -Restart=on-failure -RestartSec=3 - -[Install] -WantedBy=multi-user.target From 9b1391cde32c8fbaa37bceb3b4ac781882cfdda5 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Wed, 7 Apr 2021 14:27:32 +0000 Subject: [PATCH 04/17] removed more files --- .../fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules diff --git a/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules b/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules deleted file mode 100644 index cb7c0369a6..0000000000 --- a/nonlinear/fs-overlay-usbrescue/etc/udev/rules.d/100-accesspoint.rules +++ /dev/null @@ -1,2 +0,0 @@ -SUBSYSTEM=="net",ACTION=="add",KERNEL=="wlan0",RUN+="/sbin/ifconfig wlan0 192.168.8.2 netmask 255.255.255.224",RUN+="/bin/systemctl start accesspoint.service",RUN+="/bin/systemctl start dhcpd-wlan.service" -SUBSYSTEM=="net",ACTION=="remove",KERNEL=="wlan0",RUN+="/bin/systemctl stop accesspoint.service",RUN+="/bin/systemctl stop dhcpd-wlan.service" From ecdbba033c50607d7de8747adf927598de27b0a2 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Thu, 8 Apr 2021 09:41:04 +0000 Subject: [PATCH 05/17] added service and script --- .../system/connect-to-nllserver.service | 9 +++ .../usr/bin/connect-to-nllserver.sh | 55 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service create mode 100644 nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service new file mode 100644 index 0000000000..dcf5619c5b --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service @@ -0,0 +1,9 @@ +[Unit] +Description=Runs the script to ceonnect to NLL server for maintenance purposes +After=NetworkManager.service + +[Service] +ExecStart=/usr/bin/connect-to-nllserver.sh + +[Install] +WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh new file mode 100644 index 0000000000..0b4a1946fa --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +mount_stick() { + if ( ! ls -l /dev/ | grep sda ); then + echo "Missing USB device!" + exit + fi + + mounted=false + + while [ "$mounted" = false ]; do + + if (lsblk | grep sda); then + echo "Found /dev/sda1. Mounting to /media" + mount /dev/sda1 /media || mount /dev/sda /media + mounted=true; + else + echo "Waiting for /dev/sda to appear..." + sleep 1 + fi + done +} + +connect_with_network() { + [ ! -e /media/access.txt ] && { echo "Access file missing!"; return 1; } + SSID=$(cat /media/access.txt | grep SSID sed 's/.*://') + PWD=$(cat /media/access.txt | grep PASSWORD sed 's/.*://') + + if ( ! systemctl status NetworkManager ); then + echo "Network Manager dead!" + return 1 + fi + + if ( ! nmcli device wifi list | grep $SSID ); then + echo "Sepcified network missing!" + return 1 + fi + + nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot conect to network!"; return 1; } + return 0 +} + +connect_to_server() { + sshpass -p 'cBe18530-' ssh -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || { echo "Cannot conect to NLL server!"; return 1; } + return 0 +} + +main() { + mount_stick || return 1 + connect_with_network || return 1 + connect_to_server || return 1 + return 0 +} + +main From 3fabd617171553f2cdb3e71691430616d2adae50 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Thu, 8 Apr 2021 11:49:07 +0000 Subject: [PATCH 06/17] wip --- .../etc/systemd/system/connect-to-nllserver.service | 4 ++-- .../fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service index dcf5619c5b..f899429e81 100644 --- a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service @@ -1,6 +1,6 @@ [Unit] -Description=Runs the script to ceonnect to NLL server for maintenance purposes -After=NetworkManager.service +Description=Runs the script to connect to NLL server for maintenance purposes +After=network.target NetworkManager.service [Service] ExecStart=/usr/bin/connect-to-nllserver.sh diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index 0b4a1946fa..45a06cbb44 100644 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -23,8 +23,8 @@ mount_stick() { connect_with_network() { [ ! -e /media/access.txt ] && { echo "Access file missing!"; return 1; } - SSID=$(cat /media/access.txt | grep SSID sed 's/.*://') - PWD=$(cat /media/access.txt | grep PASSWORD sed 's/.*://') + SSID=$(cat /media/access.txt | grep SSID | sed 's/.*://') + PWD=$(cat /media/access.txt | grep PASSWORD | sed 's/.*://') if ( ! systemctl status NetworkManager ); then echo "Network Manager dead!" From 247729527e830c0f29fea5ca3369945b5b9c6e23 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Thu, 8 Apr 2021 12:46:36 +0000 Subject: [PATCH 07/17] added link to service --- .../system/multi-user.target.wants/connect-to-nllserver.service | 1 + 1 file changed, 1 insertion(+) create mode 120000 nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/connect-to-nllserver.service diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/connect-to-nllserver.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/connect-to-nllserver.service new file mode 120000 index 0000000000..3f7877e245 --- /dev/null +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/multi-user.target.wants/connect-to-nllserver.service @@ -0,0 +1 @@ +../connect-to-nllserver.service \ No newline at end of file From 64958631b876a1162b87a540af9610e1365cec43 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Thu, 8 Apr 2021 14:09:13 +0000 Subject: [PATCH 08/17] should work now --- .../etc/systemd/system/connect-to-nllserver.service | 5 ++++- .../usr/bin/connect-to-nllserver.sh | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) mode change 100644 => 100755 nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service index f899429e81..96ee96916c 100644 --- a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service @@ -1,9 +1,12 @@ [Unit] Description=Runs the script to connect to NLL server for maintenance purposes -After=network.target NetworkManager.service +After=network.target +Wants=network.target [Service] +Type=oneshot ExecStart=/usr/bin/connect-to-nllserver.sh +TimeoutSec=0 [Install] WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh old mode 100644 new mode 100755 index 45a06cbb44..c029a800d2 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -19,6 +19,7 @@ mount_stick() { sleep 1 fi done + return 0 } connect_with_network() { @@ -28,9 +29,18 @@ connect_with_network() { if ( ! systemctl status NetworkManager ); then echo "Network Manager dead!" - return 1 + return 1 fi + TIMEOUT=5 + for COUNTER in $(seq 1 $TIMEOUT); do + if ( ! nmcli device status | grep wifi ); then + echo "Wifi device not up!" + return 1 + fi + sleep 1 + done + if ( ! nmcli device wifi list | grep $SSID ); then echo "Sepcified network missing!" return 1 From 2ad5af5cfa7c811f86ede73ea8d0dc35adac80f7 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 10:34:29 +0200 Subject: [PATCH 09/17] wip --- .../usr/bin/connect-to-nllserver.sh | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index c029a800d2..3ec9f395eb 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -1,65 +1,65 @@ #!/bin/sh +LOG_FILE="/media/connection.log" -mount_stick() { - if ( ! ls -l /dev/ | grep sda ); then - echo "Missing USB device!" - exit - fi - - mounted=false +mount_stick () { + if ( ! ls -l /dev/ | grep sda ); then + echo "Missing USB device!" + exit + fi - while [ "$mounted" = false ]; do + mounted=false - if (lsblk | grep sda); then - echo "Found /dev/sda1. Mounting to /media" - mount /dev/sda1 /media || mount /dev/sda /media - mounted=true; - else - echo "Waiting for /dev/sda to appear..." - sleep 1 - fi - done - return 0 + while [ "$mounted" = false ]; do + if (lsblk | grep sda); then + echo "Found /dev/sda1. Mounting to /media" + mount /dev/sda1 /media || mount /dev/sda /media + mounted=true + fi + echo "Waiting for /dev/sda to appear..." + sleep 1 + done +return 0 } -connect_with_network() { - [ ! -e /media/access.txt ] && { echo "Access file missing!"; return 1; } - SSID=$(cat /media/access.txt | grep SSID | sed 's/.*://') - PWD=$(cat /media/access.txt | grep PASSWORD | sed 's/.*://') +connect_with_network () { + [ ! -e /media/access.txt ] && { echo "Access file missing!" > $LOG_FILE; return 1; } + SSID=$(cat /media/access.txt | grep SSID | sed 's/.*://') + PWD=$(cat /media/access.txt | grep PASSWORD | sed 's/.*://') - if ( ! systemctl status NetworkManager ); then - echo "Network Manager dead!" - return 1 - fi + if ( ! systemctl status NetworkManager ); then + echo "Network Manager dead!" > $LOG_FILE + return 1 + fi - TIMEOUT=5 - for COUNTER in $(seq 1 $TIMEOUT); do - if ( ! nmcli device status | grep wifi ); then - echo "Wifi device not up!" - return 1 - fi - sleep 1 - done + TIMEOUT=5 + for COUNTER in $(seq 1 $TIMEOUT); do + if ( ! nmcli device status | grep wifi ); then + echo "Wifi device not up!" > $LOG_FILE + return 1 + fi + sleep 1 + done - if ( ! nmcli device wifi list | grep $SSID ); then - echo "Sepcified network missing!" - return 1 - fi + if ( ! nmcli device wifi list | grep $SSID ); then + echo "Sepcified network missing!" > $LOG_FILE + return 1 + fi - nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot conect to network!"; return 1; } - return 0 + nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot conect to network!" > $LOG_FILE; return 1; } + return 0 } -connect_to_server() { - sshpass -p 'cBe18530-' ssh -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || { echo "Cannot conect to NLL server!"; return 1; } - return 0 +connect_to_server () { + sshpass -p 'cBe18530-' ssh -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || + { echo "Cannot conect to NLL server!" > $LOG_FILE; return 1; } + return 0 } -main() { - mount_stick || return 1 - connect_with_network || return 1 - connect_to_server || return 1 - return 0 +main () { + mount_stick || return 1 + connect_with_network || return 1 + connect_to_server || return 1 + return 0 } main From ca279ff15771efc4f55c2fc587580f566354a5a5 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 10:50:23 +0200 Subject: [PATCH 10/17] wip --- .../fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index 3ec9f395eb..dc5f4380a0 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -14,6 +14,8 @@ mount_stick () { echo "Found /dev/sda1. Mounting to /media" mount /dev/sda1 /media || mount /dev/sda /media mounted=true + rm $LOG_FILE + touch $LOG_FILE fi echo "Waiting for /dev/sda to appear..." sleep 1 @@ -50,7 +52,7 @@ connect_with_network () { } connect_to_server () { - sshpass -p 'cBe18530-' ssh -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || + sshpass -p 'cBe18530-' ssh -NT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || { echo "Cannot conect to NLL server!" > $LOG_FILE; return 1; } return 0 } From 2e0ae770bce0b10a7987680d111f89fcfc632750 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 10:58:40 +0200 Subject: [PATCH 11/17] wip --- nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index dc5f4380a0..c454165a5c 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -61,6 +61,7 @@ main () { mount_stick || return 1 connect_with_network || return 1 connect_to_server || return 1 + echo "Connected to server!" > $LOG_FILE return 0 } From dc57c5aed880bd46cefd8e64e50096195636f140 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 11:44:49 +0200 Subject: [PATCH 12/17] wip --- .../etc/systemd/system/connect-to-nllserver.service | 2 -- nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 1 - 2 files changed, 3 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service index 96ee96916c..9fc1174989 100644 --- a/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service +++ b/nonlinear/fs-overlay-usbrescue/etc/systemd/system/connect-to-nllserver.service @@ -4,9 +4,7 @@ After=network.target Wants=network.target [Service] -Type=oneshot ExecStart=/usr/bin/connect-to-nllserver.sh -TimeoutSec=0 [Install] WantedBy=multi-user.target diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index c454165a5c..dc5f4380a0 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -61,7 +61,6 @@ main () { mount_stick || return 1 connect_with_network || return 1 connect_to_server || return 1 - echo "Connected to server!" > $LOG_FILE return 0 } From d4169c64671794250c7414cb4b0f9ac98df90f58 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 12:05:05 +0200 Subject: [PATCH 13/17] wip --- .../usr/bin/connect-to-nllserver.sh | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index dc5f4380a0..ec402a5d43 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -1,5 +1,7 @@ #!/bin/sh + LOG_FILE="/media/connection.log" +TIMEOUT=5 mount_stick () { if ( ! ls -l /dev/ | grep sda ); then @@ -33,11 +35,11 @@ connect_with_network () { return 1 fi - TIMEOUT=5 for COUNTER in $(seq 1 $TIMEOUT); do - if ( ! nmcli device status | grep wifi ); then - echo "Wifi device not up!" > $LOG_FILE - return 1 + if ( nmcli device status | grep wifi ); then + break + else + [ $TIMEOUT -eq 5 ] && { echo "Wifi device not up!" > $LOG_FILE; return 1 } fi sleep 1 done @@ -47,13 +49,22 @@ connect_with_network () { return 1 fi - nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot conect to network!" > $LOG_FILE; return 1; } + nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot connect to network!" > $LOG_FILE; return 1; } return 0 } connect_to_server () { + for COUNTER in $(seq 1 $TIMEOUT); do + if ( ping www.urverken.de ); then + break + else + [ $TIMEOUT -eq 5 ] && { echo "Cannot ping server" > $LOG_FILE; return 1 } + fi + sleep 1 + done + sshpass -p 'cBe18530-' ssh -NT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || - { echo "Cannot conect to NLL server!" > $LOG_FILE; return 1; } + { echo "Cannot connect to NLL server!" > $LOG_FILE; return 1; } return 0 } From 914f91894c4aa5ad028d57c32cc6475fe43a49e9 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 12:18:37 +0200 Subject: [PATCH 14/17] wip --- .../fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index ec402a5d43..f876603f40 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -38,9 +38,8 @@ connect_with_network () { for COUNTER in $(seq 1 $TIMEOUT); do if ( nmcli device status | grep wifi ); then break - else - [ $TIMEOUT -eq 5 ] && { echo "Wifi device not up!" > $LOG_FILE; return 1 } fi + [ $TIMEOUT -eq 5 ] && { echo "Wifi device not up!" > $LOG_FILE; return 1; } sleep 1 done @@ -57,9 +56,8 @@ connect_to_server () { for COUNTER in $(seq 1 $TIMEOUT); do if ( ping www.urverken.de ); then break - else - [ $TIMEOUT -eq 5 ] && { echo "Cannot ping server" > $LOG_FILE; return 1 } fi + [ $TIMEOUT -eq 5 ] && { echo "Cannot ping server" > $LOG_FILE; return 1; } sleep 1 done From f44de52859c6ed74c4ca9bab7a69e14b3c2bb31b Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 12:45:16 +0200 Subject: [PATCH 15/17] wip --- .../fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index f876603f40..4019f8e380 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -54,14 +54,14 @@ connect_with_network () { connect_to_server () { for COUNTER in $(seq 1 $TIMEOUT); do - if ( ping www.urverken.de ); then + if ( ping -c 1 www.urverken.de ); then break fi [ $TIMEOUT -eq 5 ] && { echo "Cannot ping server" > $LOG_FILE; return 1; } sleep 1 done - sshpass -p 'cBe18530-' ssh -NT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || + sshpass -p 'cBe18530-' ssh -vvNT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || { echo "Cannot connect to NLL server!" > $LOG_FILE; return 1; } return 0 } From 3bf60cc71602cec929c246ff95f47907cb44acac Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 13:01:03 +0200 Subject: [PATCH 16/17] wip --- nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index 4019f8e380..a2883bbd3b 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -61,7 +61,7 @@ connect_to_server () { sleep 1 done - sshpass -p 'cBe18530-' ssh -vvNT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de || + sshpass -p 'cBe18530-' ssh -vvNT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de >$LOG_FILE 2>&1 || { echo "Cannot connect to NLL server!" > $LOG_FILE; return 1; } return 0 } From 35876e1b13adb999123d5e66c89eb62d7bf3deb2 Mon Sep 17 00:00:00 2001 From: AntonSchmied Date: Fri, 9 Apr 2021 14:16:13 +0000 Subject: [PATCH 17/17] wip --- .../usr/bin/connect-to-nllserver.sh | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh index a2883bbd3b..73f444a901 100755 --- a/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh +++ b/nonlinear/fs-overlay-usbrescue/usr/bin/connect-to-nllserver.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -x LOG_FILE="/media/connection.log" TIMEOUT=5 @@ -26,12 +27,12 @@ return 0 } connect_with_network () { - [ ! -e /media/access.txt ] && { echo "Access file missing!" > $LOG_FILE; return 1; } + [ ! -e /media/access.txt ] && { echo "Access file missing!" >> $LOG_FILE; return 1; } SSID=$(cat /media/access.txt | grep SSID | sed 's/.*://') PWD=$(cat /media/access.txt | grep PASSWORD | sed 's/.*://') if ( ! systemctl status NetworkManager ); then - echo "Network Manager dead!" > $LOG_FILE + echo "Network Manager dead!" >> $LOG_FILE return 1 fi @@ -39,30 +40,37 @@ connect_with_network () { if ( nmcli device status | grep wifi ); then break fi - [ $TIMEOUT -eq 5 ] && { echo "Wifi device not up!" > $LOG_FILE; return 1; } + [ $COUNTER -eq 5 ] && { echo "Wifi device not up!" >> $LOG_FILE; return 1; } sleep 1 done if ( ! nmcli device wifi list | grep $SSID ); then - echo "Sepcified network missing!" > $LOG_FILE + echo "Sepcified network missing!" >> $LOG_FILE return 1 fi - nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot connect to network!" > $LOG_FILE; return 1; } + nmcli device wifi connect "$SSID" password "$PWD" || { echo "Cannot connect to network!" >> $LOG_FILE; return 1; } return 0 } connect_to_server () { for COUNTER in $(seq 1 $TIMEOUT); do + echo "Ping ... $COUNTER/$TIMEOUT" >> $LOG_FILE if ( ping -c 1 www.urverken.de ); then break fi - [ $TIMEOUT -eq 5 ] && { echo "Cannot ping server" > $LOG_FILE; return 1; } + [ $COUNTER -eq 5 ] && { echo "Cannot ping server" >> $LOG_FILE; return 1; } sleep 1 done - sshpass -p 'cBe18530-' ssh -vvNT -o StrictHostKeyChecking=no -R 12345:localhost:22 nonlinear@urverken.de >$LOG_FILE 2>&1 || - { echo "Cannot connect to NLL server!" > $LOG_FILE; return 1; } + for COUNTER in $(seq 1 $TIMEOUT); do + echo "Connecting ... $COUNTER/$TIMEOUT" >> $LOG_FILE + if ( sshpass -p 'cBe18530-' ssh -vvNT -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -R 12345:localhost:22 nonlinear@urverken.de >>$LOG_FILE 2>&1 ); then + break + fi + [ $COUNTER -eq 5 ] && { echo "Cannot connect to server" >> $LOG_FILE; return 1; } + sleep 1 + done return 0 }