You are not logged in.

#1 2015-08-31 20:34:54

xn2015
Member
Registered: 2015-08-31
Posts: 2

Run macchanger using systemd if interface exists

Hi,
I was trying to do mac address spoofing using the method for systemd unit and macchanger described in this tutorial https://wiki.archlinux.org/index.php/MA … s_spoofing.
My operating system is ran on different computers. Therefore, wlan0 might not exist on the other computer.
On boot time, systemd still run macspoof@.service unit. It is basically timing out because wlan0 doesn't exist. I don't want to wait for 2 minutes for the timeout.
Is there a way to tell systemd to not run the unit if interface wlan0 doesn't exist?
I tried with

ConditionPathIsSymbolicLink=/sys/class/net/%i

but it doesn't do as described in the manpage (http://www.freedesktop.org/software/sys … .unit.html).

Here is my  macspoof@.service unit:

[Unit]
Description=Run macchanger on %i
Wants=network-pre.target
Before=network-pre.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
ConditionPathIsSymbolicLink=/sys/class/net/%i

[Service]
Type=oneshot
ExecStart=/usr/bin/macchanger -e %i

[Install]
WantedBy=multi-user.target

thx for your help!

Last edited by xn2015 (2015-08-31 20:43:54)

Offline

#2 2015-08-31 22:35:41

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Run macchanger using systemd if interface exists

What do you mean "my operating system is ran on different computers"? Are you just copying everything including system-specific configuration files from one computer to another? Why can't you just enable the service for each interface on each computer?

If you're plugging and unplugging an external wi-fi adapter then you should probably use a udev hook to do this.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2015-09-01 13:28:14

xn2015
Member
Registered: 2015-08-31
Posts: 2

Re: Run macchanger using systemd if interface exists

Xyne wrote:

What do you mean "my operating system is ran on different computers"? Are you just copying everything including system-specific configuration files from one computer to another? Why can't you just enable the service for each interface on each computer?

It means that my operating system is ran from a USB key. I plug the USB key on different computers to boot up. It is a live system, running from memory.

Offline

#4 2015-09-02 06:15:09

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Run macchanger using systemd if interface exists

Why don't you run the service manually, whenever wlan0 exists.

Offline

#5 2015-09-02 09:30:10

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Run macchanger using systemd if interface exists

xn2015 wrote:

It is basically timing out because wlan0 doesn't exist.
[snip]
but it doesn't do as described in the manpage (http://www.freedesktop.org/software/sys … .unit.html).

Could you show the exact messages systemd generates? Did they change after adding that Condition?

The man page describes BindsTo as "very similar in style to Requires=" without going into further details. Perhaps that is part of the problem.

Last edited by Raynman (2015-09-02 09:31:39)

Offline

Board footer

Powered by FluxBB