SHOW:
|
|
- or go back to the newest paste.
| 1 | - | Clocal component = require("component") |
| 1 | + | Clocal component = require("component")
|
| 2 | - | local fs = require("filesystem") |
| 2 | + | local fs = require("filesystem")
|
| 3 | - | local internet = require("internet") |
| 3 | + | local internet = require("internet")
|
| 4 | - | local shell = require("shell") |
| 4 | + | local shell = require("shell")
|
| 5 | - | |
| 5 | + | |
| 6 | - | if not component.isAvailable("internet") then |
| 6 | + | if not component.isAvailable("internet") then
|
| 7 | - | io.stderr:write("This program requires an internet card to run.") |
| 7 | + | io.stderr:write("This program requires an internet card to run.")
|
| 8 | - | return |
| 8 | + | return |
| 9 | - | end |
| 9 | + | end |
| 10 | - | |
| 10 | + | |
| 11 | - | local function get(filename) |
| 11 | + | local function get(filename) |
| 12 | - | local f, reason = io.open(filename, "w") |
| 12 | + | local f, reason = io.open(filename, "w") |
| 13 | - | if not f then |
| 13 | + | if not f then |
| 14 | - | io.stderr:write("Failed opening file for writing: " .. reason) |
| 14 | + | io.stderr:write("Failed opening file for writing: " .. reason)
|
| 15 | - | return |
| 15 | + | return |
| 16 | - | end |
| 16 | + | end |
| 17 | - | |
| 17 | + | |
| 18 | - | io.write("Downloading http://www.carr-ireland.com/mc/" .. filename .. " ") |
| 18 | + | io.write("Downloading http://www.carr-ireland.com/mc/" .. filename .. " ")
|
| 19 | - | local url = "http://www.carr-ireland.com/mc/" .. filename |
| 19 | + | local url = "http://www.carr-ireland.com/mc/" .. filename |
| 20 | - | local result, response = pcall(internet.request, url) |
| 20 | + | local result, response = pcall(internet.request, url) |
| 21 | - | if result then |
| 21 | + | if result then |
| 22 | - | io.write("OK.\nSaving " .. filename) |
| 22 | + | io.write("OK.\nSaving " .. filename)
|
| 23 | - | for chunk in response do |
| 23 | + | for chunk in response do |
| 24 | - | io.write(".") |
| 24 | + | io.write(".")
|
| 25 | - | string.gsub(chunk, "\r\n", "\n") |
| 25 | + | string.gsub(chunk, "\r\n", "\n") |
| 26 | - | f:write(chunk) |
| 26 | + | f:write(chunk) |
| 27 | - | end |
| 27 | + | end |
| 28 | - | |
| 28 | + | |
| 29 | - | f:close() |
| 29 | + | f:close() |
| 30 | - | io.write("OK\n") |
| 30 | + | io.write("OK\n")
|
| 31 | - | else |
| 31 | + | else |
| 32 | - | io.write("failed.\n") |
| 32 | + | io.write("failed.\n")
|
| 33 | - | f:close() |
| 33 | + | f:close() |
| 34 | - | fs.remove(filename) |
| 34 | + | fs.remove(filename) |
| 35 | - | io.stderr:write("HTTP request failed: " .. response .. "\n") |
| 35 | + | io.stderr:write("HTTP request failed: " .. response .. "\n")
|
| 36 | - | end |
| 36 | + | end |
| 37 | - | end |
| 37 | + | end |
| 38 | - | |
| 38 | + | |
| 39 | - | local path = shell.getWorkingDirectory() |
| 39 | + | local path = shell.getWorkingDirectory() |
| 40 | - | --print(path) |
| 40 | + | --print(path) |
| 41 | - | |
| 41 | + | |
| 42 | - | if fs.exists("/usr/lib") == false then |
| 42 | + | if fs.exists("/usr/lib") == false then
|
| 43 | - | fs.makeDirectory("/usr/lib") |
| 43 | + | fs.makeDirectory("/usr/lib")
|
| 44 | - | end |
| 44 | + | end |
| 45 | - | fs.makeDirectory("/usr/lib/windowmanager") |
| 45 | + | fs.makeDirectory("/usr/lib/windowmanager")
|
| 46 | - | fs.makeDirectory("/etc/windowmanager") |
| 46 | + | fs.makeDirectory("/etc/windowmanager")
|
| 47 | - | |
| 47 | + | |
| 48 | - | shell.setWorkingDirectory("/usr/lib/windowmanager") |
| 48 | + | shell.setWorkingDirectory("/usr/lib/windowmanager")
|
| 49 | - | |
| 49 | + | |
| 50 | - | get("windowmanager.tar") |
| 50 | + | get("windowmanager.tar")
|
| 51 | - | get("tar.lua") |
| 51 | + | get("tar.lua")
|
| 52 | - | shell.execute("tar -x -f -v windowmanager.tar", _ENV) |
| 52 | + | shell.execute("tar -x -f -v windowmanager.tar", _ENV)
|
| 53 | - | print("Removing windowmanager.tar ") |
| 53 | + | print("Removing windowmanager.tar ")
|
| 54 | - | fs.remove("/usr/lib/windowmanager/windowmanager.tar") |
| 54 | + | fs.remove("/usr/lib/windowmanager/windowmanager.tar")
|
| 55 | - | print("Removing tar.lua ") |
| 55 | + | print("Removing tar.lua ")
|
| 56 | - | fs.remove("/usr/lib/windowmanager/tar.lua") |
| 56 | + | fs.remove("/usr/lib/windowmanager/tar.lua")
|
| 57 | - | |
| 57 | + | |
| 58 | - | if fs.exists("/usr/bin") == false then |
| 58 | + | if fs.exists("/usr/bin") == false then
|
| 59 | - | fs.makeDirectory("/usr/bin") |
| 59 | + | fs.makeDirectory("/usr/bin")
|
| 60 | - | end |
| 60 | + | end |
| 61 | - | shell.setWorkingDirectory("/usr/bin") |
| 61 | + | shell.setWorkingDirectory("/usr/bin")
|
| 62 | - | |
| 62 | + | |
| 63 | - | get("windowmanager.lua") |
| 63 | + | get("windowmanager.lua")
|
| 64 | - | |
| 64 | + | |
| 65 | - | shell.setWorkingDirectory(path) |
| 65 | + | shell.setWorkingDirectory(path) |
| 66 | - | shell.execute("windowmanager save-config") |
| 66 | + | shell.execute("windowmanager save-config")
|
| 67 | - | |
| 67 | + | |
| 68 | - | print("Done") |
| 68 | + | print("Done")
|
| 69 | print("Start windowmanager.lua and enjoy") |