2022-12-13 17:33:20 +01:00
|
|
|
#!/usr/bin/env bash
|
2023-08-11 17:19:18 +02:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2022-12-13 17:33:20 +01:00
|
|
|
#
|
|
|
|
# archboot-hwsim.sh - setup a test SSID
|
|
|
|
# by Tobias Powalowski <tpowa@archlinux.org>
|
|
|
|
# usage(exitvalue)
|
|
|
|
# outputs a usage message and exits with value
|
2023-09-05 08:34:45 +02:00
|
|
|
. /usr/lib/archboot/common.sh
|
2023-04-23 21:50:36 +02:00
|
|
|
_APPNAME=${0##*/}
|
2023-01-09 18:28:06 +01:00
|
|
|
_usage()
|
2022-12-13 17:33:20 +01:00
|
|
|
{
|
2023-02-07 20:19:31 +01:00
|
|
|
echo -e "\e[1mWelcome to \e[34marchboot's\e[m \e[1mHWSIM:\e[m"
|
|
|
|
echo -e "\e[1m---------------------------------------\e[m"
|
2022-12-13 17:40:26 +01:00
|
|
|
echo "Create a simulated wireless SSID for testing purposes"
|
|
|
|
echo "with mac80211_hwsim module."
|
2022-12-13 17:48:39 +01:00
|
|
|
echo "- wlan0 will be setup as the AP. Don't use for scanning!"
|
2022-12-13 17:50:12 +01:00
|
|
|
echo "- wlan1 will be setup for STATION mode. Use this for scanning for your AP."
|
2023-04-24 07:02:39 +02:00
|
|
|
echo ""
|
2023-02-07 20:19:31 +01:00
|
|
|
echo -e "usage: \e[1m${_APPNAME} <SSID>\e[m"
|
2022-12-13 17:39:43 +01:00
|
|
|
exit 0
|
2022-12-13 17:33:20 +01:00
|
|
|
}
|
2023-01-09 18:38:55 +01:00
|
|
|
[[ -z "${1}" ]] && _usage
|
2023-09-05 08:34:45 +02:00
|
|
|
echo "Installing kernel..."
|
|
|
|
pacman -Sydd --noconfirm --noscriptlet linux &>"${_LOG}"
|
2023-09-05 08:30:39 +02:00
|
|
|
depmod -a
|
2022-12-13 17:17:17 +01:00
|
|
|
if ! grep -qw mac80211_hwsim /proc/modules; then
|
2022-12-13 17:15:30 +01:00
|
|
|
modprobe mac80211_hwsim
|
|
|
|
fi
|
|
|
|
iwctl ap wlan0 stop
|
2022-12-13 17:24:32 +01:00
|
|
|
systemctl restart iwd
|
|
|
|
sleep 2
|
2022-12-13 17:15:30 +01:00
|
|
|
iwctl device wlan0 set-property Mode ap
|
|
|
|
iwctl device wlan0 set-property Powered on
|
2023-02-07 20:19:31 +01:00
|
|
|
iwctl ap wlan0 start "${1}" "12345678" && echo -e "\e[1mSSID:'${1}' with password '12345678' is online now.\e[m"
|