From fdedf74ddc488596f43ee530dbf63855c023f371 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Tue, 29 Aug 2023 08:03:06 -0400 Subject: [PATCH] Added self install script. --- bank.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bank.lua b/bank.lua index 11756cc..00f739f 100644 --- a/bank.lua +++ b/bank.lua @@ -72,7 +72,8 @@ local function createUser(name, password) if not validatePassword(password) then return false, "Invalid password" end if userExists(name) then return false, "Username taken" end local userData = { - password = password + password = password, + createdAt = os.epoch("utc") } fs.makeDir(userDir(name)) local dataFile = io.open(userDataFile(name), "w") @@ -108,6 +109,15 @@ local function renameUser(oldName, newName) return true 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.host("BANK", "central-bank")