summaryrefslogblamecommitdiffstats
path: root/builder/modules.d/wlan-boot/hooks/parse-wlan-kernel-command-line-parameter.sh
blob: dbda284c99a29bb39d21d400233737ef925c621f (plain) (tree)





































                                                                   
#!/bin/sh

# this hook will be executed in cmdline as 10

# generate the config file for wpa_supplicant from
# the kernel commandline parameters

WIFACE=wlan0
CONFDIR=/etc/
WPACONF="$CONFDIR"/wpa_supplicant.conf

type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh

SSID=$(getarg ssid=)
PASSWORD=$(getarg pw=)
USERNAME=$(getarg user=)

if [ "$SSID" = "eduroam" ]; then
    # write ssid and pw in wpa_supplicant.conf
    cat > "$WPACONF" << EOF
    # path to UNIX socket control interface
    ctrl_interface=/var/run/wpa_supplicant
    ap_scan=1
    network={
        ssid="$SSID"
        proto=RSN
        key_mgmt=WPA-EAP
        eap=TTLS
        identity="$USERNAME"
        password="$PASSWORD"
        ca_cert="$CONFDIR/ssl/certs/Deutsche_Telekom_Root_CA_2.pem"
        phase2="auth=MSCHAPv2"
    }
EOF
else
    echo "ctrl_interface=/var/run/wpa_supplicant" > "$WPACONF"
    wpa_passphrase "$SSID" "$PASSWORD" >> "$WPACONF"
fi