mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-15 04:42:06 +00:00
parent
be8dc5c5bb
commit
1e3b7dd011
2 changed files with 57 additions and 5 deletions
52
res/write-udev-rule.sh
Executable file
52
res/write-udev-rule.sh
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
./kill-wpa.sh
|
||||||
|
|
||||||
|
. miracle-utils.sh
|
||||||
|
|
||||||
|
ETHER_NAMES=$(find_choosable_networknames)
|
||||||
|
|
||||||
|
ETHER_COUNT=$(echo "$ETHER_NAMES" | wc -l)
|
||||||
|
|
||||||
|
if [ 0 = $ETHER_COUNT ]
|
||||||
|
then
|
||||||
|
echo There is no net devices avaliable
|
||||||
|
exit 1
|
||||||
|
elif [ 1 = $ETHER_COUNT ]
|
||||||
|
then
|
||||||
|
ETHERNAME="$ETHER_NAMES"
|
||||||
|
elif [ 2 -le $ETHER_COUNT ]
|
||||||
|
then
|
||||||
|
echo choose device for normal connection:
|
||||||
|
QUIT="exit"
|
||||||
|
select et_name in $ETHER_NAMES $QUIT
|
||||||
|
do
|
||||||
|
case $et_name
|
||||||
|
in
|
||||||
|
"$QUIT")
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
if [ "$REPLY" = $QUIT ]
|
||||||
|
then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
echo unknow $REPLY
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ETHERNAME=$et_name
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# default path for config file
|
||||||
|
CONFIG_FILE=${1:-/run/network/wpa_supplicant_${ETHERNAME}.conf}
|
||||||
|
|
||||||
|
NUMBER=10
|
||||||
|
|
||||||
|
cat > /etc/udev/rules.d/${NUMBER}-network.rules << EOF
|
||||||
|
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="$(cat /sys/class/net/${ETHERNAME}/address)", NAME="${ETHERNAME}", TAGS+="miracle"
|
||||||
|
EOF
|
|
@ -40,7 +40,7 @@
|
||||||
#include "wifid.h"
|
#include "wifid.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define DO_NOT_RELY_UDEV 0
|
#define RELY_UDEV 0
|
||||||
|
|
||||||
const char *arg_wpa_bindir = "/usr/bin";
|
const char *arg_wpa_bindir = "/usr/bin";
|
||||||
unsigned int arg_wpa_loglevel = LOG_NOTICE;
|
unsigned int arg_wpa_loglevel = LOG_NOTICE;
|
||||||
|
@ -100,7 +100,7 @@ static void manager_add_udev_link(struct manager *m,
|
||||||
|
|
||||||
link_set_friendly_name(l, m->friendly_name);
|
link_set_friendly_name(l, m->friendly_name);
|
||||||
|
|
||||||
#if DO_NOT_RELY_UDEV
|
#if RELY_UDEV
|
||||||
if (udev_device_has_tag(d, "miracle"))
|
if (udev_device_has_tag(d, "miracle"))
|
||||||
#endif
|
#endif
|
||||||
link_set_managed(l, true);
|
link_set_managed(l, true);
|
||||||
|
@ -138,13 +138,13 @@ static int manager_udev_fn(sd_event_source *source,
|
||||||
link_renamed(l, ifname);
|
link_renamed(l, ifname);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DO_NOT_RELY_UDEV
|
#if RELY_UDEV
|
||||||
link_set_managed(l, true);
|
|
||||||
#else
|
|
||||||
if (udev_device_has_tag(d, "miracle"))
|
if (udev_device_has_tag(d, "miracle"))
|
||||||
link_set_managed(l, true);
|
link_set_managed(l, true);
|
||||||
else
|
else
|
||||||
link_set_managed(l, false);
|
link_set_managed(l, false);
|
||||||
|
#else
|
||||||
|
link_set_managed(l, true);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
manager_add_udev_link(m, d);
|
manager_add_udev_link(m, d);
|
||||||
|
|
Loading…
Reference in a new issue