-
Notifications
You must be signed in to change notification settings - Fork 12
/
w.sh
56 lines (48 loc) · 1.67 KB
/
w.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /bin/sh
# raspi-wifi-blindscript v4
# A minimium command line script to configure Wi-Fi network on Raspbian
# system for Raspberry Pi(R) ARM computer.
# Project HP: https://github.com/shamiao/raspi-wifi-blindscript
#
# Copyright (C) 2013 Sha Miao
# This program is released under the MIT license, see LICENSE file or
# <http://opensource.org/licenses/MIT> for full text.
#
# See README for usage.
###############################################################
#################### PLEASE EDIT THIS PART ####################
###############################################################
# SSID (aka. network name).
SSID='ssid_goes_here'
# Network encryption method.
# * 'WPA' for WPA-PSK/WPA2-PSK (note: most Wi-Fi networks use WPA);
# * 'WEP' for WEP;
# * 'Open' for open network (aka. no password).
ENCRYPTION='WPA'
# Network password. (WPA-PSK/WPA2-PSK password, or WEP key)
PASSWORD='network_password_goes_here'
###############################################################
#################### OK. STOP EDITING! ####################
###############################################################
if [ $(id -u) -ne 0 ]; then
printf "This script must be run as root. \n"
exit 1
fi
NETID=$(wpa_cli add_network | tail -n 1)
wpa_cli set_network $NETID ssid \"$SSID\"
case $ENCRYPTION in
'WPA')
wpa_cli set_network $NETID key_mgmt WPA-PSK
wpa_cli set_network $NETID psk \"$PASSWORD\"
;;
'WEP')
wpa_cli set_network $NETID wep_key0 $PASSWORD
wpa_cli set_network $NETID wep_key1 $PASSWORD
wpa_cli set_network $NETID wep_key2 $PASSWORD
wpa_cli set_network $NETID wep_key3 $PASSWORD
;;
*)
;;
esac
wpa_cli enable_network $NETID
wpa_cli save_config