Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inputTable = {
- [ ".Elico" ] = {
- initrd = "CraftOS;shell\
- WinCC 7;bootmgr",
- [ "Splash.logo" ] = " \
- \
- 99555dd\
- 999444dbb\
- 5944411bb\
- 55449bbbb\
- 599444ddd\
- 99995dd\
- \
- 999999bbb\
- 99999bb\
- 99999bb\
- 99999bb\
- 99999bb\
- 99999bb\
- 99999bb\
- 999999bbb",
- [ "Bios.logo" ] = " 444444\
- 44 4 4 44\
- 4 4444 4\
- 4 4 4\
- 4 4444444",
- [ "Splash2.logo" ] = "\
- \
- \
- \
- \
- dd 88888 8 8 88888\
- d d 8 8 8 8\
- \
- d d 8 8 8 8\
- d d 8 8 8 8\
- d d 8 8 8 8\
- d d 88888 88888 88888",
- [ "Splash1.logo" ] = "\
- \
- \
- \
- \
- 77 77777 7 7 77777\
- 7 7 7 7 7 7\
- \
- 7 7 7 7 7 7\
- 7 7 7 7 7 7\
- 7 7 7 7 7 7\
- 7 7 77777 77777 77777",
- [ "Splash3.logo" ] = "\
- \
- \
- \
- \
- 55 00000 0 0 00000\
- 5 5 0 0 0 0\
- \
- 5 5 0 0 0 0\
- 5 5 0 0 0 0\
- 5 5 0 0 0 0\
- 5 5 00000 00000 00000",
- },
- startup = "-- Local Variables --\
- local x,y = term.getSize()\
- local bootOpt = { }\
- local sides = { \"left\", \"right\", \"top\", \"bottom\", \"front\", \"back\"}\
- local sidesList = { \"left\", \"right\", \"top\", \"bottom\", \"front\", \"back\"}\
- local driveCount = 1\
- local driveCount0 = 1\
- local monitorCount = 1\
- local modemCount = 1\
- local printerCount = 1\
- local modemExists = false\
- local modemSide = \"right\"\
- local bootDriveExists = false\
- local bootDrive = \"right\"\
- local bootableDisk = false\
- local mountName = \"disk\"\
- local labLen = 13\
- local slc = 1\
- local bytesFree = fs.getFreeSpace(\"/\")\
- local clientId = os.computerID()\
- \
- -- Local Functions --\
- \
- -- Disable \"Terminate\" function --\
- function os.pullEvent()\
- local event, p1, p2, p3, p4, p5 = os.pullEventRaw()\
- if event == \"terminate\" then\
- \
- end\
- return event, p1, p2, p3, p4, p5\
- end\
- \
- \
- -- Print Centred Text Function --\
- function centerText(text, line)\
- x,y = term.getSize()\
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), line)\
- term.write(text)\
- end\
- \
- \
- -- Split String Function --\
- function split(str, pattern)\
- local t = { }\
- local fpat = \"(.-)\" .. pattern\
- local last_end = 1\
- local s, e, cap = str:find(fpat, 1)\
- while s do\
- if s ~= 1 or cap ~= \"\" then\
- table.insert(t,cap)\
- end\
- last_end = e+1\
- s, e, cap = str:find(fpat, last_end)\
- end\
- if last_end <= #str then\
- cap = str:sub(last_end)\
- table.insert(t, cap)\
- end\
- return t\
- end\
- \
- \
- -- Get list of Boot Options Function --\
- local function readBootOptions()\
- if not fs.exists(\".Elico/initrd\") then return end\
- local file = io.open(\".Elico/initrd\", \"r\")\
- c = 0\
- for line in file:lines()do\
- c = c + 1\
- local t = split(line, \";\")\
- table.insert(bootOpt, { \
- name = t[1],\
- dir = t[2],\
- args = t[3] })\
- if c == 7 then break end \
- end\
- if bootableDisk then\
- table.insert(bootOpt, { \
- name = \"Disk\",\
- dir = mountName,\
- args = \"\"})\
- end\
- file:close()\
- end\
- \
- \
- -- Draw Logo --\
- term.clear()\
- sleep(1.0)\
- if term.isColor() then\
- term.setTextColor(colors.lightGray)\
- end\
- term.setCursorPos(1,1)\
- term.setCursorBlink(true)\
- sleep(1.5)\
- term.setCursorBlink(false)\
- term.clear()\
- sleep(1.0)\
- local animateSplash = 0\
- if term.isColor() then\
- if animateSplash == 1 then\
- if not fs.exists (\".Elico/Splash1.logo\") then\
- term.setCursorPos(1,1)\
- term.write (\"SPLASH FILES NOT FOUND, STARTING WITHOUT IT!\")\
- sleep(1.5)\
- term.setBackgroundColor(colors.black)\
- term.clear()\
- sleep(0.1)\
- elseif not fs.exists (\".Elico/Splash2.logo\") then\
- term.setCursorPos(1,1)\
- term.write (\"SPLASH FILES NOT FOUND, STARTING WITHOUT IT!\")\
- sleep(1.5)\
- term.setBackgroundColor(colors.black)\
- term.clear()\
- sleep(0.1)\
- elseif not fs.exists (\".Elico/Splash3.logo\") then\
- term.setCursorPos(1,1)\
- term.write (\"SPLASH FILES NOT FOUND, STARTING WITHOUT IT!\")\
- sleep(1.5)\
- term.setBackgroundColor(colors.black)\
- term.clear()\
- sleep(0.1)\
- else\
- local image = paintutils.loadImage(\".Elico/Splash1.logo\")\
- paintutils.drawImage(image, 1, 1) \
- term.setCursorPos(16,14)\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.gray)\
- term.write(\"Inspiring \") \
- term.setTextColor(colors.gray)\
- term.write(\"Innovation\")\
- sleep(0.05) \
- local image = paintutils.loadImage(\".Elico/Splash2.logo\")\
- paintutils.drawImage(image, 1, 1) \
- term.setCursorPos(16,14)\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.green)\
- term.write(\"Inspiring \") \
- term.setTextColor(colors.lightGray)\
- term.write(\"Innovation\")\
- sleep(0.05) \
- local image = paintutils.loadImage(\".Elico/Splash3.logo\")\
- paintutils.drawImage(image, 1, 1) \
- term.setCursorPos(16,14)\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.lime)\
- term.write(\"Inspiring \") \
- term.setTextColor(colors.white)\
- term.write(\"Innovation\")\
- sleep(2.0) \
- term.setBackgroundColor(colors.black)\
- term.clear()\
- sleep(0.1)\
- end \
- else\
- if not fs.exists (\".Elico/Splash.logo\") then\
- term.setCursorPos(1,1)\
- term.write (\"SPLASH FILE NOT FOUND, STARTING WITHOUT IT!\")\
- sleep(1.5)\
- term.setBackgroundColor(colors.black)\
- term.clear()\
- sleep(0.1)\
- else\
- local image = paintutils.loadImage(\".Elico/Splash.logo\")\
- paintutils.drawImage(image, 1, 1) \
- sleep(2.0) \
- term.setBackgroundColor(colors.black)\
- term.clear()\
- sleep(0.1)\
- end \
- end\
- end\
- ---------------------------------------------------------------\
- \
- term.clear()\
- if term.isColor() then\
- if fs.exists(\".Elico/Bios.logo\") then\
- local image = paintutils.loadImage(\".Elico/Bios.logo\")\
- paintutils.drawImage(image, 39, 2)\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.lime)\
- term.setCursorPos(39,7)\
- term.write(\"------------\")\
- term.setCursorPos(39,8)\
- term.write(\"SoftWareKing\")\
- end\
- end\
- \
- term.setBackgroundColor(colors.black) \
- if term.isColor() then\
- term.setTextColor(colors.blue)\
- else\
- term.setTextColor(colors.white)\
- end\
- term.setCursorPos(1,1)\
- term.write(\"()\")\
- term.setCursorPos(1,2)\
- term.write(\"][\")\
- \
- if term.isColor() then\
- term.setCursorPos(3,1)\
- term.setBackgroundColor(colors.black) \
- term.setTextColor(colors.lightGray)\
- else\
- term.setCursorPos(3,1)\
- term.setBackgroundColor(colors.black) \
- term.setTextColor(colors.white)\
- end\
- term.write(\"Elico BIOS v5.83\")\
- term.setCursorPos(3,2)\
- term.write(\"Copyright (C) Elico Software\")\
- term.setCursorPos(1,19)\
- term.write(\"16/05/2015-Elico-BIOS/Version-5-83/AZUZ-PC\")\
- \
- sleep(1.0)\
- term.setCursorPos(1,4)\
- term.write(\"Main Processor : \")\
- term.setCursorBlink(true)\
- sleep(0.8)\
- term.write(\"UltraCore 3.4GHz\")\
- term.setCursorPos(1,5)\
- term.write(\"Memory Testing : \")\
- sleep(0.8)\
- term.write(\"\"..bytesFree..\"K FREE\")\
- term.setCursorBlink(false)\
- sleep(1.0)\
- term.setTextColor(colors.white)\
- term.setCursorPos(1,7)\
- term.write(\"Trend ChipAwayBlock (R) On Guard\")\
- if term.isColor() then\
- term.setTextColor(colors.lightGray)\
- end\
- sleep(1.0)\
- term.setCursorPos(1,9)\
- term.write(\"Detecting DISK Drives ...\")\
- sleep(1.4)\
- if driveCount > 1 then\
- term.setCursorPos(1,9)\
- term.write(\" \")\
- else \
- term.setCursorPos(1,9)\
- term.write(\"No DISK Drives Connected \")\
- end\
- \
- for i = 1,6 do\
- \
- if peripheral.isPresent(sidesList[i]) then\
- if peripheral.getType(sidesList[i]) == \"modem\" then\
- modemExists = true\
- modemSide = sidesList[i]\
- elseif peripheral.getType(sidesList[i]) == \"drive\" then\
- mountName = \"None\"\
- if disk.isPresent(sidesList[i]) then\
- mountName = disk.getMountPath(sidesList[i])\
- end\
- if driveCount > 1 then\
- term.setCursorPos(1,(8+driveCount))\
- term.write(\"Disk Drive Slave : \"..mountName..\" [\"..sidesList[i]..\"]\")\
- sleep(0.05)\
- else\
- term.setCursorPos(1,(8+driveCount))\
- term.write(\"Disk Drive Master : \"..mountName..\" [\"..sidesList[i]..\"]\")\
- sleep(0.05)\
- bootDrive = sidesList[i]\
- bootDriveExists = true\
- end\
- driveCount = driveCount + 1\
- end\
- end\
- end\
- sleep(0.7)\
- if term.isColor() then\
- if modemExists then\
- term.setCursorPos(1,18)\
- term.write(\"Modem <\")\
- term.setTextColor(colors.white)\
- term.write(\"CONNECTED\")\
- term.setTextColor(colors.lightGray)\
- term.write(\">: [\"..modemSide..\"] IP: \"..clientId..\"\")\
- else\
- term.setCursorPos(1,18)\
- term.write(\"Modem <\")\
- term.setTextColor(colors.white)\
- term.write(\"NOT CONNECTED\")\
- term.setTextColor(colors.lightGray)\
- term.write(\">\")\
- end\
- else\
- if modemExists then\
- term.setCursorPos(1,18)\
- term.write(\"Modem <\")\
- term.setTextColor(colors.white)\
- term.write(\"CONNECTED\")\
- term.write(\">: [\"..modemSide..\"] IP: \"..clientId..\"\")\
- else\
- term.setCursorPos(1,18)\
- term.write(\"Modem <\")\
- term.setTextColor(colors.white)\
- term.write(\"NOT CONNECTED\")\
- term.write(\">\")\
- end\
- end\
- sleep(1.8)\
- \
- term.clear()\
- term.setCursorPos(1,1)\
- term.setCursorBlink(true)\
- sleep(2.0)\
- term.setCursorBlink(false)\
- term.clear()\
- term.setCursorPos(1,1)\
- if term.isColor() then\
- term.setTextColor(colors.lightGray)\
- end\
- term.write(string.rep(\" \", x))\
- centerText(\"Elico Software\", 1)\
- term.write(string.rep(\" \", x))\
- centerText(\"System Configurations\", 2)\
- \
- print (\"+-------------------------------------------------+\")\
- print (\"|CPU Type : UltraCore | Free Memory : |\")\
- print (\"|CPU Clock : 3.4GHz | CPU ID : |\")\
- print (\"+-------------------------------------------------+\")\
- print (\"| | Display : |\")\
- print (\"| | |\")\
- print (\"| | |\")\
- print (\"| | |\")\
- print (\"| | |\")\
- print (\"+-------------------------------------------------+\")\
- print (\" \")\
- print (\"ALL device listing ..... \")\
- print (\"Device Class Number Side \")\
- print (\"---------------------------------------------------\")\
- \
- if term.isColor() then\
- term.setCursorPos(42,7)\
- term.write(\"Advanced\")\
- else\
- term.setCursorPos(42,7)\
- term.write(\"Typical\")\
- end\
- \
- if driveCount < 2 then\
- term.setCursorPos(2,7)\
- term.write(\"Disk Master : Not Connected\")\
- end\
- \
- if driveCount < 3 then\
- term.setCursorPos(2,8)\
- term.write(\"Disk Slave : Not Connected\")\
- end\
- \
- if driveCount < 4 then\
- term.setCursorPos(2,9)\
- term.write(\"Disk Slave : Not Connected\")\
- end\
- \
- if driveCount < 5 then\
- term.setCursorPos(2,10)\
- term.write(\"Disk Slave : Not Connected\")\
- end\
- \
- if driveCount < 6 then\
- term.setCursorPos(2,11)\
- term.write(\"Disk Slave : Not Connected\")\
- end\
- \
- local driveCount = 1\
- \
- for i = 1,6 do\
- \
- if peripheral.isPresent(sidesList[i]) then\
- if peripheral.getType(sidesList[i]) == \"modem\" then\
- modemExists = true\
- modemSide = sidesList[i]\
- elseif peripheral.getType(sidesList[i]) == \"drive\" then\
- mountName = \"None\"\
- if disk.isPresent(sidesList[i]) then\
- mountName = disk.getMountPath(sidesList[i])\
- end\
- if driveCount > 1 then\
- term.setCursorPos(2,(6+driveCount))\
- term.write(\"Disk Slave : \"..mountName..\" [\"..sidesList[i]..\"]\")\
- else\
- term.setCursorPos(2,(6+driveCount))\
- term.write(\"Disk Master : \"..mountName..\" [\"..sidesList[i]..\"]\")\
- bootDrive = sidesList[i]\
- bootDriveExists = true\
- end\
- driveCount = driveCount + 1\
- end\
- end\
- end\
- \
- term.setCursorPos(40,4)\
- print(\"\"..bytesFree..\"K\")\
- term.setCursorPos(35,5)\
- print(\"\"..clientId..\"\")\
- \
- term.setCursorPos(1,17)\
- \
- for i = 1, #sides do\
- if peripheral.isPresent(sides[i]) then\
- if peripheral.getType(sides[i]) == \"modem\" then\
- modemSide = sidesList[i]\
- print(\"Modem \"..modemCount..\" \"..modemSide..\" \")\
- modemCount = modemCount + 1\
- sleep(0.3)\
- end\
- end\
- end\
- for i = 1, #sides do\
- if peripheral.isPresent(sides[i]) then\
- if peripheral.getType(sides[i]) == \"printer\" then\
- printerSide = sidesList[i]\
- print(\"Printer \"..printerCount..\" \"..printerSide..\" \")\
- printerCount = printerCount + 1\
- sleep(0.3)\
- end\
- end\
- end\
- for i = 1, #sides do\
- if peripheral.isPresent(sides[i]) then\
- if peripheral.getType(sides[i]) == \"monitor\" then\
- monitorSide = sidesList[i]\
- print(\"Monitor \"..monitorCount..\" \"..monitorSide..\" \")\
- monitorCount = monitorCount + 1\
- sleep(0.3)\
- end\
- end\
- end\
- for i = 1, #sides do\
- if peripheral.isPresent(sides[i]) then\
- if peripheral.getType(sides[i]) == \"drive\" then\
- driveSide = sidesList[i]\
- print(\"Disk Drive \"..driveCount0..\" \"..driveSide..\" \")\
- driveCount0 = driveCount0 + 1\
- sleep(0.3)\
- end\
- end\
- end\
- \
- print(\"\")\
- sleep(0.3)\
- print(\"\") \
- sleep (0.6)\
- local sides = { \"left\", \"right\", \"top\", \"bottom\", \"front\", \"back\"}\
- for i = 1, #sides do\
- if peripheral.isPresent(sides[i]) then\
- if peripheral.getType(sides[i]) == \"drive\" then\
- term.setCursorPos(1,19)\
- print (\"Verifying DISK Drives Data \")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data .\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data ..\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data ...\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data ....\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data .....\")\
- sleep (0.05) \
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data ......\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data .......\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data ........\")\
- sleep (0.05) \
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data .........\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data ..........\")\
- sleep (0.05)\
- term.setCursorPos(1,18)\
- print (\"Verifying DISK Drives Data .......... Success\")\
- sleep (0.7)\
- break\
- end\
- end\
- end\
- \
- if fs.exists(\".Elico/initrd\") then\
- term.setCursorPos(1,19)\
- print (\"Starting ElicoBoot ...\")\
- term.setCursorPos(1,18)\
- sleep (1.2)\
- term.clear()\
- term.setTextColor(colors.white)\
- \
- if bootDriveExists and disk.isPresent(bootDrive) then\
- mountName = disk.getMountPath(bootDrive)..\"/autoexec\"\
- if fs.exists(mountName) then\
- bootableDisk = true\
- end\
- end\
- \
- -- Launch Boot Manager --\
- readBootOptions()\
- \
- -- Draw Boot Manager GUI Interface --\
- local bootOptLen = table.getn(bootOpt)\
- while true do\
- if term.isColor() then\
- term.setBackgroundColor(colors.lightGray)\
- else\
- term.setBackgroundColor(colors.white)\
- end\
- term.clear()\
- term.setCursorPos(1,1)\
- if term.isColor() then\
- term.setBackgroundColor(colors.lightGray)\
- term.setTextColor(colors.lime)\
- else\
- term.setBackgroundColor(colors.white)\
- term.setTextColor(colors.black)\
- end\
- term.write(string.rep(\" \", x))\
- centerText(\"<> ElicoBoot\", 5)\
- \
- for i=1,bootOptLen do\
- local str = \"Option\"\
- local nameLen = string.len(bootOpt[i].name)\
- local addspaces = labLen - tonumber(nameLen)\
- if addspaces >= 0 then\
- str = i..\" \"..bootOpt[i].name\
- str = str..string.rep(\" \", addspaces)\
- else\
- str = string.sub(bootOpt[i].name, 1, labLen)\
- end\
- if i == slc then\
- if term.isColor() then\
- term.setBackgroundColor(colors.gray)\
- term.setTextColor(colors.lightGray)\
- else\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.white)\
- end\
- term.setCursorPos(19,(i+6))\
- write(str)\
- term.setCursorPos(18,(i+6))\
- write(\"->\")\
- \
- \
- else \
- if term.isColor() then\
- term.setBackgroundColor(colors.lightGray)\
- term.setTextColor(colors.gray)\
- else\
- term.setBackgroundColor(colors.white)\
- term.setTextColor(colors.black)\
- end\
- term.setCursorPos(19,(i+6))\
- write(str)\
- term.setCursorPos(18,(i+6))\
- write(\" \")\
- end\
- end\
- if term.isColor() then\
- term.setBackgroundColor(colors.lightGray)\
- term.setTextColor(colors.gray) \
- else\
- term.setBackgroundColor(colors.white)\
- term.setTextColor(colors.black) \
- end\
- term.setCursorPos(4, (y-1))\
- write(\"Press F5 to restart or F6 to shutdown system.\")\
- term.setTextColor(colors.white)\
- term.setCursorPos(1,1)\
- local event, p1, p2 = os.pullEvent()\
- if event == \"key\" then \
- if p1 == keys.up and slc > 1 then slc=slc-1\
- elseif p1 == keys.down and slc < bootOptLen then slc=slc+1\
- elseif p1 == keys.enter then\
- local args = { }\
- bootOptcmd = bootOpt[slc].dir\
- if bootOpt[slc].args ~= null then\
- args = split(bootOpt[slc].args, \",\")\
- for a=1,table.getn(args) do\
- bootOptcmd = bootOptcmd..\" \"..args[a]\
- \
- end\
- end \
- term.setBackgroundColor(colors.black)\
- term.clear()\
- shell.run(bootOptcmd)\
- sleep(1)\
- elseif p1 == keys.f5 then\
- os.reboot()\
- elseif p1 == keys.f6 then\
- os.shutdown()\
- end\
- end\
- end\
- function restoreEvent()\
- function os.pullEvent( _sFilter )\
- local event, p1, p2, p3, p4, p5 = os.pullEventRaw( _sFilter )\
- if event == \"terminate\" then\
- print( \"Terminated\" )\
- error()\
- end\
- return event, p1, p2, p3, p4, p5\
- end\
- end\
- \
- else \
- term.setCursorPos(1,19)\
- print (\"BOOT FAILURE, CREATE BOOTLIST FILE AND REBOOT\")\
- end",
- }
- local function writeFile(path,content)
- local file = fs.open(path,"w")
- file.write(content)
- file.close()
- end
- function writeDown(input,dir)
- for i,v in pairs(input) do
- if type(v) == "table" then
- writeDown(v,dir.."/"..i)
- elseif type(v) == "string" then
- writeFile(dir.."/"..i,v)
- end
- end
- end
- args = {...}
- if #args == 0 then
- print("Please input a destination folder.")
- else
- writeDown(inputTable,args[1])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement