[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#502821: Enhances oldsys-preseed patch for the DNS-323



A better patch, based on Martin Michlmayr's feedback, is attached.  Enjoy!

- Matt
unchanged:
--- a/installer/build/pkg-lists/netboot/network-console/arm/orion5x.cfg
+++ b/installer/build/pkg-lists/netboot/network-console/arm/orion5x.cfg
@@ -7,6 +7,8 @@ ext2-modules-${kernel:Version}
 ext3-modules-${kernel:Version}
 # needed by oldsys-preseed on the Kurobox Pro
 jffs2-modules-${kernel:Version}
+# needed by oldsys-preseed on the DNS-323
+minix-modules-${kernel:Version}
 # To control the LED and beeper on QNAP devices
 input-modules-${kernel:Version}
 qcontrol-udeb
only in patch2:
unchanged:
--- b/packages/oldsys-preseed/functions
+++ b/packages/oldsys-preseed/functions
@@ -104,6 +104,15 @@
 	echo "$1" | grep "^$2=" | sed "s/^$2=//"
 }
 
+# Get the value from a string in the form of var = "value" from a file.
+# Named for the sib.conf file on the DNS-323 that this function was
+# originally written for.
+# $1 = file to read
+# $2 = var to read
+get_sib_var() {
+	grep "^$2[[:space:]]*=" $1 |sed "s/^$2[[:space:]]*=[[:space:]]*\"\(.*\)\"[[:space:]]*$/\1/"
+}
+
 # Add a string to a variable; deals with the fact when a string is empty
 # $1 = variable name
 # $2 = string
@@ -143,6 +152,19 @@
 	DOMAIN=$(get_var "$sysconf" "domain_name")
 }
 
+# Parse the sib.conf file, as found in the Dlink DNS-323
+# $1 = path to sib.conf
+parse_sib_conf() {
+	if [ "$(get_sib_var "$1" "CF-IP-DHCP-ENABLE")" = "0" ]; then
+		NET_CONFIG="static"
+	fi
+	IPADDRESS="$(get_sib_var "$1" "CF-IP-STATIC-IP")"
+	NETMASK="$(get_sib_var "$1" "CF-IP-STATIC-IP-NETMASK")"
+	GATEWAY="$(get_sib_var "$1" "CF-IP-STATIC-IP-GATEWAY")"
+	var_add NAMESERVERS "$(get_sib_var "$1" "CF-IP-DNS1")"
+	var_add NAMESERVERS "$(get_sib_var "$1" "CF-IP-DNS2")"
+	HOSTNAME="$(get_sib_var "$1" "CF-SYS-MODEL-STR")"
+}
 
 # Generating
 
only in patch2:
unchanged:
--- b/packages/oldsys-preseed/oldsys-preseed
+++ b/packages/oldsys-preseed/oldsys-preseed
@@ -231,6 +231,27 @@
 			fi
 			umount $path/sda1 || true
 			rmdir $path/sda1 $path || true
+		elif echo "$machine" | grep -q "^D-Link DNS-323"; then
+			check_file /proc/mtd
+			rootfs=$(get_mtdblock "MTD1")
+			if [ -z "$rootfs" ]; then
+				log "Can't find rootfs MTD partition"
+				exit 0
+			fi
+
+			INTERFACE="eth0"
+			path=/tmp/oldsys-preseed
+			mkdir -p $path/rootfs
+			mount -t minix -o ro /dev/$rootfs $path/rootfs
+			parse_sib_conf "$path/rootfs/sib.conf"
+			umount $path/rootfs
+			sanity_check_static_config
+			if [ "$NET_CONFIG" != "static" ]; then
+				IPADDRESS=192.168.0.32
+				NETMASK=255.255.255.0
+				GATEWAY=192.168.0.1
+				[ -z "$NAMESERVERS" ] && NAMESERVERS=192.168.0.1
+			fi
 		else
 			exit_unknown
 		fi
