From a34ee5f28146d6d272e56b10f028b7a4c9b4e265 Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Mon, 19 Nov 2007 18:13:37 -0800 Subject: Switch boot program from grub to isolinux. Grub has problems working with some BIOS implementations. --- scripts/install-system.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/install-system.in b/scripts/install-system.in index cf7ff263..325f7980 100755 --- a/scripts/install-system.in +++ b/scripts/install-system.in @@ -458,10 +458,8 @@ install_root_filesystem () { # make the dir for the boot files and copy em' over mkdir -p $rootfsdir/boot output=$(cp -pR /boot/* $rootfsdir/boot/) - output+=$(cp /live/image/live/vmlinuz-* $rootfsdir/boot/) + output+=$(cp /live/image/live/initrd*.img* $rootfsdir/boot/initrd.img) status=$? - output+=$(cp /live/image/live/initrd.img-* $rootfsdir/boot/initrd.img) - status=$status || $? if [ "$status" != 0 ]; then echo -e "Error trying to copy the bootfiles.\nPlease see install log for more details.\nExiting. .." -- cgit v1.2.3 From c095fa715a6fae2f6b36a8a27ad24e9f24788f5b Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Tue, 20 Nov 2007 17:05:34 -0800 Subject: Bugfix: 2412 Provide boot options in menu.lst for both Serial and KVM consoles. In both options, set up the other console to serve as the secondary console. Select which boot option to use by default based on the tty that the user is running install-system on. --- scripts/install-system.in | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/scripts/install-system.in b/scripts/install-system.in index 325f7980..90a142b7 100755 --- a/scripts/install-system.in +++ b/scripts/install-system.in @@ -588,21 +588,48 @@ install_grub () { root="(hd0,$part)" fi + # Figure out whether we are running on the serial or KVM console: + if [ "`tty`" == "/dev/ttyS0" ]; then + # Since user is running on serial console, make that the default. + DEFAULT_CONSOLE="1" + else + # Since user is running on KVM console, make that the default + DEFAULT_CONSOLE="0" + fi + # create the menu.lst file for grub + # The "default=" line selects which boot option will be used by default. + # Numbering starts at 0 for the first option. grub_file="$rootfsdir/boot/grub/menu.lst" - echo -e "default=0\ntimeout=5\n#splashimage=(hd0,0)/grub/splash.xpm.gz\nhiddenmenu" > $grub_file + echo -e "default=$DEFAULT_CONSOLE\ntimeout=5\n#splashimage=(hd0,0)/grub/splash.xpm.gz\nhiddenmenu" > $grub_file # set serial console options echo -e "serial --unit=0 --speed=9600\nterminal --timeout=5 console serial\n\n" >> $grub_file - # set primary boot option - echo -e "title Vyatta OFR\n\troot $root" >> $grub_file + + # Set first system boot option. Make KVM the default console in this one. + echo -e "title Vyatta OFR (KVM console)\n\troot $root" >> $grub_file echo -en "\tkernel /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 console=tty0 \n" >> $grub_file echo -e "\tinitrd /boot/initrd.img" >> $grub_file - # Set root password reset option + # Set the second system boot option. Make the serial port be the default + # console in this one. + echo >> $grub_file + echo -e "title Vyatta OFR (Serial console)\n\troot $root" >> $grub_file + echo -en "\tkernel /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=tty0 console=ttyS0,9600 \n" >> $grub_file + echo -e "\tinitrd /boot/initrd.img" >> $grub_file + + # Set third and fourth boot options for root password reset. Offer + # options for both serial and KVM console. + + echo >> $grub_file + echo -e "title Root password reset to factory (KVM console)" >> $grub_file + echo -e "\troot $root" >> $grub_file + echo -e "\tkernel /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 console=tty0 init=$PWRESET" >> $grub_file + echo -e "\tinitrd /boot/initrd.img" >> $grub_file + echo >> $grub_file - echo -e "title Root password reset to factory (serial console)" >> $grub_file + echo -e "title Root password reset to factory (Serial console)" >> $grub_file echo -e "\troot $root" >> $grub_file - echo -e "\tkernel /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 init=$PWRESET" >> $grub_file + echo -e "\tkernel /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=tty0 console=ttyS0,9600 init=$PWRESET" >> $grub_file echo -e "\tinitrd /boot/initrd.img" >> $grub_file echo "OK" -- cgit v1.2.3 From 6043afabb34aa2a63c862363679e91b2696468f3 Mon Sep 17 00:00:00 2001 From: rbalocca Date: Fri, 30 Nov 2007 16:39:47 -0800 Subject: Fix bad merge in install-system.in --- scripts/install-system.in | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/install-system.in b/scripts/install-system.in index fc5ad7c4..4c31b2ad 100755 --- a/scripts/install-system.in +++ b/scripts/install-system.in @@ -458,13 +458,11 @@ install_root_filesystem () { # make the dir for the boot files and copy em' over mkdir -p $rootfsdir/boot output=$(cp -pR /boot/* $rootfsdir/boot/) - output+=$(cp /live/image/live/initrd*.img* $rootfsdir/boot/initrd.img) status=$? - output+=$(cp /live/image/live/initrd.img-* $rootfsdir/boot/initrd.img) + output+=$(cp /live/image/live/initrd1.img $rootfsdir/boot/initrd.img) status=$status$? if [ "$status" -ne 0 ]; then - echo -e "Error trying to copy the bootfiles.\nPlease see install log for more details.\nExiting. -.." + echo -e "Error trying to copy the bootfiles.\nPlease see install log for more details.\nExiting..." echo -e "Error trying to copy the bootfiles.\ncp /boot/initrd.img $rootfsdir/boot/\n$output" >> $INSTALL_LOG exit 1 fi -- cgit v1.2.3 From eefd3f1d5836f383f4d627f02c794d870f23bb94 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Wed, 19 Dec 2007 09:55:08 -0800 Subject: Change temporary version string to glendale instead of eureka. --- debian/vyatta-cfg-system.postinst.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/vyatta-cfg-system.postinst.in b/debian/vyatta-cfg-system.postinst.in index b747b786..9911cda5 100644 --- a/debian/vyatta-cfg-system.postinst.in +++ b/debian/vyatta-cfg-system.postinst.in @@ -50,7 +50,7 @@ if [ "$sysconfdir" != "/etc" ]; then echo "log syslog warnings" >> /etc/quagga/Quagga.conf # add temporary version - echo "Version : eureka (beta)" > $sysconfdir/version + echo "Version : glendale (alpha 1)" > $sysconfdir/version fi # update crontab for logrotate -- cgit v1.2.3 From 3db5608b709d365b37a7df590862bbec4e845042 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Thu, 20 Dec 2007 14:55:43 -0800 Subject: synchronize /etc/{hosts,hostname} during install-system --- scripts/install-system.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install-system.in b/scripts/install-system.in index c4e46217..6454b8d0 100755 --- a/scripts/install-system.in +++ b/scripts/install-system.in @@ -472,8 +472,7 @@ install_root_filesystem () { echo -e "/dev/$ROOT_PARTITION\t/\text3\tdefaults\t0 1" >> $rootfsdir/etc/fstab #setup the hostname file - rm -f $rootfsdir/etc/hostname - echo vyatta > $rootfsdir/etc/hostname + cp /etc/hostname $rootfsdir/etc/ cp /etc/hosts $rootfsdir/etc/ progress_indicator "stop" -- cgit v1.2.3 From f5825957351be211801d03ad0f0786c6adc4cac6 Mon Sep 17 00:00:00 2001 From: Robert Bays Date: Fri, 21 Dec 2007 14:59:10 -0800 Subject: remove config partition from install-system --- scripts/install-system.in | 87 ++--------------------------------------------- 1 file changed, 2 insertions(+), 85 deletions(-) diff --git a/scripts/install-system.in b/scripts/install-system.in index 6454b8d0..5c3a6902 100755 --- a/scripts/install-system.in +++ b/scripts/install-system.in @@ -353,15 +353,10 @@ make_filesystem () { create_partitions() { ldrive=$1 root_part_size=$2 - config_part_size=$3 - - total=$(($root_part_size + $config_part_size)) - head=$(($root_part_size)) - tail=$(($root_part_size + $config_part_size)) # Make sure there is enough space on drive size=$(get_drive_size "$ldrive") - if [ "$total" -gt "$size" ]; then + if [ "$root_part_size" -gt "$size" ]; then echo "Error: $ldrive is only $size"MB" large." exit 1 fi @@ -384,27 +379,8 @@ create_partitions() { sleep 1 done - echo "Creating configuration partition on /dev/$ldrive" >> $INSTALL_LOG - echo "parted /dev/$ldrive mkpart primary $root_part_size $config_part_size" >> $INSTALL_LOG - - output=$(parted /dev/$ldrive mkpart primary $head $tail) - status=$? - if [ "$status" != 0 ]; then - echo -e "Error creating primary partition on $ldrive.\nPlease see $INSTALL_LOG for more details.\nExiting..." - echo -e "Error creating primary partition on $ldrive.\nparted /dev/$ldrive mkpart primary $root_part_size $config_part_size\n$output" - exit 1 - fi - - CONFIG_PARTITION=$ldrive"2" - # udev takes time to re-add the device file, so wait for it - while [ ! -b "/dev/$CONFIG_PARTITION" ] - do - sleep 1 - done - # make the root and config ext3 file systems. make_filesystem "$ROOT_PARTITION" - make_filesystem "$CONFIG_PARTITION" } # Install the root filesystem @@ -468,7 +444,6 @@ install_root_filesystem () { fi # create the fstab - echo -e "/dev/$CONFIG_PARTITION\t$ofrconfdir\text3\tdefaults\t1 2" >> $rootfsdir/etc/fstab echo -e "/dev/$ROOT_PARTITION\t/\text3\tdefaults\t0 1" >> $rootfsdir/etc/fstab #setup the hostname file @@ -489,14 +464,6 @@ copy_config () { # create the config directory on the union file system mkdir -p $rootfsdir$ofrconfdir - output=$(mount -t ext3 /dev/$config_partition $rootfsdir$ofrconfdir) - status=$? - - if [ "$status" != 0 ]; then - echo -e "Error trying to mount the new config partition.\nPlease see $INSTALL_LOG for details.\nExiting..." - echo -e "Error trying to mount the new config partition.\nmount -t ext3 /dev/$config_partition $rootfsdir$ofrconfdir\n$output" >> $INSTALL_LOG - exit 1 - fi # create the proper perms on the new config partition chgrp quaggavty $rootfsdir$ofrconfdir @@ -678,40 +645,9 @@ setup_method_manual() { fi done - # Ask for the config partition and make sure it's valid - # TODO: need to do better error checking here to insure - # the user doesn't select the same part for both drives. - while [ -z "$CONFIG_PARTITION" ] - do - while true - do - select_partition 5 "Which partition should I use for configurations?" - # Note that PARTITION is defined in select partition - if [ "$PARTITION" != "$ROOT_PARTITION" ] - then - break - fi - echo "The config partition cannot be the same as the root partition ($ROOT_PARTITION)!" - echo - done - - CONFIG_PARTITION=$PARTITION - unmount "$CONFIG_PARTITION" - vd=$(grep $CONFIG_PARTITION /proc/partitions | awk '{ print $4 }') - - if [ -z "$vd" ]; then - echo - echo "$CONFIG_PARTITION is an invalid partition. Please try again." - CONFIG_PARTITION="" - fi - done - # create the ext3 fs on the part make_filesystem "$ROOT_PARTITION" - # Create the ext3 fs on the part - make_filesystem $CONFIG_PARTITION - # We need to set the INSTALL_DRIVE if it wasn't set when the user ran parted # We assume that we will use the boot sector of the same drive that the partition is on # TODO: Allow different drives to function as the boot device @@ -771,8 +707,6 @@ setup_method_auto() { while [ $ROOT_MIN -gt $ROOT_PARTITION_SIZE ]; do # Get the size of the drive size=$(get_drive_size $INSTALL_DRIVE) - # Subtract our minimum config part so the user doesn't fill the entire drive - size=$(($size - $CONFIG_MIN)) echo -n "How big of a root partition should I create? ($ROOT_MIN"MB" - $size"MB") [$size]MB: " response=$(get_response "$size") # TODO: need to have better error checking on this value @@ -784,27 +718,10 @@ setup_method_auto() { fi done - # Enforce minimum partion size requirement. - CONFIG_PARTITION_SIZE=0 - while [ $CONFIG_MIN -gt $CONFIG_PARTITION_SIZE ]; do - # Get the size of the drive - size=$(get_drive_size $INSTALL_DRIVE) - # Subtract our minimum config part so the user doesn't fill the entire drive - size=$(($size - $ROOT_PARTITION_SIZE)) - echo -n "How big of a config partition should I create? ($CONFIG_MIN"MB" - $size"MB") [$CONFIG_MIN]MB: " - response=$(get_response "$CONFIG_MIN") - CONFIG_PARTITION_SIZE=$(echo "$response" | sed 's/[^0-9]//g') - if [ $CONFIG_PARTITION_SIZE -lt $CONFIG_MIN ] || [ $CONFIG_PARTITION_SIZE -gt $size ]; then - echo "Config partion must be between $CONFIG_MIN"MB" and $size"MB"" - echo - CONFIG_PARTITION_SIZE=0 - fi - done - echo # now take the data and create the partitions - create_partitions "$INSTALL_DRIVE" "$ROOT_PARTITION_SIZE" "$CONFIG_PARTITION_SIZE" + create_partitions "$INSTALL_DRIVE" "$ROOT_PARTITION_SIZE" } unmount () { -- cgit v1.2.3 From cf3cabae0a7b8b4900687f2bcad927180abace4d Mon Sep 17 00:00:00 2001 From: Robert Bays Date: Fri, 21 Dec 2007 15:03:01 -0800 Subject: remove umount on config partition --- scripts/install-system.in | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install-system.in b/scripts/install-system.in index 5c3a6902..e626a383 100755 --- a/scripts/install-system.in +++ b/scripts/install-system.in @@ -851,7 +851,6 @@ install_grub cp $INSTALL_LOG $rootfsdir/install.log -umount $rootfsdir$ofrconfdir umount $rootfsdir echo "Done!" -- cgit v1.2.3 From fa71dcd232351c123ac34dcd6622449f9193b0c5 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Sat, 22 Dec 2007 19:20:54 -0800 Subject: Add tunnel interface. --- templates/interfaces/tunnel/node.def | 11 +++++++++++ templates/interfaces/tunnel/node.tag/address/node.def | 6 ++++++ templates/interfaces/tunnel/node.tag/description/node.def | 2 ++ templates/interfaces/tunnel/node.tag/disable/node.def | 3 +++ templates/interfaces/tunnel/node.tag/encapsulation/node.def | 5 +++++ templates/interfaces/tunnel/node.tag/key/node.def | 4 ++++ templates/interfaces/tunnel/node.tag/local-ip/node.def | 3 +++ templates/interfaces/tunnel/node.tag/mtu/node.def | 6 ++++++ templates/interfaces/tunnel/node.tag/remote-ip/node.def | 2 ++ templates/interfaces/tunnel/node.tag/tos/node.def | 5 +++++ templates/interfaces/tunnel/node.tag/ttl/node.def | 5 +++++ 11 files changed, 52 insertions(+) create mode 100644 templates/interfaces/tunnel/node.def create mode 100644 templates/interfaces/tunnel/node.tag/address/node.def create mode 100644 templates/interfaces/tunnel/node.tag/description/node.def create mode 100644 templates/interfaces/tunnel/node.tag/disable/node.def create mode 100644 templates/interfaces/tunnel/node.tag/encapsulation/node.def create mode 100644 templates/interfaces/tunnel/node.tag/key/node.def create mode 100644 templates/interfaces/tunnel/node.tag/local-ip/node.def create mode 100644 templates/interfaces/tunnel/node.tag/mtu/node.def create mode 100644 templates/interfaces/tunnel/node.tag/remote-ip/node.def create mode 100644 templates/interfaces/tunnel/node.tag/tos/node.def create mode 100644 templates/interfaces/tunnel/node.tag/ttl/node.def diff --git a/templates/interfaces/tunnel/node.def b/templates/interfaces/tunnel/node.def new file mode 100644 index 00000000..8d8cc029 --- /dev/null +++ b/templates/interfaces/tunnel/node.def @@ -0,0 +1,11 @@ +tag: +type: txt +help: "Configure a tunnel interface" +syntax: $(@) in "tun0", "tun1", "tun2", "tun3", "tun4", "tun5", "tun6", "tun7", "tun8", "tun9" ; "Must be (tun0 - tun9)" +commit: $(./local-ip/) != "" ; "Must configure the tunnel local-ip" +commit: $(./remote-ip/) != "" ; "Must configure the tunnel remote-ip" +commit: $(./encapsulation/) != "" ; "Must configure the tunnel encapsulation" +create: "sudo ip tunnel add $(@) local $(./local-ip/@) remote $(./remote-ip/@) mode $(./encapsulation/@)" +create: "sudo ip link set $(@) up" +delete: "sudo ip tunnel del $(@)" +#comp_help: "Enter tunnel interface name (tun0 - tun9)" diff --git a/templates/interfaces/tunnel/node.tag/address/node.def b/templates/interfaces/tunnel/node.tag/address/node.def new file mode 100644 index 00000000..6cef105c --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/address/node.def @@ -0,0 +1,6 @@ +multi: +type: txt +help: "Set IPv4 address and prefix for this interface" +syntax: exec "/opt/vyatta/sbin/vyatta-interfaces.pl --valid-addr $(@) --dev $(../@)" +update: "sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-update $(@) --dev $(../@)"; "Error setting address $(@) on dev $(../@)" +delete: "sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-delete $(@) --dev $(../@)"; "Error deleting address $(@) on dev $(../@)" diff --git a/templates/interfaces/tunnel/node.tag/description/node.def b/templates/interfaces/tunnel/node.tag/description/node.def new file mode 100644 index 00000000..e443734d --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/description/node.def @@ -0,0 +1,2 @@ +type: txt +help: "Description of this tunnel interface" diff --git a/templates/interfaces/tunnel/node.tag/disable/node.def b/templates/interfaces/tunnel/node.tag/disable/node.def new file mode 100644 index 00000000..56199085 --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/disable/node.def @@ -0,0 +1,3 @@ +help: "Disable interface" +update: "sudo ip link set $(../@) down"; "Error disabling dev $(../@)" +delete: "sudo ip link set $(../@) up"; "Error enabling dev $(../@)" diff --git a/templates/interfaces/tunnel/node.tag/encapsulation/node.def b/templates/interfaces/tunnel/node.tag/encapsulation/node.def new file mode 100644 index 00000000..b578c543 --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/encapsulation/node.def @@ -0,0 +1,5 @@ +type: txt +help: "Set the encapsulation of this tunnel interface" +syntax: $(@) in "ipip", "gre", "sit"; "Must be (ipip, gre, sit)" +#comp_help: "Select an encapsulation (gre, ipip, sit)" +update: "sudo ip tunnel change $(../@) mode $(@)" diff --git a/templates/interfaces/tunnel/node.tag/key/node.def b/templates/interfaces/tunnel/node.tag/key/node.def new file mode 100644 index 00000000..3261229d --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/key/node.def @@ -0,0 +1,4 @@ +type: u32 +help: "Set the tunnel key" +syntax: $(@) >= 0 && $(@) <= 999999; "Must be between 0-999999" +update: "sudo ip tunnel change $(../@) key $(@)" diff --git a/templates/interfaces/tunnel/node.tag/local-ip/node.def b/templates/interfaces/tunnel/node.tag/local-ip/node.def new file mode 100644 index 00000000..6b306a3c --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/local-ip/node.def @@ -0,0 +1,3 @@ +type: ipv4 +help: "Enter the local IP address for this tunnel" + diff --git a/templates/interfaces/tunnel/node.tag/mtu/node.def b/templates/interfaces/tunnel/node.tag/mtu/node.def new file mode 100644 index 00000000..80ea5b06 --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/mtu/node.def @@ -0,0 +1,6 @@ +type: u32 +help: "Set the tunnel MTU" +syntax: $(@) >= 64 && $(@) <= 8024; "Must be between 64-8024" +update: "sudo ip link set $(../@) mtu $(@)" +delete: "sudo ip link set $(../@) mtu 1476" + diff --git a/templates/interfaces/tunnel/node.tag/remote-ip/node.def b/templates/interfaces/tunnel/node.tag/remote-ip/node.def new file mode 100644 index 00000000..b8713e46 --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/remote-ip/node.def @@ -0,0 +1,2 @@ +type: ipv4 +help: "Enter the remote IP address for this tunnel" diff --git a/templates/interfaces/tunnel/node.tag/tos/node.def b/templates/interfaces/tunnel/node.tag/tos/node.def new file mode 100644 index 00000000..7e3d28ae --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/tos/node.def @@ -0,0 +1,5 @@ +type: u32 +help: "Set the tunnel type of service" +syntax: $(@) >= 0 && $(@) <= 99; "Must be between 0-99" +update: "sudo ip tunnel change $(../@) tos $(@)" +delete: "sudo ip tunnel change $(../@) tos inherit" diff --git a/templates/interfaces/tunnel/node.tag/ttl/node.def b/templates/interfaces/tunnel/node.tag/ttl/node.def new file mode 100644 index 00000000..2cb09c73 --- /dev/null +++ b/templates/interfaces/tunnel/node.tag/ttl/node.def @@ -0,0 +1,5 @@ +type: u32 +help: "Set the tunnel time to live" +syntax: $(@) >= 0 && $(@) <= 255; "Must be between 0-255" +update: "sudo ip tunnel change $(../@) ttl $(@)" +delete: "sudo ip tunnel change $(../@) ttl inherit" -- cgit v1.2.3 From ea4c396e33bf34cb8272daa2e1b2177a962cffb1 Mon Sep 17 00:00:00 2001 From: Marat Nepomnyashy Date: Wed, 26 Dec 2007 16:51:13 -0800 Subject: Treat 'system domain-name $(@)' and 'system domain-search domain $(@)' as mutually exclusive. Generate an error message and refuse commit if both are specified. Bug 2256 fix. --- scripts/system/vyatta_update_resolv.pl | 30 +++++++++++++++++++++++++++--- templates/system/domain-name/node.def | 10 ++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index 0255b256..a8d05cfd 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -47,9 +47,18 @@ if ($modify_dir ne '') { } +$vc->setLevel('system'); + +my @domains = $vc->returnValues('domain-search domain'); +my $domain_name = $vc->returnValue('domain-name'); + +if (@domains > 0 && $domain_name && length($domain_name) > 0) { + print STDERR "System configuration error. Both \'domain-name\' and \'domain-search\' are specified, but only one of these mutually exclusive parameters is allowed.\n"; + print STDERR "System configuration commit aborted due to error(s).\n"; + exit(1); +} + my $doms = ''; -$vc->setLevel('system domain-search domain'); -my @domains = $vc->returnValues('.'); foreach my $domain (@domains) { if (length($doms) > 0) { $doms .= ' '; @@ -62,9 +71,15 @@ if (length($doms) > 0) { $search = "search\t\t$doms\t\t#line generated by $0\n"; } +my $domain = ''; +if ($domain_name && length($domain_name) > 0) { + $domain = "domain\t\t$domain_name\t\t#line generated by $0\n"; +} + # The following will re-write '/etc/resolv.conf' line by line, -# replacing the 'search' specifier with the latest values. +# replacing the 'search' specifier with the latest values, +# or replacing the 'domain' specifier with the latest value. my @resolv; if (-e '/etc/resolv.conf') { @@ -75,6 +90,7 @@ if (-e '/etc/resolv.conf') { my $foundSearch = 0; +my $foundDomain = 0; open (RESOLV, '>/etc/resolv.conf') or die("$0: Error! Unable to open '/etc/resolv.conf' for output: $!\n"); foreach my $line (@resolv) { @@ -83,6 +99,11 @@ foreach my $line (@resolv) { if (length($search) > 0) { print RESOLV $search; } + } elsif ($line =~ /^domain\s/) { + $foundDomain = 1; + if (length($domain) > 0) { + print RESOLV $domain; + } } else { print RESOLV $line; } @@ -90,6 +111,9 @@ foreach my $line (@resolv) { if ($foundSearch == 0 && length($search) > 0) { print RESOLV $search; } +if ($foundDomain == 0 && length($domain) > 0) { + print RESOLV $domain; +} close (RESOLV); diff --git a/templates/system/domain-name/node.def b/templates/system/domain-name/node.def index 111061cd..4e3902dc 100644 --- a/templates/system/domain-name/node.def +++ b/templates/system/domain-name/node.def @@ -1,11 +1,9 @@ type: txt help: "Configure system domain name" syntax: pattern $(@) "^[-a-zA-Z0-9.]{0,63}$" ; "invalid domain name $(@)" + # also add localhost line into /etc/hosts (see host-name template)? -update: "sudo sh -c \"if [ x$(@) == x ]; then exit 0; fi && \ -touch /etc/resolv.conf && \ -sed -i '/domain/d' /etc/resolv.conf && \ -echo \\\"domain\t $(@)\\\" >> /etc/resolv.conf\" " +update: "sudo /opt/vyatta/sbin/vyatta_update_resolv.pl" + # also update localhost line in /etc/hosts (see host-name template)? -delete: "sudo sh -c \"touch /etc/resolv.conf && \ -sed -i '/domain\\\\t $(@)/d' /etc/resolv.conf\" " +delete: "sudo /opt/vyatta/sbin/vyatta_update_resolv.pl" -- cgit v1.2.3