Can use wifi networks config file from the image builder

This commit is contained in:
Bob Mottram 2016-04-26 20:00:30 +01:00
parent 494af60013
commit 2b14e18748
4 changed files with 563 additions and 548 deletions

View File

@ -106,6 +106,7 @@ WIFI_SSID=
WIFI_TYPE='wpa-psk' WIFI_TYPE='wpa-psk'
WIFI_PASSPHRASE= WIFI_PASSPHRASE=
WIFI_HOTSPOT='no' WIFI_HOTSPOT='no'
WIFI_NETWORKS_FILE=${PROJECT_NAME}-wifi.cfg
mesh_router_setup_script() { mesh_router_setup_script() {
# create a setup script for a mesh router # create a setup script for a mesh router
@ -249,6 +250,10 @@ do
WIFI_HOTSPOT='yes' WIFI_HOTSPOT='yes'
fi fi
;; ;;
--wifinetworks)
shift
WIFI_NETWORKS_FILE="$1"
;;
*) *)
# unknown option # unknown option
;; ;;
@ -356,7 +361,8 @@ make $IMAGE_TYPE \
WIFI_SSID="$WIFI_SSID" \ WIFI_SSID="$WIFI_SSID" \
WIFI_TYPE="$WIFI_TYPE" \ WIFI_TYPE="$WIFI_TYPE" \
WIFI_PASSPHRASE="$WIFI_PASSPHRASE" \ WIFI_PASSPHRASE="$WIFI_PASSPHRASE" \
WIFI_HOTSPOT="$WIFI_HOTSPOT" WIFI_HOTSPOT="$WIFI_HOTSPOT" \
WIFI_NETWORKS_FILE="$WIFI_NETWORKS_FILE"
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'Build failed' echo $'Build failed'

View File

@ -84,6 +84,7 @@ WIFI_SSID=
WIFI_TYPE='wpa-psk' WIFI_TYPE='wpa-psk'
WIFI_PASSPHRASE= WIFI_PASSPHRASE=
WIFI_HOTSPOT='no' WIFI_HOTSPOT='no'
WIFI_NETWORKS_FILE=${PROJECT_NAME}-wifi.cfg
enable_eatmydata_override() { enable_eatmydata_override() {
chroot $rootdir apt-get install --no-install-recommends -y eatmydata chroot $rootdir apt-get install --no-install-recommends -y eatmydata
@ -430,6 +431,12 @@ configure_wifi() {
if [[ $VARIANT == "mesh" ]]; then if [[ $VARIANT == "mesh" ]]; then
return return
fi fi
if [ -f $WIFI_NETWORKS_FILE ]; then
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE --networks $WIFI_NETWORKS_FILE
return
fi
if [[ $WIFI_TYPE != 'none' ]]; then if [[ $WIFI_TYPE != 'none' ]]; then
if [ ! $WIFI_PASSPHRASE ]; then if [ ! $WIFI_PASSPHRASE ]; then
return return

View File

@ -61,6 +61,7 @@ export WIFI_SSID
export WIFI_TYPE export WIFI_TYPE
export WIFI_PASSPHRASE export WIFI_PASSPHRASE
export WIFI_HOTSPOT export WIFI_HOTSPOT
export WIFI_NETWORKS_FILE
# Locate vmdebootstrap program fetched in Makefile # Locate vmdebootstrap program fetched in Makefile
basedir=`pwd` basedir=`pwd`
@ -181,6 +182,7 @@ sudo sed -i "s|WIFI_SSID=.*|WIFI_SSID=\"${WIFI_SSID}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|WIFI_TYPE=.*|WIFI_TYPE=\"${WIFI_TYPE}\"|g" $TEMP_CUSTOMISE sudo sed -i "s|WIFI_TYPE=.*|WIFI_TYPE=\"${WIFI_TYPE}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|WIFI_PASSPHRASE=.*|WIFI_PASSPHRASE=\"${WIFI_PASSPHRASE}\"|g" $TEMP_CUSTOMISE sudo sed -i "s|WIFI_PASSPHRASE=.*|WIFI_PASSPHRASE=\"${WIFI_PASSPHRASE}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|WIFI_HOTSPOT=.*|WIFI_HOTSPOT=\"${WIFI_HOTSPOT}\"|g" $TEMP_CUSTOMISE sudo sed -i "s|WIFI_HOTSPOT=.*|WIFI_HOTSPOT=\"${WIFI_HOTSPOT}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|WIFI_NETWORKS_FILE=.*|WIFI_NETWORKS_FILE=\"${WIFI_NETWORKS_FILE}\"|g" $TEMP_CUSTOMISE
echo $"starting $VMDEBOOTSTRAP" echo $"starting $VMDEBOOTSTRAP"
# Run vmdebootstrap script to create image # Run vmdebootstrap script to create image

View File

@ -42,7 +42,7 @@ WIFI_SSID=
WIFI_PASSPHRASE= WIFI_PASSPHRASE=
WIFI_HOTSPOT='no' WIFI_HOTSPOT='no'
WIFI_CONFIG=/etc/wpa_supplicant/wpa_supplicant.conf WIFI_CONFIG=/etc/wpa_supplicant/wpa_supplicant.conf
WIFI_FILE=/root/${PROJECT_NAME}-wifi.cfg WIFI_NETWORKS_FILE=/root/${PROJECT_NAME}-wifi.cfg
function wifi_get_psk { function wifi_get_psk {
ssid=$1 ssid=$1
@ -197,8 +197,8 @@ function wifi_none {
} }
function create_networks_from_file { function create_networks_from_file {
if [ ! -f $WIFI_FILE ]; then if [ ! -f $WIFI_NETWORKS_FILE ]; then
return exit 4
fi fi
if [ ! -f /etc/network/interfaces_original ]; then if [ ! -f /etc/network/interfaces_original ]; then
@ -254,7 +254,7 @@ function create_networks_from_file {
ctr=$((ctr + 1)) ctr=$((ctr + 1))
fi fi
fi fi
done < $WIFI_FILE done < $WIFI_NETWORKS_FILE
systemctl restart network-manager systemctl restart network-manager
} }
@ -303,9 +303,9 @@ do
shift shift
WIFI_HOTSPOT=${1} WIFI_HOTSPOT=${1}
;; ;;
--config) --networks)
shift shift
WIFI_FILE=${1} WIFI_NETWORKS_FILE=${1}
;; ;;
*) *)
# unknown option # unknown option
@ -314,7 +314,7 @@ do
shift shift
done done
if [ -f $WIFI_FILE ]; then if [ -f $WIFI_NETWORKS_FILE ]; then
create_networks_from_file create_networks_from_file
exit 0 exit 0
fi fi