diff --git a/init.d/networking b/init.d/networking index b412f56..7e31d20 100644 --- a/init.d/networking +++ b/init.d/networking @@ -22,6 +22,8 @@ CONFIGURE_INTERFACES=yes EXCLUDE_INTERFACES= VERBOSE=no +verbose= + [ -f /etc/default/networking ] && . /etc/default/networking [ "$VERBOSE" = yes ] && verbose=-v @@ -128,7 +130,7 @@ start) set -f exclusions=$(process_exclusions) log_action_begin_msg "Configuring network interfaces" - if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose + if ifup -a $verbose --perfmode then log_action_end_msg $? else @@ -144,7 +146,7 @@ stop) check_network_swap log_action_begin_msg "Deconfiguring network interfaces" - if ifdown -a --exclude=lo $verbose; then + if ifdown -a --exclude=lo $verbose --perfmode --force; then log_action_end_msg $? else log_action_end_msg $? @@ -156,7 +158,7 @@ reload) log_action_begin_msg "Reloading network interfaces configuration" state=$(cat /run/network/ifstate) - ifdown -a --exclude=lo $verbose || true + ifdown -a --exclude=lo $verbose --perfmode --force || true if ifup --exclude=lo $state $verbose ; then log_action_end_msg $? else @@ -172,10 +174,10 @@ force-reload|restart) #log_warning_msg "Running $0 $1 is deprecated because it may not re-enable some interfaces" log_action_begin_msg "Reconfiguring network interfaces" - ifdown -a --exclude=lo $verbose || true + ifdown -a --exclude=lo $verbose --perfmode --force || true set -f exclusions=$(process_exclusions) - if ifup -a --exclude=lo $exclusions $verbose && ifup_hotplug $exclusions $verbose + if ifup -a --exclude=lo $verbose --perfmode then log_action_end_msg $? else diff --git a/pkg/ifupdownmain.py b/pkg/ifupdownmain.py index 37d8e4c..1a8084c 100644 --- a/pkg/ifupdownmain.py +++ b/pkg/ifupdownmain.py @@ -259,7 +259,7 @@ class ifupdownMain(): continue dlist = module.get_dependent_ifacenames(ifaceobj, self.ifaceobjdict.keys()) - if dlist: + if dlist is not None: self.logger.debug('%s: ' %ifaceobj.get_name() + 'got dependency list: %s' %str(dlist)) break diff --git a/pkg/networkinterfaces.py b/pkg/networkinterfaces.py index 16d1bba..4bf3595 100644 --- a/pkg/networkinterfaces.py +++ b/pkg/networkinterfaces.py @@ -89,6 +89,7 @@ class networkInterfaces(): def process_iface(self, lines, cur_idx, lineno): lines_consumed = 0 + line_idx = cur_idx ifaceobj = iface() @@ -174,47 +175,64 @@ class networkInterfaces(): return classes - - def read_file(self, filename=None): + def process_filedata(self, filedata): lineno = 0 line_idx = 0 lines_consumed = 0 + raw_lines = filedata.split('\n') + lines = [l.strip(' \n') for l in raw_lines] + + while (line_idx < len(lines)): + lineno = lineno + 1 + + if self.ignore_line(lines[line_idx]): + line_idx += 1 + continue + + words = lines[line_idx].split() + + # Check if first element is a supported keyword + if self.is_keyword(words[0]): + keyword_func = self.get_keyword_func(words[0]) + lines_consumed = keyword_func(self, lines, line_idx, lineno) + line_idx += lines_consumed + else: + self.logger.warning('could not process line %s' %l + ' at' + + ' lineno %d' %lineno) + + line_idx += 1 + + return 0 + + def run_template_engine(self, textdata): + try: + from mako.template import Template + except: + self.logger.warning('template engine mako not found ' + + 'skipping template parsing'); + return textdata + + t = Template(text=textdata, output_encoding='utf-8') + return t.render() + + def read_file(self, filename=None): ifaces_file = filename if ifaces_file == None: ifaces_file=self.ifaces_file self.logger.debug('reading ifaces_file %s' %ifaces_file) + f = open(ifaces_file) + filedata = f.read() + f.close() - with open(ifaces_file) as f: - raw_lines = f.readlines() - lines = [l.strip(' \n') for l in raw_lines] + # process line continuations + filedata = ' '.join(d.strip() for d in filedata.split('\\')) - while (line_idx < len(lines)): - lineno = lineno + 1 + # run through template engine + filedata = self.run_template_engine(filedata) - if self.ignore_line(lines[line_idx]): - line_idx += 1 - continue - - words = lines[line_idx].split() - - # Check if first element is a supported keyword - if self.is_keyword(words[0]): - keyword_func = self.get_keyword_func( - words[0]) - lines_consumed = keyword_func(self, - lines, line_idx, lineno) - - line_idx += lines_consumed - else: - self.logger.warning('could not ' + - 'process line %s' %l + ' at' + - ' lineno %d' %lineno) - - line_idx += 1 - - return 0 + self.process_filedata(filedata) def load(self, filename=None):