3 # Takes as input a reference to an encoded configuration file
4 # and produces from that a kernel module file and a network
5 # configuration file. It then restarts the networking service
6 # and saves the configuration files.
8 .
/usr
/libexec
/ovirt-functions
11 warn
() { printf '%s: %s\n' "$ME" "$*" >&2; }
12 die
() { warn
"$*"; exit 1; }
14 try_h
() { printf "Try \`$ME -h' for more information.\n" >&2; exit 1;}
15 try_help
() { printf "Usage: \`$ME [config] [module output] [config output]\n" >&2; exit 1;}
18 0|
1|
2) warn
"too few arguments"; try_help
;;
20 *) warn
"too many arguments"; try_help
;;
24 OVIRT_KERNEL_MODULE_FILE
=$2
25 OVIRT_CONFIG_OUTPUT_FILE
=$3
27 modconf
=$
(awk '/^[ \t]*bonding=.+/ {
28 match($0, "^[ \t]*bonding=(.+)", data)
29 printf "data[2] = %s\n", data[2]
31 if (match("[^[:alnum:]=_@-]", data[2]) >= 0) {
32 printf "invalid bonding alias: \"%s\"\n", data[2];
38 printf("install %s bonding", alias)
41 echo "$modconf" > $OVIRT_KERNEL_MODULE_FILE
43 networking
=$
(awk '/^[ \t]*ifcfg=/ {
44 match($0, "^[ \t]*ifcfg=(.*)", data)
45 split(data[1], ifcfg, "|")
49 ifcfg_dir = "/files/etc/sysconfig/network-scripts"
51 printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface)
52 printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface)
56 match(ifcfg[line], "(^[^=]+)=(.*)", values)
60 if(length(field) == 0) {
61 print "Missing field name."
65 if(length(value) == 0) {
66 print "Missing field value."
70 printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value)
78 if [ $SUCCESS != 0 ]; then
80 1) error
="missing field name";;
81 2) error
="missing field value";;
84 die
"Bad data received: ${error}"
87 echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE
89 if [ -f $OVIRT_CONFIG_OUTPUT_FILE ]; then
90 augtool
$OVIRT_CONFIG_OUTPUT_FILE \
91 && RESULT
=0 || RESULT
=1
92 # FIXME do not store ifcfg-lo
93 if ls /etc
/sysconfig
/network-scripts
/ifcfg
* >/dev
/null
2>/dev
/null
; then
94 ovirt_store_config
/etc
/sysconfig
/network-scripts
/ifcfg
*