Project

General

Profile

WiFi works!!! A successful experience. [ SCRIPTS PROVIDED ] » write_config.sh

writes a config file for wpa_supplicant using provided parameters (SSID and password) - Fil Bergamo, 11/21/2016 04:49 PM

 
#
# THIS IS FREE SOFTWARE
#
# Copyright 2016 Filippo "Fil" Bergamo
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

configfile=/data/misc/wifi/wpa_supplicant.conf
socketfile=/data/misc/wifi/socket
pidfile=/data/misc/wifi/pidfile

#read SSID and password from command line:
ssid=$1
pass=$2

#check if config file exists
if [ -e $configfile ]; then
rm $configfile
fi

#write fixed lines:
echo -e "ctrl_interface=DIR="$socketfile"
update_config=1
network={
\tssid=\"$ssid\"
\tpsk=\"$pass\"
}" > $configfile

chmod 777 $configfile

echo "Network connection has been set up for "$ssid"!"
(1-1/7)