Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Version = 1.2
- local args = {...}
- --Copyright Lyqyd
- --Copyright COOLGAMETUBE
- local exStr = [[shell.run("/usr/bin/AutoAPI loadAPIs")]]
- local function loadStartup()
- local lines = {}
- if fs.exists("/startup") then
- local handle = io.open("/startup", "r")
- if handle then
- for line in handle:lines() do
- table.insert(lines, line)
- end
- handle:close()
- end
- end
- return lines
- end
- local function writeStartup(contents)
- local handle = io.open("/startup", "w")
- if handle then
- for i, line in ipairs(contents) do
- handle:write(line.."\n")
- end
- handle:close()
- end
- end
- if #args >= 1 then
- if args[1] == "loadAPIs" then
- for _, apiF in ipairs(fs.list("/usr/apis/")) do
- if apiF ~= "package" then
- if apiF then
- os.unloadAPI(apiF)
- end
- os.loadAPI("/usr/apis/"..apiF)
- end
- end
- elseif args[1] == "install" then
- local contents = loadStartup()
- local changed = false
- if fs.exists("/startup") then
- local exists = false
- for i = 1, #contents do
- if contents[i] == exStr then
- exists = true
- break
- end
- end
- if not exists then
- table.insert(contents, 1, exStr)
- changed = true
- end
- else
- contents[1] = exStr
- changed = true
- end
- if changed then
- writeStartup(contents)
- end
- shell.run("usr/bin/AutoAPI loadAPIs")
- elseif args[1] == "remove" then
- local contents = loadStartup()
- for i = #contents, 1, -1 do
- if contents[i] == exStr then
- table.remove(contents, i)
- end
- end
- writeStartup(contents)
- elseif args[1] == "reload" then
- if #args > 1 then
- os.unloadAPI(args[2])
- os.loadAPI(args[2])
- else
- shell.run("AutoAPI loadAPIs")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement