From 42867e6ff00791e78494cbcbbc514f4f972f82d6 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 16 Nov 2024 01:50:20 +0200 Subject: [PATCH] scripts --- scripts/00-header | 12 ++++++++++++ scripts/10-help-text | 33 --------------------------------- scripts/networkinterfaces.sh | 14 ++++++-------- 3 files changed, 18 insertions(+), 41 deletions(-) delete mode 100644 scripts/10-help-text diff --git a/scripts/00-header b/scripts/00-header index 77b1c71..7c0ff2e 100644 --- a/scripts/00-header +++ b/scripts/00-header @@ -27,3 +27,15 @@ if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then # Fall back to using the very slow lsb_release utility DISTRIB_DESCRIPTION=$(lsb_release -s -d) fi + +[ -r /etc/lsb-release ] && . /etc/lsb-release + +#printf "\n" +printf " %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)" +printf " Meshtastic is a registered trademark of Meshtastic LLC.\n" +printf " Meshtastic software components are released under various licenses,\n" +printf " see GitHub for details. No warranty is provided - use at your own risk.\n" +printf " Luckfox: wiki.luckfox.com This image built by github.com/noon92/femtofox\n" +printf " This system has been minimized. To restore content, run 'unminimize'.\n\n" + +printf "IP address: $(hostname -I | sed 's/ / /g') Uptime:$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')\n" \ No newline at end of file diff --git a/scripts/10-help-text b/scripts/10-help-text deleted file mode 100644 index 175702c..0000000 --- a/scripts/10-help-text +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 10-help-text - print the help text associated with the distro -# Copyright (C) 2009-2010 Canonical Ltd. -# -# Authors: Dustin Kirkland , -# Brian Murray -# -# This program 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. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -[ -r /etc/lsb-release ] && . /etc/lsb-release - -#printf "\n" -printf " %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)" -printf " Meshtastic is a registered trademark of Meshtastic LLC.\n" -printf " Meshtastic software components are released under various licenses,\n" -printf " see GitHub for details. No warranty is provided - use at your own risk.\n" -printf " Luckfox: wiki.luckfox.com This image built by github.com/noon92/femtofox\n" -printf " This system has been minimized. To restore content, run 'unminimize'.\n\n" - -printf "IP address: $(hostname -I | sed 's/ / /g') Uptime:$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')\n" \ No newline at end of file diff --git a/scripts/networkinterfaces.sh b/scripts/networkinterfaces.sh index 05402d4..7a1b984 100644 --- a/scripts/networkinterfaces.sh +++ b/scripts/networkinterfaces.sh @@ -1,9 +1,7 @@ #!/bin/bash -# Generate a random unicast MAC address -random_mac=$(printf '%02X:%02X:%02X:%02X:%02X:%02X\n' \ - $(( (RANDOM % 256) & 0xFE )) $(( RANDOM % 256 )) $(( RANDOM % 256 )) \ - $(( RANDOM % 256 )) $(( RANDOM % 256 )) $(( RANDOM % 256 ))) +# Get the current MAC address for eth0 +current_mac=$(cat /sys/class/net/eth0/address) # Define the configuration to append config=" @@ -13,7 +11,7 @@ iface lo inet loopback # static mac address for onboard ethernet (castellated pins) allow-hotplug eth0 iface eth0 inet dhcp -hwaddress ether $random_mac +hwaddress ether $current_mac allow-hotplug wlan0 iface wlan0 inet dhcp @@ -21,7 +19,7 @@ iface wlan0 inet dhcp " # Append the configuration to /etc/network/interfaces -echo "$config" >> /etc/network/interfaces +echo "$config" | sudo tee -a /etc/network/interfaces -# Output the generated MAC address -echo "Appended configuration with generated MAC address: $random_mac" +# Output the current MAC address +echo "Appended configuration with current MAC address: $current_mac"