Added self install script.

This commit is contained in:
Andrew Lalis 2023-08-29 08:03:06 -04:00
parent a3ddb06e07
commit fdedf74ddc
1 changed files with 11 additions and 1 deletions

View File

@ -72,7 +72,8 @@ local function createUser(name, password)
if not validatePassword(password) then return false, "Invalid password" end if not validatePassword(password) then return false, "Invalid password" end
if userExists(name) then return false, "Username taken" end if userExists(name) then return false, "Username taken" end
local userData = { local userData = {
password = password password = password,
createdAt = os.epoch("utc")
} }
fs.makeDir(userDir(name)) fs.makeDir(userDir(name))
local dataFile = io.open(userDataFile(name), "w") local dataFile = io.open(userDataFile(name), "w")
@ -108,6 +109,15 @@ local function renameUser(oldName, newName)
return true return true
end end
local args = {...}
if args[1] == "-i" then
print("Reinstalling from GitHub.")
fs.delete("bank.lua")
shell.execute("wget", "https://raw.githubusercontent.com/andrewlalis/kp-bank/main/bank.lua")
shell.execute("bank.lua")
end
rednet.open("modem") rednet.open("modem")
rednet.host("BANK", "central-bank") rednet.host("BANK", "central-bank")