2021-05-10 15:15:42 +05:30
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
DATADIR="$(dirname "$0")/../share/naxalnet"
|
|
|
|
NETWORKD_DIR=/run/systemd/network
|
|
|
|
SSID="Hello World"
|
|
|
|
|
|
|
|
if [[ $# != 1 ]]
|
|
|
|
then
|
|
|
|
echo "Usage: $0 {wireless device}"
|
|
|
|
echo "Example: $0 wlan0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d "$NETWORKD_DIR" ]]
|
|
|
|
then
|
|
|
|
mkdir "$NETWORKD_DIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Copying systemd-networkd config files"
|
2021-05-11 11:29:38 +05:30
|
|
|
# Copies all files in DATADIR to NETWORKD_DIR
|
|
|
|
find "$DATADIR" -type f -execdir cp -t "$NETWORKD_DIR" {} +
|
2021-05-10 15:15:42 +05:30
|
|
|
|
2021-05-11 11:29:38 +05:30
|
|
|
echo "Linking resolv.conf to systemd-resolved's stub-resolved.conf"
|
2021-05-10 15:15:42 +05:30
|
|
|
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
|
|
|
|
|
|
|
echo "Starting services"
|
2021-05-11 11:29:38 +05:30
|
|
|
systemctl reload-or-restart iwd systemd-resolved systemd-networkd
|
2021-05-10 15:15:42 +05:30
|
|
|
|
|
|
|
# wait five seconds for iwd to start
|
2021-05-11 11:29:38 +05:30
|
|
|
#sleep 5
|
2021-05-10 15:15:42 +05:30
|
|
|
echo "Configuring iwd"
|
2021-05-11 11:29:38 +05:30
|
|
|
iwctl device "$1" set-property Mode ad-hoc
|
|
|
|
iwctl ad-hoc "$1" start_open "$SSID"
|
2021-05-10 15:15:42 +05:30
|
|
|
|
|
|
|
echo "Done"
|