Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreamcat4/9463087 to your computer and use it in GitHub Desktop.
Save dreamcat4/9463087 to your computer and use it in GitHub Desktop.
diff -cr qjail-3.2/usr/local/bin/qjail qjail-3.2-auto-nic-patch/usr/local/bin/qjail
*** qjail-3.2/usr/local/bin/qjail 2014-03-10 10:55:29.000000000 +0000
--- qjail-3.2-auto-nic-patch/usr/local/bin/qjail 2014-06-06 21:23:37.000000000 +0100
***************
*** 50,56 ****
delete|restore|config|update|logmsg|help] {parameters}"
syntax_install="Syntax: qjail install [-z zone] [-h ftp host] [-f file location] [-l]"
! syntax_create="Syntax: qjail create [-z zone] [-n value] [-a archive] [-f flavor] [-c]\n\
[-i size] [-d duplicate#] [-4 IPv4...] [-6 IPv6...]\n\
jailname"
syntax_list="Syntax: qjail list [-z zone] [jailname...]"
--- 50,56 ----
delete|restore|config|update|logmsg|help] {parameters}"
syntax_install="Syntax: qjail install [-z zone] [-h ftp host] [-f file location] [-l]"
! syntax_create="Syntax: qjail create [-z zone] [-m] [-n value] [-a archive] [-f flavor] [-c]\n\
[-i size] [-d duplicate#] [-4 IPv4...] [-6 IPv6...]\n\
jailname"
syntax_list="Syntax: qjail list [-z zone] [jailname...]"
***************
*** 562,570 ****
duplicate_count=000
! shift; while getopts f:a:n:d:i:z:4:6:c arg; do case ${arg} in
f) flavor=${OPTARG};;
a) fromarchive=${OPTARG};;
n) nic_devicename=${OPTARG};;
d) duplicate_times=${OPTARG};;
i) imagesize=${OPTARG}; create_image="YES";;
--- 562,571 ----
duplicate_count=000
! shift; while getopts f:a:m:n:d:i:z:4:6:c arg; do case ${arg} in
f) flavor=${OPTARG};;
a) fromarchive=${OPTARG};;
+ m) manual_network_definition="YES";;
n) nic_devicename=${OPTARG};;
d) duplicate_times=${OPTARG};;
i) imagesize=${OPTARG}; create_image="YES";;
***************
*** 618,623 ****
--- 619,638 ----
[ -z ${nic_name} ] \
&& kill "Entered -n interface device name is not valid."
fi
+
+ if [ -z "$nic_devicename" -a -z "$manual_network_definition" ]; then
+ # when no "-n <nic-devicename>", no "|" embedded iface in ip.addr, and no "-m" manual network definition
+
+ if [ "$ip4" ]; then
+ # get the nic device name from the ipv4 default route (or "" if the default route is not set)
+ nic_devicename="$(route get -inet default 2> /dev/null | grep -o "interface.*" | cut -d ' ' -f 2)"
+ fi
+
+ if [ -z "$nic_devicename" -a -n "$ip6" ]; then
+ # get the nic device name from the ipv6 default route (or "" if the default route is not set)
+ nic_devicename="$(route get -inet6 default 2> /dev/null | grep -o "interface.*" | cut -d ' ' -f 2)"
+ fi
+ fi
# Check that -c and -f ssh-default are not coded at same time.
[ "${flavor}" = "ssh-default" -a -n "${create_ssh}" ] \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment