tails-unblock-network 1.75 KB
Newer Older
1
2
#!/bin/sh

3
set -e
4
set -u
5
6
set -x

7
8
systemctl start tails-unblock-network.service

9
10
11
12
13
14
15
16
# Without this, network is sometimes not unblocked, probably due to some
# race condition between tails-unblock-network.service (that deletes the
# blacklist file) and udevadm trigger, possibly caused by yet another aufs
# weirdness (#9012)...
echo "Sleeping..." >&2
sleep 2
echo "slept." >&2

17
18
19
# Now we'll load any present network device previously blocked by
# the blacklist. In particular, the MAC spoofing udev rule should trigger
# for each network device added.
20
echo "Restarting systemd-udev-trigger.service..." >&2
21
systemctl restart systemd-udev-trigger.service
22
echo "systemd-udev-trigger.service restarted." >&2
23
24
25
26
27
28

# Block until all triggers have been run. NetworkManager is started immediately
# after, and without the blocking behaviour there's a race between NM
# and the MAC spoof udev triggers. When NM takes control of some network device,
# some operations are not possible on the device, like MAC spoofing. Hence,
# if NM wins, the udev-triggered run of tails-spoof-mac will fail.
29
echo "Restarting systemd-udev-settle.service..." >&2
30
systemctl restart systemd-udev-settle.service
31
echo "systemd-udev-settle.service restarted." >&2
32
33
34
35
36

# Enable and start NetworkManager services
# No need to manually enable NetworkManager-dispatcher.service,
# as NetworkManager.service has "Also=NetworkManager-dispatcher.service"
# in its [Install] section.
37
# If tails-spoof-mac goes into panic mode but fails to disable the
38
39
40
41
# problematic device, the NetworkManager services will be masked.
systemctl enable NetworkManager.service NetworkManager-wait-online.service || :
systemctl start NetworkManager.service NetworkManager-dispatcher.service || :
systemctl --no-block start NetworkManager-wait-online.service || :