#! /bin/sh

# Get the SSID and Password from arguments
SSID=$1
PASSWORD=$2

# default SSID and Password
if [ -z "$SSID" ]; then
    SSID="WEB-888"
fi

if [ -z "$PASSWORD" ]; then
    PASSWORD="88888888"
fi

wpa_passphrase "$SSID" "$PASSWORD" > /etc/wpa_supplicant/wpa_supplicant.conf

openrc default

rc-update del wpa_supplicant wifi

rc-update add iptables wifi
rc-update add dnsmasq wifi
rc-update add hostapd wifi

sed -i '/^#interface wlan0/{s/^#interface/interface/;n;s/^#static/static/}' /etc/dhcpcd.conf

service dhcpcd restart
