fixed ad-hoc device getting ip address

naxalnet no longer creates temporary directories,
since the networkd configs no longer have device
names engraved in them.
This commit is contained in:
Pranav Jerry 2021-05-11 11:29:38 +05:30
parent b2727231d0
commit 8d318a5b13
2 changed files with 10 additions and 19 deletions

View File

@ -1,7 +1,5 @@
#!/usr/bin/env bash
DATADIR="$(dirname "$0")/../share/naxalnet"
NETWORKD_DIR=/run/systemd/network
SSID="Hello World"
@ -13,33 +11,25 @@ then
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"
# Copies all files in DATADIR to NETWORKD_DIR
find "$DATADIR" -type f -execdir cp -t "$NETWORKD_DIR" {} +
echo "Linking resolv.conf to resolved stub-resolved.conf"
echo "Linking resolv.conf to systemd-resolved's 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
systemctl reload-or-restart iwd systemd-resolved systemd-networkd
# wait five seconds for iwd to start
sleep 5
#sleep 5
echo "Configuring iwd"
iwctl device $1 set-property Mode ad-hoc
iwctl ad-hoc $1 start_open "$SSID"
iwctl device "$1" set-property Mode ad-hoc
iwctl ad-hoc "$1" start_open "$SSID"
echo "Done"

View File

@ -1,6 +1,7 @@
[Match]
# this line will be changed by sed
WLANInterfaceType={ADHOC_NETWORK}
# This will match all networks in ad-hoc mode.
# It assumes there is only one interface in ad-hoc mode.
WLANInterfaceType=ad-hoc
[Network]
Description=ad-hoc network connecting to other nodes