diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 02:06:17 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 02:06:17 +0200 |
commit | 54eecdabe0cdfdc47d77b3e182fda5899702ded7 (patch) | |
tree | 8e28d750773f0aa38f0d2de83109b190faf0b425 /recipes-core/net-persistent-mac/net-persistent-mac/init | |
download | meta-fsl-arm-extra-daisy-140929.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'recipes-core/net-persistent-mac/net-persistent-mac/init')
-rw-r--r-- | recipes-core/net-persistent-mac/net-persistent-mac/init | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/recipes-core/net-persistent-mac/net-persistent-mac/init b/recipes-core/net-persistent-mac/net-persistent-mac/init new file mode 100644 index 0000000..a2e2863 --- /dev/null +++ b/recipes-core/net-persistent-mac/net-persistent-mac/init | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ### BEGIN INIT INFO | ||
4 | # Provides: net-persistent-mac | ||
5 | # Required-Start: $local_fs | ||
6 | # Required-Stop: | ||
7 | # Default-Start: S | ||
8 | # Default-Stop: | ||
9 | # X-Start-Before: networking | ||
10 | # Short-Description: restore MAC during boot process | ||
11 | ### END INIT INFO | ||
12 | |||
13 | set -e | ||
14 | |||
15 | [ -f /etc/default/net-persistent-mac ] && . /etc/default/net-persistent-mac | ||
16 | |||
17 | MAC_DIR="/var/lib/net-persistent-mac" | ||
18 | |||
19 | for if in $INTERFACES; do | ||
20 | mkdir -p "$MAC_DIR" | ||
21 | IF_FILE="$MAC_DIR/$if.mac" | ||
22 | IF_MAC="/sys/class/net/$if/address" | ||
23 | |||
24 | # Store MAC for reuse | ||
25 | if [ ! -r "$IF_FILE" ]; then | ||
26 | if [ -e "$IF_MAC" ]; then | ||
27 | echo "Storing MAC for $if for future use." > /dev/stderr | ||
28 | cat "$IF_MAC" > "$IF_FILE" | ||
29 | else | ||
30 | echo "Failed to read MAC for $if; skiping device." | ||
31 | fi | ||
32 | fi | ||
33 | |||
34 | if [ -r "$IF_FILE" ]; then | ||
35 | # Restore MAC setting | ||
36 | WANTED_MAC=`cat $IF_FILE` | ||
37 | if [ "$WANTED_MAC" != "`cat $IF_MAC`" ]; then | ||
38 | echo "Setting MAC of $if to $WANTED_MAC." | ||
39 | ifconfig $if hw ether "$WANTED_MAC" | ||
40 | fi | ||
41 | fi | ||
42 | done | ||