only in patch2:
unchanged:
--- /dev/null
+++ b/packages/oldsys-preseed/tests/arm/dns323-static.preseed
@@ -0,0 +1,8 @@
+d-i netcfg/choose_interface select eth0
+d-i netcfg/get_ipaddress string 192.168.0.2
+d-i netcfg/get_netmask string 255.255.255.0
+d-i netcfg/get_gateway string 192.168.0.254
+d-i netcfg/get_nameservers string 192.168.0.254 192.168.0.255
+d-i netcfg/confirm_static boolean true
+d-i netcfg/disable_dhcp boolean true
+d-i netcfg/get_hostname string home
only in patch2:
unchanged:
--- /dev/null
+++ b/packages/oldsys-preseed/tests/arm/dns323-static.test
@@ -0,0 +1,5 @@
+INTERFACE=eth0
+parse_sib_conf $TEST_DIR/dns323_sib.conf
+sanity_check_static_config
+generate_preseed_file "$1"
+
only in patch2:
unchanged:
--- /dev/null
+++ b/packages/oldsys-preseed/tests/arm/dns323-dhcp.preseed
@@ -0,0 +1,3 @@
+d-i netcfg/choose_interface select eth0
+d-i netcfg/use_dhcp boolean true
+d-i netcfg/get_hostname string home
only in patch2:
unchanged:
--- /dev/null
+++ b/packages/oldsys-preseed/tests/arm/dns323-dhcp.test
@@ -0,0 +1,4 @@
+INTERFACE=eth0
+parse_sib_conf $TEST_DIR/dns323_dhcp_sib.conf
+sanity_check_static_config
+generate_preseed_file "$1"
only in patch2:
unchanged:
--- /dev/null
+++ b/packages/oldsys-preseed/tests/arm/dns323-dhcp_sib.conf
@@ -0,0 +1,29 @@
+CF-SYS-MODEL-STR = "home"
+CF-WEB-IDLE-TIME  = "5"
+CF-IP-DHCP-ENABLE       = "1"
+CF-IP-STATIC-IP         = "192.168.0.2"
+CF-IP-STATIC-IP-NETMASK = "255.255.255.0"
+CF-IP-STATIC-IP-GATEWAY = "192.168.0.254"
+CF-IP-DNS1 = "192.168.0.254"
+CF-IP-DNS2 = "192.168.0.255"
+CF-TIMEZONE = "8"
+CF-METHOD = "2"
+CF-WEB-USER-IDLE = "5"
+CF-TIMESERVER = "216.200.93.8"
+CF-WL-WIRELESS = "0"
+CF-WL-COMM-MODE = "0"
+CF-WL-SSID = ""
+CF-WL-CHANNEL = ""
+CF-WL-AUTH = "1"
+CF-WL-SECURITY-MODE = "1"
+CF-WL-ENCRYPTION-MODE = "1"
+CF-WL-KEY-FORMATE = "1"
+CF-WL-DEFAULT-KEY = "1"
+CF-WL-KEY-VALUE-1 = ""
+CF-WL-KEY-VALUE-2 = ""
+CF-WL-KEY-VALUE-3 = ""
+CF-WL-KEY-VALUE-4 = ""
+CF-WL-PSK = ""
+CF-WL-MACADDRESS = ""
+CF-WL-SIGNAL = ""
+CF-WL-CONNECT = "1"
only in patch2:
unchanged:
--- /dev/null
+++ b/packages/oldsys-preseed/tests/arm/dns323-static_sib.conf
@@ -0,0 +1,29 @@
+CF-SYS-MODEL-STR = "home"
+CF-WEB-IDLE-TIME  = "5"
+CF-IP-DHCP-ENABLE       = "0"
+CF-IP-STATIC-IP         = "192.168.0.2"
+CF-IP-STATIC-IP-NETMASK = "255.255.255.0"
+CF-IP-STATIC-IP-GATEWAY = "192.168.0.254"
+CF-IP-DNS1 = "192.168.0.254"
+CF-IP-DNS2 = "192.168.0.255"
+CF-TIMEZONE = "8"
+CF-METHOD = "2"
+CF-WEB-USER-IDLE = "5"
+CF-TIMESERVER = "216.200.93.8"
+CF-WL-WIRELESS = "0"
+CF-WL-COMM-MODE = "0"
+CF-WL-SSID = ""
+CF-WL-CHANNEL = ""
+CF-WL-AUTH = "1"
+CF-WL-SECURITY-MODE = "1"
+CF-WL-ENCRYPTION-MODE = "1"
+CF-WL-KEY-FORMATE = "1"
+CF-WL-DEFAULT-KEY = "1"
+CF-WL-KEY-VALUE-1 = ""
+CF-WL-KEY-VALUE-2 = ""
+CF-WL-KEY-VALUE-3 = ""
+CF-WL-KEY-VALUE-4 = ""
+CF-WL-PSK = ""
+CF-WL-MACADDRESS = ""
+CF-WL-SIGNAL = ""
+CF-WL-CONNECT = "1"

Reply to: