YuRaNnNzZZ

[CC] FFRepo Installer

Mar 26th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. -------------------------------------------------------------
  2. --                       WARNING!!!                        --
  3. -- FFRepo for ComputerCraft will not be supported anymore. --
  4. -- If you want to continue using FFRepo, use OpenComputers --
  5. --                    version instead.                     --
  6. --              http://pastebin.com/BUGDqGMB               --
  7. -------------------------------------------------------------
  8.  
  9. -- FFRepo installing program
  10. -- Made by YuRaNnNzZZ (topgamer) and Sanovskiy (pater)
  11.  
  12. local basedir = '/ffbin'
  13. local baseurl = 'http://ffgs.ru/ffrepo/get/raw/true/search/by_name/value/'
  14. local prog = {'ffrepoConfig', 'ffrepoInit', 'ffrepo', 'ffrepoApi'}
  15.  
  16. print('Installing ffrepo...')
  17.  
  18. print('Installing JSON library... ')
  19. shell.run('pastebin', 'get', '4nRg9CHU', basedir .. '/json')
  20.  
  21. term.write('Checking target directory... ')
  22. if fs.exists(basedir) then
  23.     if not fs.isDir(basedir) then
  24.         print('Deleted file, created directory.')
  25.         fs.delete(basedir) -- установка любой ценой
  26.         fs.makeDir(basedir)
  27.     else
  28.         print('OK.')
  29.     end
  30. else
  31.     print('Created.')
  32.     fs.makeDir(basedir)
  33. end
  34.  
  35. print('Installing core modules...')
  36. for key,val in pairs(prog) do
  37.     term.write('  ' .. val .. '... ')
  38.     targetDir = basedir
  39.     local dl = http.get(baseurl .. val)
  40.     local code = dl.readAll()
  41.     dl.close()
  42.     if string.len(code) < 1 then
  43.         error('Failed.')
  44.     end
  45.     if val == 'ffrepoConfig' then
  46.         targetDir = '/'
  47.     end
  48.     local filename = targetDir .. '/' .. val
  49.     local installing = fs.open(filename, "w")
  50.     installing.write(code)
  51.     installing.close()
  52.     print('Done.')
  53. end
  54. print('Core modules installed.')
  55.  
  56. local startupname = '/startup'
  57. if fs.exists(startupname) then
  58.     startupname = '/startup.ffrepo'
  59.     print('Looks like you already have startup file.')
  60.     print('You might need to add this string to your startup file:')
  61.     print('shell.run("ffbin/ffrepoInit")')
  62. end
  63. local initfile = fs.open(startupname, 'w')
  64. initfile.write('shell.run("ffbin/ffrepoInit")')
  65. initfile.close()
  66. print('Startup file saved to: ' .. startupname)
  67. print('Have a nice day.')
  68. if startupname == '/startup' then
  69.     print('Your system will be restarted in 10 seconds.')
  70.     sleep(10)
  71.     os.reboot()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment