Skip to content

Commit

Permalink
Unifying style of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Mar 3, 2024
1 parent f85ebef commit c2fe587
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions extensions/preset-firstrun.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
function post_family_tweaks__preset_configs() {
display_alert "$BOARD" "preset configs for rootfs" "info"
# Set FR_net_change_defaults to 1 to apply any network related settings below
echo "FR_net_change_defaults=1" > "${SDCARD}"/root/.not_logged_in_yet
# Set PRESET_NET_CHANGE_DEFAULTS to 1 to apply any network related settings below
echo "PRESET_NET_CHANGE_DEFAULTS=1" > "${SDCARD}"/root/.not_logged_in_yet

# Enable WiFi or Ethernet.
# NB: If both are enabled, WiFi will take priority and Ethernet will be disabled.
echo "FR_net_ethernet_enabled=1" >> "${SDCARD}"/root/.not_logged_in_yet
echo "FR_net_wifi_enabled=1" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_ETHERNET_ENABLED=1" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_WIFI_ENABLED=1" >> "${SDCARD}"/root/.not_logged_in_yet

#Enter your WiFi creds
# SECURITY WARN: Your wifi keys will be stored in plaintext, no encryption.
echo "FR_net_wifi_ssid='MySSID'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "FR_net_wifi_key='MyWiFiKEY'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_WIFI_SSID='MySSID'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_WIFI_KEY='MyWiFiKEY'" >> "${SDCARD}"/root/.not_logged_in_yet

# Country code to enable power ratings and channels for your country. eg: GB US DE | https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
echo "FR_net_wifi_countrycode='GB'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_WIFI_COUNTRYCODE='GB'" >> "${SDCARD}"/root/.not_logged_in_yet

#If you want to use a static ip, set it here
echo "FR_net_use_static=1" >> "${SDCARD}"/root/.not_logged_in_yet
echo "FR_net_static_ip='192.168.0.100'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "FR_net_static_mask='255.255.255.0'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "FR_net_static_gateway='192.168.0.1'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "FR_net_static_dns='8.8.8.8 8.8.4.4'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_USE_STATIC=1" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_STATIC_IP='192.168.0.100'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_STATIC_MASK='255.255.255.0'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_STATIC_GATEWAY='192.168.0.1'" >> "${SDCARD}"/root/.not_logged_in_yet
echo "PRESET_NET_STATIC_DNS='8.8.8.8 8.8.4.4'" >> "${SDCARD}"/root/.not_logged_in_yet

# Preset user default shell, you can choose bash or zsh
echo "PRESET_USER_SHELL=bash" >> "${SDCARD}"/root/.not_logged_in_yet
Expand Down
22 changes: 11 additions & 11 deletions packages/bsp/common/usr/lib/armbian/armbian-firstlogin
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ do_firstrun_automated_network_configuration()
source "$fp_config"

# Obtain backward configuration compatibility
FR_net_static_dns=${FR_net_static_dns// /,}
FR_net_static_mask=$(mask2cidr $FR_net_static_mask)
PRESET_NET_STATIC_DNS=${PRESET_NET_STATIC_DNS// /,}
PRESET_NET_STATIC_MASK=$(mask2cidr $PRESET_NET_STATIC_MASK)

#-----------------------------------------------------------------------------
# Set Network
if [[ $FR_net_change_defaults == 1 ]]; then
if [[ $PRESET_NET_CHANGE_DEFAULTS == 1 ]]; then
# Only run at tty1
if [ "$(who am i | awk '{print $2}')" != "tty1" ];then
exit
Expand All @@ -82,34 +82,34 @@ do_firstrun_automated_network_configuration()
wlan_index="$(nmcli d | grep wifi | cut -d ' ' -f 1 | head -n 1)"

# for static IP we only append settings
if [[ $FR_net_use_static == 1 ]]; then
local FIXED_IP_SETTINGS="ipv4.method manual ipv4.address ${FR_net_static_ip}/${FR_net_static_mask} ipv4.dns ${FR_net_static_dns} ipv4.gateway ${FR_net_static_gateway}"
if [[ $PRESET_NET_USE_STATIC == 1 ]]; then
local FIXED_IP_SETTINGS="ipv4.method manual ipv4.address ${PRESET_NET_STATIC_IP}/${PRESET_NET_STATIC_MASK} ipv4.dns ${PRESET_NET_STATIC_DNS} ipv4.gateway ${PRESET_NET_STATIC_GATEWAY}"
fi

if [[ -n $eth_index || -n $wlan_index ]]; then
# delete all current connections
LC_ALL=C nmcli -t -f UUID,DEVICE connection show | awk '{print $1}' | cut -f1 -d":" | xargs nmcli connection delete

# - Wifi enable
if [[ $FR_net_wifi_enabled == 1 ]]; then
if [[ $PRESET_NET_WIFI_ENABLED == 1 ]]; then

#Set wifi country code
iw reg set "$FR_net_wifi_countrycode"
iw reg set "$PRESET_NET_WIFI_COUNTRYCODE"

nmcli con add con-name "Armbian wireless" type wifi ifname ${wlan_index} ssid "$FR_net_wifi_ssid" -- wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$FR_net_wifi_key" ${FIXED_IP_SETTINGS}
nmcli con add con-name "Armbian wireless" type wifi ifname ${wlan_index} ssid "$PRESET_NET_WIFI_SSID" -- wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$PRESET_NET_WIFI_KEY" ${FIXED_IP_SETTINGS}
nmcli con up "Armbian wireless"

#Enable Wlan, disable Eth
FR_net_ethernet_enabled=0
PRESET_NET_ETHERNET_ENABLED=0

# - Ethernet enable
elif [[ $FR_net_ethernet_enabled == 1 ]]; then
elif [[ $PRESET_NET_ETHERNET_ENABLED == 1 ]]; then

nmcli con add con-name "Armbian ethernet" type ethernet ifname ${eth_index} -- ${FIXED_IP_SETTINGS}
nmcli con up "Armbian ethernet"

#Enable Eth, disable Wlan
FR_net_wifi_enabled=0
PRESET_NET_WIFI_ENABLED=0

fi
fi
Expand Down

0 comments on commit c2fe587

Please sign in to comment.