MrFredber

Install FOS ver. b1

Nov 21st, 2019 (edited)
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.28 KB | None | 0 0
  1. local r=require
  2. local c=r("component")
  3. local gpu=c.gpu
  4. local os=r("os")
  5. if gpu.maxDepth() == 1 then
  6. print("Screen/GPU does not support touches.")
  7. os.exit()
  8. end
  9. local fs=r("filesystem")
  10. local unicode=r("unicode")
  11. local len=unicode.len
  12. local term=r("term")
  13. local io=r("io")
  14. local w,h=gpu.getResolution();
  15. local fill=gpu.fill
  16. local color=gpu.setBackground
  17. local fcolor=gpu.setForeground
  18. local set=gpu.set
  19. local event=r("event")
  20. local dir=fs.makeDirectory
  21. local langchoise=""
  22. dir("/lib/fos")
  23. os.execute("wget -f https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/tools.lua /lib/fos/tools.lua")
  24. os.execute("wget -f https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/picture.lua /lib/fos/picture.lua")
  25. local tools=r("fos/tools")
  26. term.clear()
  27.  
  28. local function reset()
  29. color(0x2b2b2b)
  30. fill(1,1,w,h," ")
  31. color(0xffffff)
  32. fcolor(0)
  33. fill(1,1,w,1," ")
  34. set(2,1,"FOS Installer")
  35. color(0)
  36. fcolor(0xffffff)
  37. end
  38.  
  39. reset()
  40. xw=math.floor(w/2-12)
  41. hw=math.floor(h/2-3)
  42. fill(xw+1,hw+1,26,8," ")
  43. color(0xffffff)
  44. fcolor(0)
  45. fill(xw,hw,26,8," ")
  46. set(xw+10,hw+2,"Choose language")
  47. set(xw+10,hw+3,"Выберите язык")
  48. tools.btn(xw+3,hw+6,"English")
  49. tools.btn(xw+14,hw+6,"Русский")
  50. fcolor(0x0094ff)
  51. set(xw+7,hw+1,"⣶⡄")
  52. fcolor(0x0000ff)
  53. set(xw+1,hw+4,"⠘⠿    ⠿⠃")
  54. fcolor(0x00ff00)
  55. set(xw+1,hw+1,"⢠⣶")
  56. color(0x0094ff)
  57. set(xw+3,hw+1,"⣿⣿⡟⣿")
  58. color(0x0062ff)
  59. set(xw+1,hw+2,"⣿⣿⣿⠟⠋ ⡀ ")
  60. color(0x0040ff)
  61. set(xw+1,hw+3," ⠉⠿⣆⣠⠈  ")
  62. color(0x0000ff)
  63. set(xw+3,hw+4," ⠛⠁ ")
  64. color(0xb40000)
  65. fcolor(0xffffff)
  66. set(xw+23,hw," X ")
  67. while true do
  68.     _,_,x,y=event.pull("touch")
  69.     if x >= xw+3 and x <= xw+10 and y == hw+6 then
  70.         langchoise="english.lang"
  71.         break
  72.     elseif x >= xw+14 and x <= xw+22 and y == hw+6 then
  73.         langchoise="russian.lang"
  74.         break
  75.     elseif x >= xw+23 and x <= xw+26 and y == hw then
  76.         langchoise=nil
  77.         break
  78.     end
  79. end
  80.  
  81. if langchoise == nil then
  82.     color(0)
  83.     fcolor(0xffffff)
  84.     term.clear()
  85.     print("If system isn't installed on this PC, you can delete /lib/fos directory.")
  86.     os.exit()
  87. else
  88.     os.execute("wget -fq https://raw.githubusercontent.com/MrFredber/FOS/master/Install/"..langchoise.." /tmp/lang")
  89. end
  90. local lang={}
  91. local file=io.open("/tmp/lang","r")
  92. for var in file:lines() do
  93.     check=var:find("=")
  94.     if check ~= nil then
  95.         arg=unicode.sub(var,1,check-1)
  96.         var=unicode.sub(var,check+1)
  97.         lang[arg]=var
  98.     else
  99.         table.insert(lang,var)
  100.     end
  101. end
  102. file:close()
  103.  
  104. reset()
  105. xw=math.floor(w/2-37)
  106. hw=math.floor(h/2-10)
  107. fill(xw+1,hw+1,75,23," ")
  108. color(0xffffff)
  109. fcolor(0)
  110. fill(xw,hw,75,23," ")
  111. set(xw+1,hw,lang.license)
  112. slen=len(lang.licenseMsg)
  113. set(w/2-slen/2,hw+22,lang.licenseMsg)
  114. slen=len(lang.accept)
  115. tools.btn(w/2-slen/2-1,hw+21,lang.accept)
  116. color(0xe0e0e0)
  117. fill(xw,hw+1,75,19," ")
  118. set(xw,hw+1,"Copyright (C) 2021 Mr.Fredber")
  119. set(xw,hw+3,"Permission is hereby granted, free of charge, to any person obtaining a")
  120. set(xw,hw+4,"copy of this software and associated documentation files (the 'Software'),")
  121. set(xw,hw+5,"to deal in the Software without restriction, including without limitation")
  122. set(xw,hw+6,"the rights to use, copy, modify, merge, publish, distribute, sublicense,")
  123. set(xw,hw+7,"and/or sell copies of the Software, and to permit persons to whom the")
  124. set(xw,hw+8,"Software is furnished to do so, subject to the following conditions:")
  125. set(xw,hw+10,"The above copyright notice and this permission notice shall be")
  126. set(xw,hw+11,"included in all copies or substantial portions of the Software.")
  127. set(xw,hw+13,"THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR")
  128. set(xw,hw+14,"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,")
  129. set(xw,hw+15,"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL")
  130. set(xw,hw+16,"THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER")
  131. set(xw,hw+17,"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING")
  132. set(xw,hw+18,"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER")
  133. set(xw,hw+19,"DEALINGS IN THE SOFTWARE.")
  134. while true do
  135.     local _,_,x,y=event.pull("touch")
  136.     if x >= math.floor(w/2-slen/2-1) and x <= math.floor(w/2+slen/2) and y == hw+21 then
  137.         break
  138.     end
  139. end
  140.  
  141. reset()
  142. function typeDraw()
  143. hw=math.floor(h/2-7)
  144. xw=math.floor(w/2-37)
  145. fill(xw+1,hw+1,75,17," ")
  146. color(0xffffff)
  147. fcolor(0)
  148. fill(xw,hw,75,17," ")
  149. set(xw+1,hw,lang.installType)
  150. set(xw+10,hw+2,lang.typeUpgrade)
  151. set(xw+10,hw+7,lang.typeInstall)
  152. set(xw+10,hw+12,lang.typeWipe)
  153. fcolor(0x727272)
  154. set(xw+10,hw+3,lang.typeUpgradeMsg1)
  155. set(xw+10,hw+4,lang.typeUpgradeMsg2)
  156. set(xw+10,hw+8,lang.typeInstallMsg1)
  157. set(xw+10,hw+9,lang.typeInstallMsg2)
  158. set(xw+10,hw+13,lang.typeWipeMsg1)
  159. set(xw+10,hw+14,lang.typeWipeMsg2)
  160. fcolor(0x00bec1)
  161. set(xw+1,hw+2,"⠛⠛⠛⠛⠛⠛⠛⠛")
  162. fcolor(0x0094ff)
  163. set(xw+1,hw+3,"⠀⠀⠀⢸⡇⠀⠀⠀")
  164. set(xw+1,hw+4,"⠀⠀⠙⢿⡿⠋⠀⠀")
  165. fcolor(0xb200ff)
  166. set(xw+1,hw+5,"⣤⣤⣤⣤⣤⣤⣤⣤")
  167. fcolor(0x4cff00)
  168. set(xw+4,hw+2,"⠛⠛")
  169. set(xw+7,hw+2,"⠛")
  170. set(xw+4,hw+5,"⣤⣤")
  171. set(xw+7,hw+5,"⣤")
  172. fcolor(0x0094ff)
  173. set(xw+1,hw+7,"⠀⠀⠀⢸⡇⠀⠀⠀")
  174. set(xw+1,hw+8,"⠀⠀⠀⢸⡇⠀⠀⠀")
  175. set(xw+1,hw+9,"⠀⠀⠙⢿⡿⠋⠀⠀")
  176. fcolor(0xb200ff)
  177. set(xw+1,hw+10,"⣤⣤⣤⣤⣤⣤⣤⣤")
  178. fcolor(0x4cff00)
  179. set(xw+4,hw+10,"⣤⣤")
  180. set(xw+7,hw+10,"⣤")
  181. fcolor(0xff0000)
  182. set(xw+1,hw+12,"⢠⡶⢿⣿⣿⡿⢶⡄")
  183. set(xw+1,hw+13,"⣿⣷⣄⠙⠋⣠⣾⣿")
  184. set(xw+1,hw+14,"⣿⡿⠋⣠⣄⠙⢿⣿")
  185. set(xw+1,hw+15,"⠘⠷⣾⣿⣿⣷⠾⠃")
  186. installtype=0
  187. end
  188. function typeConfirm()
  189. max=len(lang.typeConfirm)+2
  190. cw=math.floor(w/2-max/2)
  191. ch=math.floor(h/2-2)
  192. reset()
  193. fill(cw+1,ch+1,max,6," ")
  194. color(0xffffff)
  195. fcolor(0)
  196. fill(cw,ch,max,6," ")
  197. set(cw+1,ch+1,lang.typeConfirm)
  198. temp={"typeUpgrade","typeInstall","typeWipe"}
  199. slen=len(lang[temp[installtype]] or "Null")
  200. set(w/2-slen/2,ch+2,lang[temp[installtype]] or "Null")
  201. slen1=len(lang.yes)
  202. slen2=len(lang.no)
  203. tlen=w/2-(slen1+slen2+5)/2
  204. tools.btn(tlen,ch+4,lang.yes)
  205. tools.btn(tlen+slen1+3,ch+4,lang.no)
  206. while true do
  207.     _,_,x,y=event.pull("touch")
  208.     if x >= tlen and x <= tlen+1+slen1 and y == ch+4 then
  209.         typeconfirmed=1
  210.         break
  211.     elseif x >= tlen+slen1+3 and x <= tlen+slen1+slen2+4 and y == ch+4 then
  212.         typeconfirmed=0
  213.         color(0)
  214.         typeDraw()
  215.         break
  216.     end
  217. end
  218. end
  219. typeDraw()
  220. while true do
  221.     _,_,x,y=event.pull("touch")
  222.     if x >= xw+1 and x <= xw+73 and y >= hw+2 and y <= hw+5 then
  223.         installtype=1
  224.         typeConfirm()
  225.         if typeconfirmed == 1 then break end
  226.     elseif x >= xw+1 and x <= xw+73 and y >= hw+7 and y <= hw+10 then
  227.         installtype=2
  228.         typeConfirm()
  229.         if typeconfirmed == 1 then break end
  230.     elseif x >= xw+1 and x <= xw+73 and y >= hw+12 and y <= hw+15 then
  231.         installtype=3
  232.         typeConfirm()
  233.         if typeconfirmed == 1 then break end
  234.     end
  235. end
  236.  
  237. if installtype == 2 or installtype == 3 then
  238.     reg={["username"]="User",["passwordProtection"]="0"}
  239.     i=1
  240.     temp={"user","username","password","passwordLvr"}
  241.     max=0
  242.     while i-1 ~= 4 do
  243.         slen=len(lang[temp[i]])
  244.         if i == 4 then
  245.             slen=slen+5
  246.         end
  247.         if slen > max then
  248.             max=slen
  249.         end
  250.         i=i+1
  251.     end
  252.     userclr=0x0094ff
  253.     reset()
  254.     xw=math.floor(w/2-max/2-1)
  255.     hw=math.floor(h/2-7)
  256.    
  257.     function userdraw()
  258.     color(0)
  259.     fcolor(0xffffff)
  260.     fill(xw+1,hw+1,max+2,16," ")
  261.     color(0xffffff)
  262.     fcolor(0)
  263.     fill(xw,hw,max+2,16," ")
  264.     set(xw,hw,lang.user)
  265.     set(xw+1,hw+6,lang.username)
  266.     set(xw+1,hw+9,lang.passwordLvr)
  267.     btnlen=len(lang.next)
  268.     tools.btn(w/2-btnlen/2-1,hw+14,lang.next)
  269.     tools.lvr(xw+max-3,hw+9,reg.passwordProtection)
  270.     if reg.passwordProtection == "1" then
  271.         set(xw+1,hw+11,lang.password)
  272.     end
  273.     fcolor(userclr)
  274.     set(w/2-3,hw+1,"⢠⡶⢿⡿⢶⡄")
  275.     set(w/2-3,hw+2,"⣿⣇⣸⣇⣸⣿")
  276.     set(w/2-3,hw+3,"⠘⠿⣮⣵⠿⠃")
  277.     set(w/2-3,hw+4,"⣀⣤⣿⣿⣤⣀")
  278.     color(0xe0e0e0)
  279.     fcolor(0)
  280.     fill(xw+1,hw+7,max,1," ")
  281.     set(xw+1,hw+7,reg.username)
  282.     if reg.passwordProtection == "1" then
  283.         fill(xw+1,hw+12,max,1," ")
  284.         slen=len(reg.password or "")
  285.         fill(xw+1,hw+12,slen,1,"*")
  286.     end
  287.     end
  288.     userdraw()
  289.    
  290.     function userInput(s)
  291.     color(0xffffff)
  292.     fcolor(0)
  293.     term.setCursor(1,h)
  294.     fill(1,h,w,1," ")
  295.     if s == true then
  296.         text=term.read({},false,"","*")
  297.     else
  298.         text=term.read({},false)
  299.     end
  300.     text=unicode.sub(text,1,-2)
  301.     color(0x2b2b2b)
  302.     fill(1,h,w,1," ")
  303.     return text
  304.     end
  305.    
  306.     while true do
  307.         _,_,x,y=event.pull("touch")
  308.         if x >= xw+max-5 and x <= xw+max and y == hw+9 then
  309.             if reg.passwordProtection == "1" then
  310.                 reg.passwordProtection="0"
  311.             else
  312.                 reg.passwordProtection="1"
  313.             end
  314.             userdraw()
  315.         elseif x >= xw+1 and x <= xw+max and y == hw+7 then
  316.             reg.username=userInput()
  317.             userdraw()
  318.         elseif x >= xw+1 and x <= xw+max and y == hw+12 then
  319.             reg.password=userInput(true)
  320.             userdraw()
  321.         elseif x >= math.floor(w/2-btnlen/2-1) and x <= math.floor(w/2+btnlen/2) and y == hw+14 then
  322.             break
  323.         end
  324.     end
  325. end
  326.  
  327. reset()
  328. temp="1"
  329. slen=len(lang.other)
  330. max=slen+5
  331. xw=math.floor(w/2-max/2-1)
  332. hw=math.floor(h/2-2)
  333.  
  334. function download()
  335. color(0)
  336. fcolor(0xffffff)
  337. fill(xw+1,hw+1,max+2,5," ")
  338. color(0xffffff)
  339. fcolor(0)
  340. fill(xw,hw,max+2,5," ")
  341. set(xw+1,hw+1,lang.other)
  342. tools.lvr(xw+max-3,hw+1,temp)
  343. slen=len(lang.install)
  344. tools.btn(w/2-slen/2-1,hw+3,lang.install)
  345. end
  346. download()
  347.  
  348. while true do
  349.     _,_,x,y=event.pull("touch")
  350.     if x >= xw+max-5 and x <= xw+max and y == hw+1 then
  351.         if temp == "1" then
  352.             temp="0"
  353.         else
  354.             temp="1"
  355.         end
  356.         download()
  357.     elseif x >= math.floor(w/2-slen/2-1) and x <= math.floor(w/2+slen/2) and y == hw+3 then
  358.         break
  359.     end
  360. end
  361.  
  362. if installtype == 3 then
  363.     fs.remove("/fos")
  364.     fs.remove("/lib/fos")
  365.     dir("/lib/fos")
  366. end
  367.  
  368. dir("/FOS/desktop")
  369. dir("/FOS/apps/Settings.app/appname")
  370. dir("/FOS/apps/Settings.app/lang")
  371. dir("/FOS/apps/Settings.app/modules/1_System")
  372. dir("/FOS/apps/Settings.app/modules/3_Personalization")
  373. dir("/FOS/apps/Settings.app/modules/4_Apps")
  374. dir("/FOS/apps/Settings.app/modules/6_DateAndLang")
  375. dir("/FOS/apps/Explorer.app/appname")
  376. dir("/FOS/lang/fos")
  377. dir("/FOS/lang/shared")
  378. dir("/FOS/system")
  379.  
  380. reset()
  381. term.setCursor(1,1)
  382. tools.fullbar(1,h,w,1)
  383. local files={
  384.     "https://raw.githubusercontent.com/MrFredber/FOS/master/FOS/fos.lua /fos/fos.lua",
  385.     "https://raw.githubusercontent.com/MrFredber/FOS/master/FOS/boot.lua /lib/core/boot.lua",
  386.     "https://raw.githubusercontent.com/MrFredber/FOS/master/FOS/foslink.lua /home/fos",
  387.     "https://raw.githubusercontent.com/MrFredber/FOS/master/FOS/bootmgr.lua /fos/bootmgr.lua",
  388.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/system.lua /lib/fos/system.lua",
  389.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/finder.lua /lib/fos/finder.lua",
  390.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/icons.lua /lib/fos/icons.lua",
  391.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/tools.lua /lib/fos/tools.lua",
  392.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Libraries/picture.lua /lib/fos/picture.lua",
  393.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/icon.spic /fos/apps/settings.app/icon.spic",
  394.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/modules/1_System/main.lua /fos/apps/settings.app/modules/1_System/main.lua",
  395.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/modules/3_Personalization/main.lua /fos/apps/settings.app/modules/3_Personalization/main.lua",
  396.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/modules/4_Apps/main.lua /fos/apps/settings.app/modules/4_Apps/main.lua",
  397.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/modules/6_DateAndLang/main.lua /fos/apps/settings.app/modules/6_DateAndLang/main.lua",
  398.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/main.lua /fos/apps/settings.app/main.lua",
  399.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Explorer.app/icon.spic /fos/apps/explorer.app/icon.spic",
  400.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Explorer.app/main.lua /fos/apps/explorer.app/main.lua",
  401.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Language/fos/english.lang /fos/lang/fos/english.lang",
  402.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Language/fos/russian.lang /fos/lang/fos/russian.lang",
  403.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Language/shared/english.lang /fos/lang/shared/english.lang",
  404.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Language/shared/russian.lang /fos/lang/shared/russian.lang",
  405.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/lang/english.lang /fos/apps/settings.app/lang/english.lang",
  406.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/lang/russian.lang /fos/apps/settings.app/lang/russian.lang",
  407.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/appname/english.lang /fos/apps/settings.app/appname/english.lang",
  408.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/appname/russian.lang /fos/apps/settings.app/appname/russian.lang",
  409.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Explorer.app/appname/english.lang /fos/apps/explorer.app/appname/english.lang",
  410.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Explorer.app/appname/russian.lang /fos/apps/explorer.app/appname/russian.lang"}
  411. local other={
  412.     "https://raw.githubusercontent.com/MrFredber/FOS/master/FOS/RAM%20test.lua /fos/desktop/'RAM test.lua'",
  413.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/icon.pic /fos/apps/settings.app/icon.pic",
  414.     "https://raw.githubusercontent.com/MrFredber/FOS/master/Applications/Settings.app/icon.bmp /fos/apps/settings.app/icon.bmp"}
  415.  
  416. i=1
  417. ibar=0
  418. percent=100/#files
  419. color(0x2b2b2b)
  420. while i-1 ~= #files do
  421.     fcolor(0xffffff)
  422.     temp=files[i]:find(" ")
  423.     set(1,h-1,files[i]:sub(temp+1))
  424.     tools.fullbar(1,h,w,percent*ibar)
  425.     color(0x2b2b2b)
  426.     os.execute("wget -fq "..files[i])
  427.     fill(1,h-1,w,2," ")
  428.     ibar=ibar+1
  429.     i=i+1
  430. end
  431. if temp == "1" then
  432.     i=1
  433.     ibar=0
  434.     percent=100/#other
  435.     color(0x2b2b2b)
  436.     while i-1 ~= #other do
  437.         fcolor(0xffffff)
  438.         temp=other[i]:find(" ")
  439.         set(1,h-1,other[i]:sub(temp+1))
  440.         tools.fullbar(1,h,w,percent*ibar)
  441.         color(0x2b2b2b)
  442.         os.execute("wget -fq "..other[i])
  443.         fill(1,h-1,w,2," ")
  444.         ibar=ibar+1
  445.         i=i+1
  446.     end
  447. end
  448. fcolor(0xffffff)
  449. color(0x0094ff)
  450. slen=len(lang.last)
  451. fill(1,1,w,h," ")
  452. set(w/2-slen/2,h/2,lang.last)
  453.  
  454. file=io.open("/fos/desktop/Settings.lnk","w")
  455. file:write("/fos/apps/settings.app")
  456. file:close()
  457. file=io.open("/fos/desktop/Explorer.lnk","w")
  458. file:write("/fos/apps/explorer.app")
  459. file:close()
  460. function standart()
  461. if reg.passwordProtection == "1" and reg.password == nil then
  462.     reg.passwordProtection="0"
  463.     reg.password="0"
  464. end
  465. w,h=gpu.maxResolution()
  466. reg.width=tostring(w)
  467. reg.height=tostring(h)
  468. reg.userColor="0x0094ff"
  469. reg.powerSafe="0"
  470. reg.ver="b1"
  471. reg.lang=langchoise
  472. reg.gpu=tostring(gpu.maxDepth())
  473. reg.dataType="%d.%m.%Y %H:%M:%S"
  474. reg.contrastColorHeaders="1"
  475. reg.taskbarShowSeconds="1"
  476. reg.timeZone=7
  477. reg.desktopColor=0x2b2b2b
  478. reg.darkMode="0"
  479. reg.contrastColor=0xd95be6
  480. file=io.open("/fos/system/auto.cfg","w")
  481. file:write("")
  482. file:close()
  483. end
  484. function userError()
  485. tools.error("File 'user.cfg' not exists or corrupted",2)
  486. reg.username="User"
  487. reg.userColor="0x0094ff"
  488. reg.passwordProtection="0"
  489. reg.password="0"
  490. end
  491. function usertransform()
  492. reg.username=usr[1]
  493. reg.userColor=usr[2]
  494. reg.passwordProtection=usr[3]
  495. if usr[3] == "1" then
  496.     reg.password=usr[4]
  497. end
  498. end
  499. function compError()
  500. tools.error("File 'comp.cfg' not exists or corrupted",2)
  501. reg.w,h=gpu.maxResolution()
  502. reg.width=tostring(w)
  503. reg.height=tostring(h)
  504. reg.powerSafe="0"
  505. end
  506. function comptransform()
  507. reg.powerSafe=cmp[1]
  508. temp=cmp[2]:find(",")
  509. reg.width=tonumber(cmp[2]:sub(1,temp-1))
  510. reg.height=tonumber(cmp[2]:sub(temp+1))
  511. end
  512. if installtype == 2 or installtype == 3 then
  513.     standart()
  514. else
  515.     temp=fs.exists("/fos/system/registry")
  516.     if not temp then
  517.         reg={}
  518.         user=fs.exists("/fos/system/user.cfg")
  519.         if not user then
  520.             userError()
  521.         else
  522.             file=io.open("/fos/system/user.cfg","r")
  523.             usr={}
  524.             for var in file:lines() do table.insert(usr,var) end
  525.             status=pcall(usertransform)
  526.             if not status then
  527.                 userError()
  528.             end
  529.         end
  530.         comp=fs.exists("/fos/system/comp.cfg")
  531.         if not comp then
  532.             compError()
  533.         else
  534.             file=io.open("/fos/system/comp.cfg","r")
  535.             cmp={}
  536.             for var in file:lines() do table.insert(cmp,var) end
  537.             status=pcall(comptransform)
  538.             if not status then
  539.                 compError()
  540.             end
  541.         end
  542.         reg.ver="b1"
  543.         reg.gpu=tostring(gpu.maxDepth())
  544.         reg.lang=langchoise
  545.         reg.dataType="%d.%m.%Y %H:%M:%S"
  546.         reg.contrastColorHeaders="1"
  547.         reg.taskbarShowSeconds="1"
  548.         reg.timeZone=7
  549.         reg.desktopColor=0x2b2b2b
  550.         reg.darkMode="0"
  551.         reg.contrastColor=0x0094ff
  552.     else
  553.         reg={}
  554.         file=io.open("/fos/system/registry","r")
  555.         for var in file:lines() do
  556.         if var:find("=") ~= nil then
  557.             check=var:find("=")
  558.             arg=unicode.sub(var,1,check-1)
  559.             var=unicode.sub(var,check+1)
  560.             reg[arg]=var
  561.         else
  562.             table.insert(reg,var)
  563.         end
  564.         end
  565.         file:close()
  566.         reg.ver="b1"
  567.     end
  568. end
  569. file=io.open("/fos/system/registry","w")
  570. for k in pairs(reg) do
  571.     file:write(k.."="..reg[k].."\n")
  572. end
  573. file:close()
  574. r("computer").shutdown(true)
Add Comment
Please, Sign In to add comment