v8
Remove requirment for first run file.
This commit is contained in:
parent
eb8c0e193d
commit
fbf322c84f
@ -2,7 +2,6 @@
|
||||
#ARMbian first run: Set optional end user configuration
|
||||
# - /boot/armbian_first_run.txt
|
||||
# - Settings below will be applied on 1st run of ARMbian
|
||||
# - This file is required to complete 1st run setup of ARMbian
|
||||
# - Do not "comment out" or remove any entries, as, we load this file directly to variables
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# Wired adapter #1
|
||||
#allow-hotplug eth0
|
||||
allow-hotplug eth0
|
||||
#no-auto-down eth0
|
||||
iface eth0 inet dhcp
|
||||
#address 192.168.0.100
|
||||
|
||||
190
scripts/firstrun
190
scripts/firstrun
@ -240,13 +240,6 @@ check_prerequisits() {
|
||||
do_firstrun_automated_user_configuration() {
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#Requires:
|
||||
# - sed
|
||||
# - grep
|
||||
# - cat
|
||||
# - /usr/bin/killall
|
||||
# - ifup & ifdown
|
||||
|
||||
#Notes:
|
||||
# - See /boot/armbian_first_run.txt for full list of available variables
|
||||
# - If you change any variable name in this function, it MUST ALSO be changed in /boot/armbian_first_run.txt to match, as we read file directly into variables.
|
||||
@ -266,6 +259,7 @@ do_firstrun_automated_user_configuration() {
|
||||
chmod +x "$fp_config" # possibly required for ext4
|
||||
. "$fp_config"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# - FR_general_delete_this_file_after_completion?
|
||||
if (( $FR_general_delete_this_file_after_completion )); then
|
||||
|
||||
@ -274,122 +268,124 @@ do_firstrun_automated_user_configuration() {
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
#-----------------------------------------------------------------------------
|
||||
#Set Network
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#Set Network
|
||||
# - Get 1st active index of wlan and eth adapters
|
||||
local fp_ifconfig_tmp='/tmp/.ifconfig'
|
||||
ifconfig -a > "$fp_ifconfig_tmp" #export to file, should be quicker in loop than calling ifconfig each time.
|
||||
|
||||
# - Get 1st active index of wlan and eth adapters
|
||||
local fp_ifconfig_tmp='/tmp/.ifconfig'
|
||||
ifconfig -a > "$fp_ifconfig_tmp" #export to file, should be quicker in loop than calling ifconfig each time.
|
||||
# find eth[0-9]
|
||||
for ((i=0; i<=9; i++))
|
||||
do
|
||||
|
||||
# find eth[0-9]
|
||||
for ((i=0; i<=9; i++))
|
||||
do
|
||||
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "eth$i") )); then
|
||||
|
||||
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "eth$i") )); then
|
||||
eth_index=$i
|
||||
break
|
||||
|
||||
eth_index=$i
|
||||
break
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
done
|
||||
# find wlan[0-9]
|
||||
for ((i=0; i<=9; i++))
|
||||
do
|
||||
|
||||
# find wlan[0-9]
|
||||
for ((i=0; i<=9; i++))
|
||||
do
|
||||
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "wlan$i") )); then
|
||||
|
||||
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "wlan$i") )); then
|
||||
wlan_index=$i
|
||||
break
|
||||
|
||||
wlan_index=$i
|
||||
break
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
done
|
||||
rm "$fp_ifconfig_tmp"
|
||||
|
||||
rm "$fp_ifconfig_tmp"
|
||||
# - Kill dhclient
|
||||
killall -w dhclient
|
||||
|
||||
# - Kill dhclient
|
||||
# killall -w dhclient #FOURDEE: not needed as interfaces are disabled from up to this point
|
||||
|
||||
# - Drop Connections
|
||||
# ifdown eth$eth_index #FOURDEE: not needed as interfaces are disabled from up to this point
|
||||
# ifdown wlan$wlan_index #FOURDEE: not needed as interfaces are disabled from up to this point
|
||||
|
||||
# - Wifi enable
|
||||
if (( $FR_net_wifi_enabled )); then
|
||||
|
||||
#Enable Wlan, disable Eth
|
||||
FR_net_ethernet_enabled=0
|
||||
sed -i "/allow-hotplug wlan$wlan_index/c\allow-hotplug wlan$wlan_index" /etc/network/interfaces
|
||||
#sed -i "/allow-hotplug eth$eth_index/c\#allow-hotplug eth$eth_index" /etc/network/interfaces
|
||||
|
||||
#Set SSid (covers both WEP and WPA)
|
||||
sed -i "/wireless-essid /c\ wireless-essid $FR_net_wifi_ssid" /etc/network/interfaces
|
||||
sed -i "/wpa-ssid /c\ wpa-ssid $FR_net_wifi_ssid" /etc/network/interfaces
|
||||
|
||||
#Set Key (covers both WEP and WPA)
|
||||
sed -i "/wireless-key /c\ wireless-key $FR_net_wifi_key" /etc/network/interfaces
|
||||
sed -i "/wpa-psk /c\ wpa-psk $FR_net_wifi_key" /etc/network/interfaces
|
||||
|
||||
#Set wifi country code
|
||||
iw reg set "$FR_net_wifi_countrycode"
|
||||
|
||||
# - Ethernet enable
|
||||
elif (( $FR_net_ethernet_enabled )); then
|
||||
|
||||
#Enable Eth, disable Wlan
|
||||
FR_net_wifi_enabled=0
|
||||
sed -i "/allow-hotplug eth$eth_index/c\allow-hotplug eth$eth_index" /etc/network/interfaces
|
||||
#sed -i "/allow-hotplug wlan$wlan_index/c\#allow-hotplug wlan$wlan_index" /etc/network/interfaces
|
||||
|
||||
fi
|
||||
|
||||
# - Static IP enable
|
||||
if (( $FR_net_use_static )); then
|
||||
# - Drop Connections
|
||||
ifdown eth$eth_index
|
||||
ifdown wlan$wlan_index
|
||||
|
||||
# - Wifi enable
|
||||
if (( $FR_net_wifi_enabled )); then
|
||||
|
||||
sed -i "/iface wlan$wlan_index inet/c\iface wlan$wlan_index inet static" /etc/network/interfaces
|
||||
#Enable Wlan, disable Eth
|
||||
FR_net_ethernet_enabled=0
|
||||
sed -i "/allow-hotplug wlan$wlan_index/c\allow-hotplug wlan$wlan_index" /etc/network/interfaces
|
||||
sed -i "/allow-hotplug eth$eth_index/c\#allow-hotplug eth$eth_index" /etc/network/interfaces
|
||||
|
||||
#Set SSid (covers both WEP and WPA)
|
||||
sed -i "/wireless-essid /c\ wireless-essid $FR_net_wifi_ssid" /etc/network/interfaces
|
||||
sed -i "/wpa-ssid /c\ wpa-ssid $FR_net_wifi_ssid" /etc/network/interfaces
|
||||
|
||||
#Set Key (covers both WEP and WPA)
|
||||
sed -i "/wireless-key /c\ wireless-key $FR_net_wifi_key" /etc/network/interfaces
|
||||
sed -i "/wpa-psk /c\ wpa-psk $FR_net_wifi_key" /etc/network/interfaces
|
||||
|
||||
#Set wifi country code
|
||||
iw reg set "$FR_net_wifi_countrycode"
|
||||
|
||||
# - Ethernet enable
|
||||
elif (( $FR_net_ethernet_enabled )); then
|
||||
|
||||
#Enable Eth, disable Wlan
|
||||
FR_net_wifi_enabled=0
|
||||
sed -i "/allow-hotplug eth$eth_index/c\allow-hotplug eth$eth_index" /etc/network/interfaces
|
||||
#sed -i "/allow-hotplug wlan$wlan_index/c\#allow-hotplug wlan$wlan_index" /etc/network/interfaces
|
||||
|
||||
fi
|
||||
|
||||
# - Static IP enable
|
||||
if (( $FR_net_use_static )); then
|
||||
|
||||
if (( $FR_net_wifi_enabled )); then
|
||||
|
||||
sed -i "/iface wlan$wlan_index inet/c\iface wlan$wlan_index inet static" /etc/network/interfaces
|
||||
|
||||
elif (( $FR_net_ethernet_enabled )); then
|
||||
|
||||
sed -i "/iface eth$eth_index inet/c\iface eth$eth_index inet static" /etc/network/interfaces
|
||||
|
||||
fi
|
||||
|
||||
#This will change both eth and wlan entries, however, as only 1 adapater is enabled by this feature, should be fine.
|
||||
sed -i "/^#address/c\address $FR_net_static_ip" /etc/network/interfaces
|
||||
sed -i "/^#netmask/c\netmask $FR_net_static_mask" /etc/network/interfaces
|
||||
sed -i "/^#gateway/c\gateway $FR_net_static_gateway" /etc/network/interfaces
|
||||
sed -i "/^#dns-nameservers/c\dns-nameservers $FR_net_static_dns" /etc/network/interfaces
|
||||
|
||||
fi
|
||||
|
||||
# - Restart Networking
|
||||
if [[ "$DISTRIBUTION" == "wheezy" || "$DISTRIBUTION" == "trusty" ]]; then
|
||||
|
||||
service networking restart
|
||||
|
||||
else
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl restart networking
|
||||
|
||||
fi
|
||||
|
||||
# - Manually bring up adapters (just incase)
|
||||
if (( $FR_net_wifi_enabled )); then
|
||||
|
||||
ifup wlan$wlan_index
|
||||
|
||||
elif (( $FR_net_ethernet_enabled )); then
|
||||
|
||||
sed -i "/iface eth$eth_index inet/c\iface eth$eth_index inet static" /etc/network/interfaces
|
||||
ifup eth$eth_index
|
||||
|
||||
fi
|
||||
|
||||
#This will change both eth and wlan entries, however, as only 1 adapater is enabled by this feature, should be fine.
|
||||
sed -i "/^#address/c\address $FR_net_static_ip" /etc/network/interfaces
|
||||
sed -i "/^#netmask/c\netmask $FR_net_static_mask" /etc/network/interfaces
|
||||
sed -i "/^#gateway/c\gateway $FR_net_static_gateway" /etc/network/interfaces
|
||||
sed -i "/^#dns-nameservers/c\dns-nameservers $FR_net_static_dns" /etc/network/interfaces
|
||||
|
||||
fi
|
||||
|
||||
# - Restart Networking
|
||||
if [[ "$DISTRIBUTION" == "wheezy" || "$DISTRIBUTION" == "trusty" ]]; then
|
||||
|
||||
service networking restart
|
||||
|
||||
else
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl restart networking
|
||||
|
||||
fi
|
||||
|
||||
# - Manually bring up adapters (just incase)
|
||||
if (( $FR_net_wifi_enabled )); then
|
||||
|
||||
ifup wlan$wlan_index
|
||||
|
||||
elif (( $FR_net_ethernet_enabled )); then
|
||||
|
||||
ifup eth$eth_index
|
||||
|
||||
fi
|
||||
|
||||
} #do_firstrun_automated_user_configuration
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user