Can configure wifi from image builder

This commit is contained in:
Bob Mottram 2016-04-26 15:41:35 +01:00
parent 266c31e10a
commit ddc7f1a7bb
No known key found for this signature in database
GPG Key ID: BA68F26108DC9F87
3 changed files with 152 additions and 85 deletions

View File

@ -100,6 +100,13 @@ MIRROR='http://ftp.de.debian.org/debian'
# Whether to only install debian but nothing else
DEBIAN_INSTALL_ONLY='no'
# wifi settings
WIFI_INTERFACE='wlan0'
WIFI_SSID=
WIFI_TYPE='wpa-psk'
WIFI_PASSPHRASE=
WIFI_HOTSPOT='no'
mesh_router_setup_script() {
# create a setup script for a mesh router
mesh_script_filename=$1
@ -220,6 +227,28 @@ do
shift
DEBIAN_INSTALL_ONLY="$1"
;;
--interface|--if)
shift
WIFI_INTERFACE="$1"
;;
--ssid|--essid)
shift
WIFI_SSID="$1"
;;
--wifitype)
shift
WIFI_TYPE="$1"
;;
--wifipass|--passphrase)
shift
WIFI_PASSPHRASE="$1"
;;
--hotspot)
shift
if [[ $"$1" == $'yes' || $"$1" == $'y' ]]; then
WIFI_HOTSPOT='yes'
fi
;;
*)
# unknown option
;;
@ -322,7 +351,12 @@ make $IMAGE_TYPE \
PROJECT_REPO="$PROJECT_REPO" \
MIRROR="$MIRROR" \
BUILD_MIRROR="$MIRROR" \
DEBIAN_INSTALL_ONLY="$DEBIAN_INSTALL_ONLY"
DEBIAN_INSTALL_ONLY="$DEBIAN_INSTALL_ONLY" \
WIFI_INTERFACE="$WIFI_INTERFACE" \
WIFI_SSID="$WIFI_SSID" \
WIFI_TYPE="$WIFI_TYPE" \
WIFI_PASSPHRASE="$WIFI_PASSPHRASE" \
WIFI_HOTSPOT="$WIFI_HOTSPOT"
if [ ! "$?" = "0" ]; then
echo $'Build failed'

View File

@ -78,7 +78,12 @@ ONION_ONLY="no"
# Whether to only install debian and nothing else
DEBIAN_INSTALL_ONLY="no"
# wifi settings
WIFI_INTERFACE='wlan0'
WIFI_SSID=
WIFI_TYPE='wpa-psk'
WIFI_PASSPHRASE=
WIFI_HOTSPOT='no'
enable_eatmydata_override() {
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
@ -421,6 +426,23 @@ initialise_mesh() {
chroot "$rootdir" systemctl enable $MESH_SERVICE
}
configure_wifi() {
if [[ $VARIANT == "mesh" ]]; then
return
fi
if [[ $WIFI_TYPE != 'none' ]]; then
if [ ! $WIFI_PASSPHRASE ]; then
return
fi
if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
return
fi
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $HOTSPOT
else
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT
fi
}
# Set to true/false to control if eatmydata is used during build
use_eatmydata=true
@ -540,6 +562,7 @@ create_generic_image
atheros_wifi
continue_installation
initialise_mesh
configure_wifi
cd /
echo $"info: killing leftover processes in chroot"

View File

@ -56,6 +56,11 @@ export SSH_PORT
export ONION_ONLY
export PROJECT_REPO
export DEBIAN_INSTALL_ONLY
export WIFI_INTERFACE
export WIFI_SSID
export WIFI_TYPE
export WIFI_PASSPHRASE
export WIFI_HOTSPOT
# Locate vmdebootstrap program fetched in Makefile
basedir=`pwd`
@ -171,6 +176,11 @@ sudo sed -i "s|SSH_PORT=.*|SSH_PORT=\"${SSH_PORT}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|ONION_ONLY=.*|ONION_ONLY=\"${ONION_ONLY}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|PROJECT_REPO=.*|PROJECT_REPO=\"${PROJECT_REPO}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|DEBIAN_INSTALL_ONLY=.*|DEBIAN_INSTALL_ONLY=\"${DEBIAN_INSTALL_ONLY}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|WIFI_INTERFACE=.*|WIFI_INTERFACE=\"${WIFI_INTERFACE}\"|g" $TEMP_CUSTOMISE
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_PASSPHRASE=.*|WIFI_PASSPHRASE=\"${WIFI_PASSPHRASE}\"|g" $TEMP_CUSTOMISE
sudo sed -i "s|WIFI_HOTSPOT=.*|WIFI_HOTSPOT=\"${WIFI_HOTSPOT}\"|g" $TEMP_CUSTOMISE
echo $"starting $VMDEBOOTSTRAP"
# Run vmdebootstrap script to create image