BLL.Workflows.DefaultBootMenu.CreateSyslinuxMenu C# (CSharp) Method

CreateSyslinuxMenu() private method

private CreateSyslinuxMenu ( ) : void
return void
        private void CreateSyslinuxMenu()
        {
            var customMenuEntries = BLL.BootEntry.SearchBootEntrys().Where(x => x.Type == "syslinux/pxelinux" && x.Active == 1).OrderBy(x => x.Order).ThenBy(x => x.Name);
            var defaultCustomEntry = customMenuEntries.FirstOrDefault(x => x.Default == 1);
            var sysLinuxMenu = new StringBuilder();

            sysLinuxMenu.Append("DEFAULT vesamenu.c32" + NewLineChar);
            sysLinuxMenu.Append("MENU TITLE Boot Menu" + NewLineChar);
            sysLinuxMenu.Append("MENU BACKGROUND bg.png" + NewLineChar);
            sysLinuxMenu.Append("menu tabmsgrow 22" + NewLineChar);
            sysLinuxMenu.Append("menu cmdlinerow 22" + NewLineChar);
            sysLinuxMenu.Append("menu endrow 24" + NewLineChar);
            sysLinuxMenu.Append("menu color title                1;34;49    #eea0a0ff #cc333355 std" + NewLineChar);
            sysLinuxMenu.Append("menu color sel                  7;37;40    #ff000000 #bb9999aa all" + NewLineChar);
            sysLinuxMenu.Append("menu color border               30;44      #ffffffff #00000000 std" + NewLineChar);
            sysLinuxMenu.Append("menu color pwdheader            31;47      #eeff1010 #20ffffff std" + NewLineChar);
            sysLinuxMenu.Append("menu color hotkey               35;40      #90ffff00 #00000000 std" + NewLineChar);
            sysLinuxMenu.Append("menu color hotsel               35;40      #90000000 #bb9999aa all" + NewLineChar);
            sysLinuxMenu.Append("menu color timeout_msg          35;40      #90ffffff #00000000 none" + NewLineChar);
            sysLinuxMenu.Append("menu color timeout              31;47      #eeff1010 #00000000 none" + NewLineChar);
            sysLinuxMenu.Append("NOESCAPE 0" + NewLineChar);
            sysLinuxMenu.Append("ALLOWOPTIONS 0" + NewLineChar);
            sysLinuxMenu.Append("" + NewLineChar);
            sysLinuxMenu.Append("LABEL local" + NewLineChar);
            sysLinuxMenu.Append("localboot 0" + NewLineChar);
            if(defaultCustomEntry == null)
                sysLinuxMenu.Append("MENU DEFAULT" + NewLineChar);
            sysLinuxMenu.Append("MENU LABEL Boot To Local Machine" + NewLineChar);
            sysLinuxMenu.Append("" + NewLineChar);

            sysLinuxMenu.Append("LABEL Client Console" + NewLineChar);
            if (!string.IsNullOrEmpty(DebugPwd) && DebugPwd != "Error: Empty password")
                sysLinuxMenu.Append("MENU PASSWD " + DebugPwd + "" + NewLineChar);

            sysLinuxMenu.Append("kernel kernels" + Path.DirectorySeparatorChar + Kernel + "" + NewLineChar);
            sysLinuxMenu.Append("append initrd=images" + Path.DirectorySeparatorChar + BootImage +
                                " root=/dev/ram0 rw ramdisk_size=156000 " + " web=" + _webPath + " USER_TOKEN=" +
                                _userToken +
                                " task=debug consoleblank=0 " + _globalComputerArgs + "" + NewLineChar);

            sysLinuxMenu.Append("MENU LABEL Client Console" + NewLineChar);
            sysLinuxMenu.Append("" + NewLineChar);

            sysLinuxMenu.Append("LABEL Add Computer" + NewLineChar);
            if (!string.IsNullOrEmpty(AddPwd) && AddPwd != "Error: Empty password")
                sysLinuxMenu.Append("MENU PASSWD " + AddPwd + "" + NewLineChar);

            sysLinuxMenu.Append("kernel kernels" + Path.DirectorySeparatorChar + Kernel + "" + NewLineChar);
            sysLinuxMenu.Append("append initrd=images" + Path.DirectorySeparatorChar + BootImage +
                                " root=/dev/ram0 rw ramdisk_size=156000 " + " web=" + _webPath + " USER_TOKEN=" +
                                _userToken +
                                " task=register consoleblank=0 " + _globalComputerArgs + "" + NewLineChar);

            sysLinuxMenu.Append("MENU LABEL Add Computer" + NewLineChar);
            sysLinuxMenu.Append("" + NewLineChar);

            sysLinuxMenu.Append("LABEL On Demand" + NewLineChar);
            if (!string.IsNullOrEmpty(OndPwd) && OndPwd != "Error: Empty password")
                sysLinuxMenu.Append("MENU PASSWD " + OndPwd + "" + NewLineChar);

            sysLinuxMenu.Append("kernel kernels" + Path.DirectorySeparatorChar + Kernel + "" + NewLineChar);
            sysLinuxMenu.Append("append initrd=images" + Path.DirectorySeparatorChar + BootImage +
                                " root=/dev/ram0 rw ramdisk_size=156000 " + " web=" + _webPath + " USER_TOKEN=" +
                                _userToken +
                                " task=ond consoleblank=0 " + _globalComputerArgs + "" + NewLineChar);

            sysLinuxMenu.Append("MENU LABEL On Demand" + NewLineChar);
            sysLinuxMenu.Append("" + NewLineChar);

            sysLinuxMenu.Append("LABEL Diagnostics" + NewLineChar);
            if (!string.IsNullOrEmpty(DiagPwd) && DiagPwd != "Error: Empty password")
                sysLinuxMenu.Append("MENU PASSWD " + DiagPwd + "" + NewLineChar);

            sysLinuxMenu.Append("kernel kernels" + Path.DirectorySeparatorChar + Kernel + "" + NewLineChar);
            sysLinuxMenu.Append("append initrd=images" + Path.DirectorySeparatorChar + BootImage +
                                " root=/dev/ram0 rw ramdisk_size=156000 " + " web=" + _webPath + " USER_TOKEN=" +
                                _userToken +
                                " task=diag consoleblank=0 " + _globalComputerArgs + "" + NewLineChar);

            sysLinuxMenu.Append("MENU LABEL Diagnostics" + NewLineChar);
            sysLinuxMenu.Append("" + NewLineChar);

            //Insert active custom boot menu entries
            foreach (var customEntry in customMenuEntries)
            {
                sysLinuxMenu.Append("LABEL " + _alphaNumericSpace.Replace(customEntry.Name,"") + NewLineChar);
                sysLinuxMenu.Append(customEntry.Content + NewLineChar);
                if(defaultCustomEntry != null && customEntry.Id == defaultCustomEntry.Id)
                    sysLinuxMenu.Append("MENU DEFAULT" + NewLineChar);
                sysLinuxMenu.Append("MENU LABEL " + _alphaNumericSpace.Replace(customEntry.Name, "") + NewLineChar);
                sysLinuxMenu.Append("" + NewLineChar);
            }

            sysLinuxMenu.Append("PROMPT 0" + NewLineChar);
            sysLinuxMenu.Append("TIMEOUT 50" + NewLineChar);

            string path;
            if (Type == "standard")
                path = Settings.TftpPath + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default";
            else
                path = Settings.TftpPath + "proxy" + Path.DirectorySeparatorChar + Type +
                       Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default";

            new FileOps().WritePath(path, sysLinuxMenu.ToString());
        }