diff --git a/naxalnet b/naxalnet index c4e109d..c333bdd 100755 --- a/naxalnet +++ b/naxalnet @@ -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" diff --git a/systemd-networkd/03-wireless-ad-hoc.network b/systemd-networkd/03-wireless-ad-hoc.network index cd47b29..f40b3e6 100644 --- a/systemd-networkd/03-wireless-ad-hoc.network +++ b/systemd-networkd/03-wireless-ad-hoc.network @@ -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