]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/system/partresize
Enable serial console on all Azure instances
[ipfire-2.x.git] / src / initscripts / system / partresize
index 8c05f4d15e6e11921039e0ac75d4045ec7af691d..0c2866c0b9d79f8168464388204f3273acf976e6 100644 (file)
@@ -18,6 +18,7 @@
 case "${1}" in
        start)
                if [ -e "/.partresize" ]; then
+
                        boot_mesg "Mounting root file system in read/write mode ..."
                        mount -o remount,rw / > /dev/null
                        evaluate_retval
@@ -28,6 +29,38 @@ case "${1}" in
                        (exit ${failed})
                        evaluate_retval
 
+                       # check if serial console enabled
+                       scon="off";
+                       if [ ! "$(grep "console=ttyS0" /proc/cmdline)" == "" ]; then
+                               scon="on";
+                       fi
+                       IFS= read -r DMI_PRODUCT_NAME < /sys/class/dmi/id/product_name;
+                       case ${DMI_PRODUCT_NAME} in
+                               APU|apu[1-4]|PC\ Engines\ apu[1-4] )
+                                               scon="on";
+                                       ;;
+                       esac
+
+                       # Enable the serial console on all systems on Azure
+                       if running_on_azure; then
+                               scon="on"
+                       fi
+
+                       mount /boot > /dev/null
+                       if [ -e /boot/grub/grub.cfg ]; then
+                               # swtich permanent to serial console if it was selected on first boot
+                               if [ "${scon}" = "on" ]; then
+                                       # Enable also serial console on GRUB
+                                       echo "GRUB_TERMINAL=\"serial console\"" >> /etc/default/grub
+                                       echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub
+                                       sed -i -e "s|panic=10|& console=ttyS0,115200n8|g" /etc/default/grub
+                               fi
+
+                               # Re-generate GRUB configuration
+                               /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg
+                       fi
+                       umount /boot > /dev/null
+
                        # Detect device
                        mount | while read -r dev tmp1 mountpoint tmp2; do
                                [ "${dev}" = "rootfs" ] && continue