add wifi support

This commit is contained in:
Aaron Murray 2020-05-10 10:02:30 -05:00
parent 1ce5556f6b
commit 3cc04dd196

View File

@ -27,6 +27,7 @@ if [ ! "${systemd}" = "systemd" ]; then
exit 100 exit 100
fi fi
declare -i cfg=0
declare -l codename declare -l codename
declare -l omvCodename declare -l omvCodename
declare -l omvInstall="" declare -l omvInstall=""
@ -384,12 +385,12 @@ fi
# remove networkmanager and dhcpcd5 then configure networkd # remove networkmanager and dhcpcd5 then configure networkd
if [ ${version} -gt 4 ]; then if [ ${version} -gt 4 ]; then
defLink="/etc/systemd/network/99-default.link" defLink="/etc/systemd/network/99-default.link"
if [ -e "${defLink}" ]; then if [ -e "${defLink}" ]; then
rm -f "${defLink}" rm -fv "${defLink}"
fi fi
nic="eth0"
if grep -qw "${nic}" /proc/net/dev; then
echo "Removing network-manager and dhcpcd5 ..." echo "Removing network-manager and dhcpcd5 ..."
apt-get -y --autoremove purge network-manager dhcpcd5 apt-get -y --autoremove purge network-manager dhcpcd5
@ -406,17 +407,47 @@ if [ ${version} -gt 4 ]; then
rm /etc/resolv.conf rm /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
echo "Configure ${nic} to use networkd ..." nic="eth0"
if grep -qw "${nic}" /proc/net/dev; then
echo "Configure ${nic} ..."
# add database entry # add database entry
jq --null-input --compact-output \ jq --null-input --compact-output \
"{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"dhcp\", method6: \"dhcp\"}" | \ "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"dhcp\", method6: \"dhcp\"}" | \
omv-confdbadm update "conf.system.network.interface" - omv-confdbadm update "conf.system.network.interface" -
cfg=1
fi
nic="wlan0"
if grep -qw "${nic}" /proc/net/dev; then
echo "Configure ${nic} ..."
wpaConf="/etc/wpa_supplicant/wpa_supplicant.conf"
crda="/etc/default/crda"
if [ -f "${wpaConf}" ]; then
country=$(awk -F'=' '/country=/{gsub(/["\r]/,""); print $NF}' ${wpaConf})
wifiName=$(awk -F'=' '/ssid="/{st=index($0,"="); ssid=substr($0,st+1); gsub(/["\r]/,"",ssid); print ssid}' ${wpaConf})
wifiPass=$(awk -F'=' '/psk="/{st=index($0,"="); pass=substr($0,st+1); gsub(/["\r]/,"",pass); print pass}' ${wpaConf})
if [ -n "${country}" ] && [ -n "${wifiName}" ] && [ -n "${wifiPass}" ]; then
if [ -f "${crda}" ]; then
awk -i inplace -F'=' -v country="$country" '/REGDOMAIN=/{$0=$1"="country} {print $0}' ${crda}
fi
jq --null-input --compact-output \
"{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"dhcp\", method6: \"dhcp\", wpassid: \"${wifiName}\", wpapsk: \"${wifiPass}\"}" | \
omv-confdbadm update "conf.system.network.interface" -
cfg=1
fi
fi
fi
if [ ${cfg} -eq 1 ]; then
echo "IP address may change and you could lose connection if running this script via ssd."
# create config files # create config files
${confCmd} ${network} ${confCmd} ${network}
fi
echo "It is recommended to reboot and then setup the network adapter in the openmediavault web interface." echo "It is recommended to reboot and then setup the network adapter in the openmediavault web interface."
fi
fi fi
exit 0 exit 0