feat: differentiate machine-id generation in x86 target

This commit is contained in:
2023-03-10 11:21:22 +01:00
parent 55b49679f1
commit 50025decc1
7 changed files with 38 additions and 15 deletions

View File

@ -0,0 +1,24 @@
#/bin/sh
set -e
main() {
local machine_id_file="/etc/machine-id"
if [ -f "$machine_id_file" ]; then
echo "Machine ID already generated. Doing nothing."
exit 0
fi
# Accumulate data to create unique machine id
local mac_addresses=$(cat /sys/class/net/*/address | uniq | sort)
local device_uuid=$(dmidecode | grep UUID)
# Ensure destination directory
mkdir -p "$(dirname "$machine_id_file")"
# Generate SHA256 hash of data and save it to $machine_id_file
echo "$mac_adresses $device_uuid" | sha256sum | cut -d ' ' -f1 > "$machine_id_file"
}
main

View File

@ -3,6 +3,7 @@
set -e
main() {
# Update default firewall ruleset
uci add firewall rule
uci set firewall.@rule[-1].name='Allow SSH on WAN'
uci set firewall.@rule[-1].src='wan'
@ -25,15 +26,12 @@ main() {
uci set firewall.@rule[-1].target='ACCEPT'
uci commit firewall
service firewall restart
# Forward DNS queries to public DNS
( uci -q delete dhcp.@dnsmasq[0].server || exit 0 )
uci add_list dhcp.@dnsmasq[0].server="8.8.8.8"
uci add_list dhcp.@dnsmasq[0].server="8.8.4.4"
# Disable DNS-rebind protection
uci set dhcp.@dnsmasq[0].rebind_protection='0'
uci commit dhcp
service dnsmasq restart
reload_config
}
main