mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-11-10 15:22:02 +05:30
46 lines
906 B
Bash
Executable File
46 lines
906 B
Bash
Executable File
#!/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
|
|
|
|
echo "creating and copying file to tmp dir"
|
|
TMPDIR=$(mktemp -d)
|
|
cd "$TMPDIR"
|
|
cp -r $DATADIR/* .
|
|
|
|
|
|
echo "Setting $1 as wireless device"
|
|
sed -i "s/{ADHOC_NETWORK}/$1/" *.network
|
|
|
|
if [[ ! -d "$NETWORKD_DIR" ]]
|
|
then
|
|
mkdir "$NETWORKD_DIR"
|
|
fi
|
|
|
|
echo "Copying systemd-networkd config files"
|
|
cp * "$NETWORKD_DIR"
|
|
|
|
echo "Linking resolv.conf to resolved stub-resolved.conf"
|
|
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
|
|
|
echo "Starting services"
|
|
systemctl reload-or-restart systemd-resolved iwd systemd-networkd
|
|
|
|
# wait five seconds for iwd to start
|
|
sleep 5
|
|
echo "Configuring iwd"
|
|
iwctl device $1 set-property Mode ad-hoc
|
|
iwctl ad-hoc $1 start_open "$SSID"
|
|
|
|
echo "Done"
|