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

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

    
18
configfile=/data/misc/wifi/wpa_supplicant.conf
19
socketfile=/data/misc/wifi/socket
20
pidfile=/data/misc/wifi/pidfile
21

    
22
#read SSID and password from command line:
23
ssid=$1
24
pass=$2
25

    
26
#check if config file exists
27
if [ -e $configfile ]; then
28
	rm $configfile
29
fi
30

    
31
#write fixed lines:
32
echo -e "ctrl_interface=DIR="$socketfile"
33
update_config=1
34
network={
35
\tssid=\"$ssid\"
36
\tpsk=\"$pass\"
37
}" > $configfile
38

    
39
chmod 777 $configfile
40

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