summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-04-15 11:51:43 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2012-04-15 11:51:43 +0200
commit6ed6803d0dd8cd3fc93208d614c3558b962a654e (patch)
tree2cdb4c71787965334f7be6352c5a12c757d30c1b
parentc96f443ea84f8041c4b1bdea56f36d9a0d827cf6 (diff)
downloadnetctl-6ed6803d0dd8cd3fc93208d614c3558b962a654e.tar.gz
netctl-6ed6803d0dd8cd3fc93208d614c3558b962a654e.tar.xz
Restore support for kernel command line
It is once again possible to use NET= at the kernel command line when using net-profiles.
-rw-r--r--Makefile7
-rwxr-xr-xrc.d/net-profiles26
-rw-r--r--rc.d/net-set-variable10
-rwxr-xr-xscripts/netcfg-menu11
-rw-r--r--systemd/netcfg@.service2
5 files changed, 30 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 7ab32ea..2b7ad63 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ export VERSION = 2.8.0
install: install-docs
# Configuration files
install -d $(DESTDIR)/etc/network.d/{examples,interfaces}
- install -D -m644 config/netcfg $(DESTDIR)/etc/conf.d/netcfg
+ install -Dm644 config/netcfg $(DESTDIR)/etc/conf.d/netcfg
install -m644 config/iftab $(DESTDIR)/etc/iftab
install -m644 docs/examples/* $(DESTDIR)/etc/network.d/examples/
# Libs
@@ -26,7 +26,7 @@ install: install-docs
$(DESTDIR)/usr/bin/
install -Dm755 scripts/ifplugd.action $(DESTDIR)/etc/ifplugd/netcfg.action
# Daemons
- install -d $(DESTDIR)/etc/rc.d
+ install -Dm755 rc.d/net-set-variable $(DESTDIR)/etc/rc.d/functions.d/net-set-variable
install -m755 \
rc.d/net-profiles \
rc.d/net-rename \
@@ -39,9 +39,8 @@ install: install-docs
$(DESTDIR)/usr/lib/systemd/system/
install-docs: docs
- install -d $(DESTDIR)/usr/share/man/man5
+ install -d $(DESTDIR)/usr/share/man/{man5,man8}
install -m644 docs/*.5 $(DESTDIR)/usr/share/man/man5/
- install -d $(DESTDIR)/usr/share/man/man8
install -m644 docs/*.8 $(DESTDIR)/usr/share/man/man8/
install -d $(DESTDIR)/usr/share/doc/netcfg/contrib
install -m644 docs/*.html $(DESTDIR)/usr/share/doc/netcfg/
diff --git a/rc.d/net-profiles b/rc.d/net-profiles
index 66f0851..ae9c00e 100755
--- a/rc.d/net-profiles
+++ b/rc.d/net-profiles
@@ -14,7 +14,7 @@ case "$1" in
# Ensure any device renaming has occurred as intended
for daemon in "${DAEMONS[@]}"; do
- if [[ "$daemon" = "net-rename" ]]; then
+ if [[ $daemon = net-rename ]]; then
if ck_daemon net-rename; then
/etc/rc.d/net-rename start
fi
@@ -22,23 +22,19 @@ case "$1" in
done
# $NET env var is passed from the kernel boot line
- if [[ "$NET" = "menu" ]]; then
- if /usr/bin/netcfg-menu; then
- mv "$STATE_DIR"/{menu,netcfg-daemon} # JP: user may want to disconnect profile by calling net-profiles stop
- add_daemon net-profiles
- exit 0
+ if [[ -n $NET ]]; then
+ # Record the connected profile for net-profiles stop
+ if [[ $NET = menu ]]; then
+ /usr/bin/netcfg-menu || exit 1
+ mv "$STATE_DIR"/{menu,netcfg-daemon}
+ else
+ /usr/bin/netcfg check-iface "$NET" || exit 1
+ echo "$NET" > "$STATE_DIR/netcfg-daemon"
fi
- elif [[ -n "$NET" ]]; then
- if /usr/bin/netcfg check-iface "$NET"; then
- echo "$NET" > "$STATE_DIR/netcfg-daemon" # JP: user may want to disconnect profile by calling net-profiles stop
- add_daemon net-profiles
- exit 0
- fi
- elif /usr/bin/netcfg-daemon start; then
- add_daemon net-profiles
- else
+ elif ! /usr/bin/netcfg-daemon start; then
exit_err "No profile started."
fi
+ add_daemon net-profiles
;;
stop)
if ck_daemon net-profiles; then
diff --git a/rc.d/net-set-variable b/rc.d/net-set-variable
new file mode 100644
index 0000000..cc881e7
--- /dev/null
+++ b/rc.d/net-set-variable
@@ -0,0 +1,10 @@
+# Set the NET variable if specified on the kernel command line.
+
+net-set-variable() {
+ local re="\<NET=([^ ]+)\>"
+ if [[ -f /proc/cmdline && $(< /proc/cmdline) =~ $re ]]; then
+ export NET=${BASH_REMATCH[1]}
+ fi
+}
+
+add_hook multi_start net-set-variable
diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu
index a62838a..b6aa402 100755
--- a/scripts/netcfg-menu
+++ b/scripts/netcfg-menu
@@ -48,14 +48,13 @@ ret=$?
case $ret in
1) ;; # Cancel - do nothing
255) # timeout - use default
- profile_up "$DEFAULT" # JP: use profile_up and catch $?
- ret=$?
- (( ret == 0 )) && echo "$DEFAULT" > "$STATE_DIR/menu"
- ;;
+ PROFILE=$DEFAULT;;&
0) # User selection
- profile_up "$(< "$ANSWER")"
+ PROFILE=$(< "$ANSWER");;&
+ 255|0)
+ profile_up "$PROFILE"
ret=$?
- (( ret == 0 )) && mv "$ANSWER" "$STATE_DIR/menu"
+ (( ret == 0 )) && echo "$PROFILE" > "$STATE_DIR/menu"
;;
*) # Shouldnt happen
exit_err "Abnormal ret code from dialog: $ret"
diff --git a/systemd/netcfg@.service b/systemd/netcfg@.service
index 5c0619d..94b0c76 100644
--- a/systemd/netcfg@.service
+++ b/systemd/netcfg@.service
@@ -1,5 +1,5 @@
[Unit]
-Description=Netcfg profile based networking service
+Description=Netcfg networking service for profile %i
Before=network.target
[Service]