Advertisement
minimite

sysinfo_stable

Jul 22nd, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.13 KB | None | 0 0
  1. --SysInfo by Atenefyr
  2. --[[
  3. Copyright (c) 2015 Atenefyr
  4.  
  5. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  6.  
  7. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  8.  
  9. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  10. ]]
  11.  
  12. --[[
  13. What's new for 15w29a?
  14. - Downgraded GlassOS support to partial
  15. - Upgraded [os] support to full
  16. - Removed Extended Shell detection due to it being shaky
  17. - Removed first stage of OTOS detection
  18. - Removed SmashOS detection due to it being shaky
  19. - Added full support for Craftbang
  20. - Implemented usage of O.getReleaseVersion()
  21. - Added support for future Lua 5.2 update
  22. ]]
  23.  
  24.  
  25. local function explode(div,str) -- credit: http://richard.warburton.it
  26.   if (div=='') then return false end
  27.   local pos,arr = 0,{}
  28.   -- for each divider found
  29.   for st,sp in function() return string.find(str,div,pos,true) end do
  30.     table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
  31.     pos = sp + 1 -- Jump past current divider
  32.   end
  33.   table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
  34.   return arr
  35. end
  36.  
  37.  
  38. function getos()
  39. local ost = ""
  40. local v = ""
  41.  
  42. if osdata then
  43.   ost = osdata.name
  44.   v = osdata.version
  45. elseif fs.exists(".os_info") then
  46.   local open = fs.open(".os_info", "r")
  47.   ost = open.readLine()
  48.   v = open.readLine()
  49.   open.close()
  50. elseif fs.isDir("LyqydOS") then
  51.   if fs.exists("LyqydOS/installer") then
  52.     local open = fs.open("LyqydOS/installer", "r")
  53.     repeat
  54.       line = open.readLine()
  55.     until line:find("versionNumber")
  56.     line = line:gsub("local ", "")
  57.     load(line)()
  58.     v = versionNumber
  59.   end
  60.   ost = "LyqydOS"
  61. elseif fs.isDir("craftbang") then
  62.   ost = "Craftbang"
  63.   local open = fs.open("craftbang/session", "r")
  64.   repeat
  65.     line = open.readLine() or 'version = ""'
  66.   until line:find("version = ")
  67.   line = line:gsub("version = ", "return ")
  68.   v = load(line)()
  69. elseif fs.exists("rainos") and fs.isDir("rainos") then
  70.   ost = "RainOS"
  71. elseif fs.exists(".kernel/core/os") then
  72.   ost = "Base"
  73.   local open = fs.open(".kernel/core/os", "r")
  74.   repeat
  75.     l = open.readLine()
  76.   until l:find("Base V")
  77.   l = l:sub(2)
  78.   l = l:gsub("Base V", "")
  79.   l = l:gsub(" by Sam Gunner.", "")
  80.   v = l
  81. elseif fs.exists(".system/run.sys") then
  82.   ost = "Glass OS"
  83. elseif lyokos then
  84.   ost = "LyokOS"
  85.   v = lyokos.version()
  86. elseif fs.exists("users") and fs.isDir("users") and fs.exists("accountDatabase") and fs.exists("updateOS") then
  87.   ost = "NanoOS"
  88. elseif fs.isDir("Love") then
  89.   ost = "LoveOS"
  90. elseif VERSION_STRING and VERSION_STRING:match("XWin") then
  91.   ost = VERSION_STRING:gsub("Kernel Version ", "")
  92. elseif fs.isDir("ZROOT") then
  93.   ost = "ZoS"
  94. elseif OneOS then
  95.   ost = "OneOS"
  96.   v = OneOS.Version()
  97. elseif fs.exists("/System/APIs/System.lua") then
  98.   ost = "OneOS"
  99.   v = "2.0"
  100. elseif fs.exists("/System/API/Bedrock.lua") then
  101.   ost = "OneOS"
  102.   v = "1.0"
  103. elseif cmd or fs.isDir(".cmd") then --APIs can't access "cmd" for some stupid reason
  104.   ost = "Command Alpha"
  105. elseif fs.exists("system/os/apps/desktop") then
  106.   ost = "LinOS"
  107. elseif fs.exists("LabyOS") and fs.isDir("LabyOS") then
  108.   ost = "LabyOS"
  109. elseif fs.exists("NxOS") and fs.isDir("NxOS") and fs.exists("NxOS/Files") then
  110.   ost = "NxOS"
  111.   v = "1.0"
  112. elseif fs.exists("NxOS") and fs.isDir("NxOS") then
  113.   ost = "NxOS"
  114.   v = "2.0"
  115. elseif fs.exists(".sertexos") and fs.isDir(".sertexos") then
  116.   ost = "SertexOS"
  117. elseif fs.exists("LimeFyre/.version") then
  118.   local open = fs.open("LimeFyre/.version", "r")
  119.   v = open.readAll()
  120.   open.close()
  121.   ost = "LimeFyre 2"
  122. elseif fs.isDir("MCOS") and fs.exists("startup") then
  123.   ost = "MCOS"
  124.   local open = fs.open("startup", "r")
  125.   repeat
  126.     l = open.readLine() or "version = \"\""
  127.   until l:find("version")
  128.   l = l:gsub("version =", "return")
  129.   open.close()
  130.   v = load(l)()
  131. elseif fs.exists("skins/limefyre") then
  132.   ost = "LimeFyre Classic"
  133. elseif fs.exists("OS/chromestore") and fs.exists("OS/choose") then
  134.   local open = fs.open("OS/choose", "r")
  135.   repeat
  136.     line = open.readLine()
  137.   until line:find("version")
  138.   open.close()
  139.   line = line:gsub("local version = ", "")
  140.   v = load("return " .. line)()
  141.   ost = "ChromeOS"
  142. elseif fs.exists("OS/chromestore") and fs.isDir("OS") and fs.exists("OS/d2.img") then
  143.   ost = "ChromeOS"
  144.   v = "2.0"
  145. elseif fs.exists("OS/chromestore") and fs.isDir("OS") and fs.exists("OS/passwort") then
  146.   ost = "ChromeOS"
  147.   v = "2.5"
  148. elseif fs.exists("OS/chromestore") and fs.isDir("OS") then
  149.   ost = "ChromeOS"
  150. elseif fs.exists("kepler") and fs.isDir("kepler") then
  151.   ost = "KeplerOS"
  152. elseif fs.exists("LongOS") and fs.isDir("LongOS") then
  153.   ost = "LongOS"
  154. elseif fs.exists("terminal_starter") then
  155.   ost = "AdmiOS"
  156. elseif fs.exists("prezentace") then
  157.   ost = "Pepdroll Classic"
  158. elseif fs.exists(".core/biosset") then
  159.   ost = "Pepdroll Six Professional"
  160. elseif fs.exists("flix") and fs.exists("apps/desktop/desktop") then
  161.   ost = "FlixOS"
  162.   v = "Metro"
  163. elseif fs.exists(".background") and fs.exists("gui") then
  164.   ost = "FlixOS"
  165.   v = "Beta"
  166. elseif fs.exists("logo") and fs.exists("bk1") and fs.exists("bk2") then
  167.   ost = "Stained Glass OS"
  168. elseif fs.exists("system/pocketshell") then
  169.   ost = "PocketShell"
  170. elseif fs.exists("pockyOS") and fs.isDir("pockyOS") then
  171.   ost = "PockyOS"
  172. elseif fs.exists("/kernel/locker") then
  173.   ost = "Unix for Minecraft"
  174. elseif fs.exists("/boot/uberkernel") then
  175.   ost = "UberOS"
  176. elseif fs.exists("login~") then
  177.   ost = "bOS"
  178. elseif fs.exists("doorOS") and fs.isDir("doorOS") then
  179.   ost = "DoorOS"
  180. elseif version and OStag == "ApfelOS" then
  181.   v = version
  182.   ost = "ApfelOS"
  183. elseif fs.exists("ApfelOS_PE") then
  184.   v = version
  185.   ost = "ApfelOS PE"
  186. elseif fs.isDir("Windows7") and fs.exists("Windows7/windows-welcome") then
  187.   ost = "Windows 7 ComputerCraft Edition"
  188. elseif fs.isDir("dev/sda1") and fs.isDir("dev/sda2") then
  189.   ost = "ScaptOS"
  190. elseif fs.exists("ApfelOS") and fs.isDir("ApfelOS") then
  191.   ost = "ApfelOS"
  192. elseif fs.exists("fLib") then
  193.   ost = "FroddeOS"
  194. elseif fs.exists("uOS") then
  195.   local open = fs.open("uOS", "r")
  196.   local l = ""
  197.   repeat
  198.     l = open.readLine()
  199.   until l:find("version")
  200.   l = l:gsub("version = ", "")
  201.   v = load("return " .. l)()
  202.   open.close()
  203.   ost = "uOS"
  204. elseif fs.exists("void/version") then
  205.   local open = fs.open("void/version", "r")
  206.   v = open.readLine()
  207.   open.close()
  208.   ost = "VoidOS"
  209. elseif fs.exists("core/apis/versioninfo") then
  210.   os.loadAPI("core/apis/versioninfo")
  211.   ost = "NinOS"
  212.   v = versioninfo.version
  213.   os.unloadAPI("core/apis/versioninfo")
  214. elseif fs.exists(".bustedOS") then
  215.   local open = fs.open(".bustedOS/osFiles/version", "r")
  216.   v = open.readLine()
  217.   ost = "BustedOS"
  218. elseif fs.exists(".system/os.program") then
  219.   ost = "IsaaxOS"
  220.   if build then
  221.     v = "build"
  222.   end
  223. elseif fs.exists("jupiterOS") and fs.isDir("jupiterOS") then
  224.   local open = fs.open("jupiterOS/files/version", "r")
  225.   local version = open.readAll()
  226.   open.close()
  227.   ost = "JupiterOS"
  228.   v = version
  229. elseif fs.exists(".kitten/api/kitapi") and fs.exists("startup") then
  230.   ost = "KittenOS"
  231.   local open = fs.open("startup", "r")
  232.   repeat
  233.     l = open.readLine()
  234.   until l:find("version")
  235.   open.close()
  236.   l = l:gsub("local version =", "return")
  237.   v = load(l)()
  238. elseif fs.exists("npp.e04") then
  239.   ost = "RockOS"
  240.   v = "2.5"
  241. elseif fs.exists(".System") and fs.isDir(".System") and fs.exists(".System/Programs/devgui") then
  242.   ost = "RockOS"
  243.   v = "3.0"
  244. elseif fs.exists(".sys/fos") and fs.isDir(".sys") then
  245.   if buildname and build then
  246.     ost = buildname
  247.     v = build
  248.   else
  249.     ost = "FlowOS"
  250.   end
  251. elseif fs.exists("linear") and fs.isDir("linear") then
  252.   ost = "LinearOS"
  253.   if fs.exists("startup") then
  254.     local open = fs.open("startup", "r")
  255.     repeat
  256.       l = open.readLine()
  257.     until l:find("version")
  258.     assert(load(l))()
  259.     v = version
  260.   end
  261. elseif fs.exists("CCWin") then
  262.   ost = "CCWin"
  263. elseif fs.exists("System") and fs.isDir("System") and fs.exists("System/Password") and fs.exists("System/bg") then
  264.   ost = "Floose System"
  265. elseif fs.exists("cp-dos") and fs.isDir("cp-dos") then
  266.   ost = "CP-DOS"
  267. elseif fs.exists("system2") then
  268.   ost = "CCWin"
  269. elseif _G.deltaOS and versionStr then
  270.   ost = versionStr
  271. elseif fs.isDir("Nova") then
  272.   ost = "Nova Horizon"
  273. elseif fs.isDir(".nova") then
  274.   ost = "Nova Horizon"
  275. elseif fs.exists("home") and fs.isDir("home") and fs.exists("home/mouse.cfg") then
  276.   ost = "CryptonOS"
  277. elseif fs.exists("System") and fs.isDir("System") and fs.exists("System/PearOS.lua") then
  278.   ost = "PearOS"
  279. elseif fs.exists("LuaSS/apis/LuaSS") then
  280.   local open = fs.open("LuaSS/apis/LuaSS", "r")
  281.   repeat
  282.     l = open.readLine()
  283.   until l:find("version = ")
  284.   l = l:gsub("version =", "return")
  285.   open.close()
  286.   v = load(l)()
  287.   ost = "LuaSS"
  288. elseif fs.exists("/system/config/version") and fs.exists("/system/apis/skylark") then
  289.   local open = fs.open("/system/config/version", "r")
  290.   v = open.readAll()
  291.   open.close()
  292.   ost = "KreOS"
  293. elseif fs.exists("bin/KiloShell.lua") and fs.isDir("bin") and fs.exists("sbin/kernel.lua") then
  294.   local open = fs.open("sbin/kernel.lua","r")
  295.   repeat
  296.     line = open.readLine()
  297.   until line:find("VERSION")
  298.   line = line:gsub("local VERSION =", "return")
  299.   open.close()
  300.   local version = assert(load(line))()
  301.   ost = "KilOS"
  302.   v = version
  303. elseif fs.exists("craftoidOS") then
  304.   ost = "Craftoid"
  305. elseif fs.exists(".kruss_files") and fs.isDir(".kruss_files") then
  306.   ost = "Kruss Beta"
  307. elseif fs.exists("system") and fs.isDir("system") and fs.exists("system/system.lua") and fs.exists("system/configs/version.lua") then
  308.   local open = fs.open("system/configs/version.lua", "r")
  309.   load(open.readAll():gsub("system.", ""))()
  310.   open.close()
  311.   v = versionFull
  312.   ost = "ApeOS"
  313.   version = nil
  314. elseif fs.isDir("disqueC") and fs.isDir("disqueD") then
  315.   ost = "Wincraft 8 Pro"
  316. elseif fs.exists("AuroraOS") and fs.isDir("AuroraOS") then
  317.   ost = "AuroraOS"
  318. elseif OmniOS then
  319.   ost = "OmniOS"
  320.   v = OmniOS.version:gsub("^%l", string.upper) .. " " .. OmniOS.tag
  321. elseif fs.isDir("OmniOS") and fs.exists("OmniOS/API/OmniOS.lua") then
  322.   local open = fs.open("OmniOS/API/OmniOS.lua", "r")
  323.   local s = open.readLine():gsub("version = \"", ""):gsub("\"", ""):gsub("^%l", string.upper)
  324.   local t = open.readLine():gsub("tag = \"", ""):gsub("\"", "")
  325.   open.close()
  326.   ost = "OmniOS"
  327.   v = s .. " " .. t
  328. elseif fs.isDir("OmniOS") and not fs.exists("OmniOS/API/OmniOS.lua") then
  329.   ost = "OmniOS"
  330. elseif fs.isDir("turtleshell") and fs.exists("turtleshell/os.db") then
  331.   local open = fs.open("turtleshell/os.db", "r")
  332.   local t = ""
  333.   for i = 1, 4 do
  334.     t = open.readLine()
  335.   end
  336.   t = t:gsub("  ", ""):gsub(",", "")
  337.   load(t)()
  338.   ost = "TurtleShell " .. lastVersion .. " Beta"
  339. elseif fs.isDir("B00tloader") and fs.isDir("System/API") then
  340.   ost = "LinOS Alpha"
  341. elseif O then
  342.   ost = "O"
  343.   if O.getReleaseVersion then
  344.     v = O.getReleaseVersion()
  345.   elseif O.getVersionNumber then
  346.     v = O.getVersionNumber()
  347.   end
  348. elseif fs.exists("systemO/version") then
  349.   local open = fs.open("systemO/version", "r")
  350.   v = open.readAll()
  351.   open.close()
  352.   ost = "O"
  353. elseif fs.exists("systemO/odata/version") then
  354.   local open = fs.open("systemO/odata/version", "r")
  355.   v = open.readAll()
  356.   open.close()
  357.   ost = "O"
  358. elseif fs.isDir("fd") then
  359.   ost = "FloppyDOS"
  360. elseif fs.isDir("BananaOS") and fs.exists("BananaOS/system") then
  361.   local open = fs.open("BananaOS/system", "r")
  362.   repeat
  363.     l = open.readLine()
  364.   until l:find("version = ")
  365.   open.close()
  366.   l = l:gsub("version = ", "")
  367.   v = load("return " .. l)()
  368.   ost = "BananaOS"
  369. elseif OTOS then
  370.   if OTOS.version then
  371.     v = OTOS.version
  372.   elseif OTOS.fetch then
  373.     v = OTOS.fetch("version") .. " " .. OTOS.fetch("edition")
  374.   end
  375.   ost = "OpenTerminalOS"
  376. elseif fs.isDir("OTOS") and not fs.exists("OTOS/internalapis/OTOS") and not fs.exists("version") then
  377.   ost = "OpenTerminalOS"
  378.   v = "Nightly"
  379. elseif osStuff or fs.exists("library/osStuff") then
  380.   ost = "[os]"
  381.   if osStuff then
  382.     if osStuff.version then
  383.       v = osStuff.version
  384.     end
  385.   end
  386. elseif fs.exists("guiapi") and fs.exists("touchpoint") and fs.exists("master") then
  387.   ost = "Kizz OS"
  388. elseif fs.exists("usr/etc/release") then
  389.   local open = fs.open("usr/etc/release", "r")
  390.   local p = open.readAll()
  391.   open.close()
  392.   ost = p
  393. elseif fs.exists("kernel/TestRunner.lua") and not fs.exists("usr/etc/release") then
  394.   ost = "TARDIX System"
  395. else
  396.   if os.version then
  397.     t = explode(" ", os.version())
  398.     ost = ""
  399.     for i = 1, #t-1 do
  400.       ost = ost .. t[i] .. " "
  401.     end
  402.     ost = ost:sub(1,-2)
  403.     v = t[#t]
  404.   else
  405.     ost = "CraftOS"
  406.   end
  407. end
  408.  
  409. v = tostring(v) or ""
  410. return ost, v
  411. end
  412.  
  413.  
  414. function getdevice()
  415.     if turtleedu and turtle then
  416.         return "ComputerCraftEdu Turtle"
  417.     elseif turtle and not term.isColor then
  418.         return "Pre-1.4 Normal Turtle"
  419.     elseif not term.isColor then
  420.         return "Pre-1.4 Normal Computer"
  421.     elseif commands then
  422.         return "Command Computer"
  423.     elseif term.isColor() and pocket then
  424.         return "Advanced Pocket Computer"
  425.     elseif not term.isColor() and pocket then
  426.         return "Normal Pocket Computer"
  427.     elseif term.isColor() and turtle then
  428.         return "Advanced Turtle"
  429.     elseif term.isColor() and not turtle then
  430.         return "Advanced Computer"
  431.     elseif not term.isColor() and turtle then
  432.         return "Normal Turtle"
  433.     else
  434.         return "Normal Computer"
  435.     end
  436. end
  437.  
  438. function version() --SysInfo version
  439.   return "15w29a" --Released July 18th, 2015
  440. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement