-
Notifications
You must be signed in to change notification settings - Fork 0
/
wlankeygen
executable file
·30 lines (23 loc) · 1.39 KB
/
wlankeygen
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
#!/bin/bash
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
WORKDIR=/var/guestwlan
HOSTAPDCONF=$WORKDIR/config-files/etc-hostapd-hostapd.conf
MOBILECONFIGTEMPLATE=$WORKDIR/guestwlan.mobileconfig.in
source $WORKDIR/config
WLANPSK=$(dd if=/dev/urandom count=1 status=none | tr -d -c 'a-z' | cut -b1-10)
sed -i -e "s/^ssid=.*/ssid=${WLANSSID}/" $HOSTAPDCONF
sed -i -e "s/^wpa_passphrase=.*/wpa_passphrase=${WLANPSK}/" $HOSTAPDCONF
service hostapd reload
qrencode -t PNG -o ${WORKDIR}/qr_android.png -v 10 -l H "WIFI:T:WPA;S:${WLANSSID};P:${WLANPSK};H:false;"
qrencode -t PNG -o ${WORKDIR}/qr_windows.png -v 10 -l H "WIFI;T:WPA;S:${WLANSSID};P:${WLANPSK};H:false;"
sed -e "s/__wlanssid__/${WLANSSID}/g" $MOBILECONFIGTEMPLATE > /var/www/html/${WLANPSK}.mobileconfig
sed -i -e "s/<string>__wlanpsk__/<string>${WLANPSK}/" /var/www/html/${WLANPSK}.mobileconfig
qrencode -t PNG -o ${WORKDIR}/qr_ios.png -v 10 -l H "${DOMAIN}:${EXTERNALPORT}/${WLANPSK}.mobileconfig"
gm convert -page +0+0 ${WORKDIR}/qr_android.png -page +69+65 ${WORKDIR}/assets/android.png -mosaic ${WORKDIR}/android.png
gm convert -page +0+0 ${WORKDIR}/qr_windows.png -page +69+69 ${WORKDIR}/assets/windows.png -mosaic ${WORKDIR}/windows.png
gm convert -page +0+0 ${WORKDIR}/qr_ios.png -page +69+69 ${WORKDIR}/assets/ios.png -mosaic ${WORKDIR}/ios.png
echo "DONE"