Skip to content

Fix debug flag handling #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions changeInterface.awk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function writeStatic(addr, nw, nm, gw) {
function usage() {
print "awk -f changeInterfaces.awk <interfaces file> device=<eth device> \n" \
" [address=<ip addr>] [gateway=<ip addr>] [netmask=<ip addr>]\n" \
" [network=<ip addr>] [mode=dhcp|static] [arg=debug]"
" [network=<ip addr>] [mode=dhcp|static] [debug]"
}

BEGIN { start = 0;
Expand All @@ -26,6 +26,13 @@ BEGIN { start = 0;
}

for (i = 2; i < ARGC; i++) {

if (ARGV[i] == "debug") {
debug = 1;
delete ARGV[i];
continue;
}

split(ARGV[i], pair, "=");
if (pair[1] == "address")
address = pair[2];
Expand All @@ -37,8 +44,6 @@ BEGIN { start = 0;
netmask = pair[2];
else if (pair[1] == "device")
device = pair[2];
else if (pair[1] == "arg" && pair[2] == "debug")
debug = 1;
else if (pair[1] == "mode" && pair[2] == "dhcp")
dhcp = 1;
else if (pair[1] == "mode" && pair[2] == "static")
Expand Down
18 changes: 16 additions & 2 deletions readInterfaces.awk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ BEGIN { start = 0;
}

for (i = 2; i < ARGC; i++) {
if (ARGV[i] == debug) {

if (ARGV[i] == "debug") {
debug = 1;
delete ARGV[i];
continue;
}

split(ARGV[i], arg, "=");
if (arg[1] == "device")
device = arg[2];
Expand Down Expand Up @@ -52,13 +55,24 @@ BEGIN { start = 0;
}
}

if ($1 == "auto") {
static = 0;
next;
}

# Skip comment and blank lines
if ($0 ~ /^#/ ||
$0 ~ /^[ \t]*$/ ) {
next;
}

# At here, it means we are after the iface static line of
# after the device we are searching for
# Scan for the static content
if (static) {

if (debug)
print "static - ", $0, $1;
print $0

if ($1 == "address") {
address = $2;
Expand Down