blob: 1899e95f925f52cd6b8e37e6f5cc1fd53fe54dc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: Random MAC address generator
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set a random MAC for tagged interfaces
# Description: Set a random MAC for interfaces with RANDOM_MAC
### END INIT INFO
# Author: Darren Hart <dvhart@linux.intel.com>
# Based on /etc/init.d/skeleton
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Set a random MAC for tagged interfaces"
NAME=genmac
RANPWD=`which ranpwd`
SCRIPTNAME=/etc/init.d/$NAME
# Exit if ranpwd is not installed
[ -x "$RANPWD" ] || exit 0
do_start() {
# Replace every occurence of RANDOM_MAC with a unique locally
# administered, unicast, randomly generated MAC address.
while grep -q RANDOM_MAC /etc/network/interfaces; do
sed -i "1,/RANDOM_MAC/s/RANDOM_MAC/$($RANPWD -m)/" /etc/network/interfaces
done
}
case "$1" in
start)
echo "$NAME: Setting random MAC addresses"
do_start
;;
stop)
;;
*)
echo "Usage: $SCRIPTNAME {start|stop}" >&2
exit 3
;;
esac
exit 0
|