]> git.ipfire.org Git - people/ms/network.git/blob - udev/network-hotplug-rename
Fix hotplugging with udev.
[people/ms/network.git] / udev / network-hotplug-rename
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 # Setup logging.
23 LOG_FACILITY="network-hotplug-rename"
24 LOG_DISABLE_STDOUT="true"
25
26 . /usr/lib/network/functions
27
28 # Setup the locking.
29 LOCKFILE="${RUN_DIR}/.rename_lock"
30 function cleanup() {
31 lock_release ${LOCKFILE}
32 }
33 trap cleanup EXIT TERM KILL
34
35 # Check if the INTERFACE variable is properly set.
36 assert isset INTERFACE
37
38 # Log what we are doing here.
39 log DEBUG "Called for interface '${INTERFACE}'."
40
41 # Acquiring lock for this operation.
42 lock_acquire ${LOCKFILE}
43
44 # Get the name of that device from the configuration
45 # or return a new one if it is unknown.
46 device_hotplug ${INTERFACE}
47
48 exit $?