Advertisement
joebodo

builder2-setup.lua

May 18th, 2014
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.83 KB | None | 0 0
  1. local systemFiles = {
  2.   [ '/' ] = {
  3.     [ 'startup'       ] = 'Cmnq3tgk',
  4.   },
  5.   [ '/apps' ] = {
  6.     [ 'shell'         ] = '8WCbpxQs',
  7.     [ 'multishell'    ] = 'W2f3Uj1g',
  8.     [ 'autorun.lua'   ] = 'xwX617sw',
  9.     [ 'update.lua'    ] = 'tw70aUNq',
  10.     [ 'Overview'      ] = 'Ch56YsLX',
  11.     [ 'Files'         ] = 'zbffjQBg',
  12.     [ 'Network'       ] = 'tzUUFi3q',
  13.     [ 'Lua'           ] = 'sn41FFK3',
  14.     [ 'Tabs'          ] = 'PxMTTrpW',
  15.     [ 'Peripherals'   ] = '50xYxBzh',
  16.  -- [ 'net.lua'       ] = 'f8bav3Vt',
  17.     [ 'Turtles'       ] = 'kXRSXhDT',
  18.     [ 'telnet.lua'    ] = '0f4yAW6h',
  19.   },
  20.   [ '/autorun' ] = {
  21.     [ 'network.daemon' ] = 'tzgzkKmY',
  22.     [ 'device.daemon'   ] = 'JbmTjdVH',
  23.   },
  24.   [ '/sys/apis' ] =  {
  25.     [ 'ui.api'        ] = 'rnzi2X58',
  26.     [ 'history.api'   ] = '6HDeC2Kj',
  27.     [ 'config.api'    ] = 'NUzUVuR1',
  28.     [ 'core.api'      ] = '6bb08CWK',
  29.     [ 'tracker.api'   ] = 'v5WKccY9',
  30.     [ 'socket.api'    ] = 'rTaC5qF0',
  31.     [ 'thread.api'    ] = 'VB49zPTd',
  32.     [ 'vos.api'       ] = 'Exb20U1t',
  33.     [ 'process.api'   ] = 'BkbkdF9Y',
  34.     [ 'me.api'        ] = 'NQEbZcEU',
  35.   },
  36.   [ '/sys/config' ] =  {
  37.     [ 'repository'    ] = 'GMRhVEuf',
  38.   },
  39.   [ '/sys/boot' ] =  {
  40.     [ 'default.boot'    ] = 'M6iQXhjw',
  41.     [ 'multishell.boot' ] = 'XsmCmfKu',
  42.   },
  43.   [ '/sys/network' ] =  {
  44.     [ 'telnet.plugin' ] = 'jbd9tV2n',
  45.     [ 'snmp.plugin'   ] = '0XtKbb1T',
  46.   },
  47.   [ '/apis' ] =  {
  48.     [ 'Util'          ] = '0Lrqfxzy',
  49.     [ 'Peripheral'    ] = 'LpnyHhKf',
  50.   },
  51. }
  52.  
  53. local appFiles = {
  54.   [ '/apps' ] = {
  55.     [ 'cat.lua'       ] = 'LX895Y5e',
  56.  -- [ 'ls.lua'        ] = 'DKUbgwKD',
  57.     [ 'touch.lua'     ] = 'SbPGTBqe',
  58.     [ 'which.lua'     ] = 'HybhbEEL',
  59.     [ 'colors.lua'    ] = 'TN7rE318',
  60.     [ 'pb.lua'        ] = 'e1CkBjhN',
  61.   },
  62. }
  63.  
  64. local turtleFiles = {
  65.   [ '/apps' ] = {
  66.     [ 't.lua'           ] = 'wb43Gk19',
  67.   },
  68.   [ '/sys/network' ] =  {
  69.     [ 'turtle.plugin' ] = 'u87UtX53',
  70.   },
  71.   [ '/sys/apis' ] =  {
  72.     [ 'tl2.api'        ] = 'mm1wiCH8',
  73.   },
  74. }
  75.  
  76. local storageMonitorFiles = {
  77.   [ '/apps' ] = {
  78.     [ 'storageMonitor.lua' ] = 'rByeECaM',
  79.   },
  80.   [ '/autorun' ] =  {
  81.     [ 'storageMonitor.lua' ] = 'aVF6BK51',
  82.   },
  83. }
  84.  
  85. local builderFiles = {
  86.   [ '/sys/apis' ] = {
  87.     [ 'profile.api'   ] = 'RJZCHknF',
  88.     [ 'tableDB.api'   ] = 'F19nsmDw',
  89.     [ 'schematic.api' ] = 'Z3u5zDxV',
  90.     [ 'base64.api'    ] = 'u59wCxBr',
  91.   },
  92.   [ '/apps' ] = {
  93.     [ 'builder.lua'   ] = 'bRsAtWe7',
  94.     [ 'dl.lua'        ] = 'zfiSjek5',
  95.   },
  96. }
  97.  
  98. local downloads = {
  99.   system = systemFiles,
  100.   apps = appFiles,
  101. }
  102.  
  103. local allDownloads = {
  104.   [ 'system' ] = { systemFiles },
  105.   [ 'apps' ] = {  appFiles },
  106.   [ 'turtle' ] = { turtleFiles },
  107.   [ 'storageMonitor' ] = { systemFiles, appFiles, turtleFiles, storageMonitorFiles },
  108.   [ 'builder' ] = { systemFiles, appFiles, turtleFiles, builderFiles },
  109. }
  110.  
  111. function download(downloads)
  112.   for dir, files in pairs(downloads) do
  113.     if not fs.exists(dir) then
  114.       fs.makeDir(dir)
  115.     end
  116.  
  117.     local tmpFile = '/.pastebin.tmp'
  118.     for file, key in pairs(files) do
  119.  
  120.       local cmd = string.format(
  121.         'pastebin get %s %s',
  122.         key, tmpFile)
  123.  
  124.       fs.delete(tmpFile)
  125.       shell.run(cmd)
  126.  
  127.       if fs.exists(tmpFile) then
  128.         local fullname = '/' .. fs.combine(dir, file)
  129.         if fs.exists(fullname) then
  130.           fs.delete(fullname)
  131.         end
  132.         fs.copy(tmpFile, fullname)
  133.       end
  134.     end
  135.     fs.delete(tmpFile)
  136.   end
  137. end
  138.  
  139. local args = { ... }
  140. if #args == 0 then
  141.   for _,v in pairs(downloads) do
  142.     download(v)
  143.   end
  144.   if turtle then
  145.     download(turtleFiles)
  146.   end
  147. elseif allDownloads[args[1]] then
  148.   local fileSets = allDownloads[args[1]]
  149.  
  150.   for _,v in pairs(fileSets) do
  151.     download(v)
  152.   end
  153. else
  154.   printError('syntax:')
  155.   printError('update or update <system, apps, turtle>')
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement