From 5252961fd785fc65517b8426143a811a0590192d Mon Sep 17 00:00:00 2001 From: brulijam Date: Sat, 8 Jun 2024 22:11:04 +0200 Subject: [PATCH] . --- src/brulijam/lib/createNetworkingKey.lua | 4 +++- src/brulijam/setLabel.lua | 9 ++++++--- src/brulijam/systemlock.lua | 4 +++- src/startup.lua | 13 +++++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/brulijam/lib/createNetworkingKey.lua b/src/brulijam/lib/createNetworkingKey.lua index 9526584..e1e612d 100644 --- a/src/brulijam/lib/createNetworkingKey.lua +++ b/src/brulijam/lib/createNetworkingKey.lua @@ -6,7 +6,9 @@ os.loadAPI("brulijam/lib/aes.lua") function createKeyfile() basic.clearDisplay() print("[Networking]") - write("Please enter shared secret for networking: ") + print("Please enter shared secret for networking.") + print("This will be used to communicate with other Devices and should be the same on different Turtles and Computers.") + write("Input: ") local pwHash = hash.digestStr(read("*") .. "salty salt") basic.writeToFile("brulijam/files/networking-key.txt", pwHash) basic.clearDisplay() diff --git a/src/brulijam/setLabel.lua b/src/brulijam/setLabel.lua index b043d03..c66a53b 100644 --- a/src/brulijam/setLabel.lua +++ b/src/brulijam/setLabel.lua @@ -1,7 +1,10 @@ -labelPrefix = "SPHEAL" - +local basic = require("lib.basic") local hash = require("lib.hash") + +local systemConfig = basic.readFileAll("/brulijam/config/systemConfig.txt") +systemConfig = textutils.unserialize(systemConfig) + if os.getComputerLabel() == nil then local labelMainPart = string.sub(hash.digestStr(string.format(os.getComputerID())), 1, 6) - os.setComputerLabel(labelPrefix .. "-" .. labelMainPart) + os.setComputerLabel(systemConfig["labelPrefix"] .. "-" .. labelMainPart) end \ No newline at end of file diff --git a/src/brulijam/systemlock.lua b/src/brulijam/systemlock.lua index e949386..027e559 100644 --- a/src/brulijam/systemlock.lua +++ b/src/brulijam/systemlock.lua @@ -13,7 +13,9 @@ local function createPwHash() while not inputConfirmed do basic.clearDisplay() print("[Systemlock]") - write("Create a new password: ") + print("Create a new password.") + print("This will be used to unlock this device.") + write("Input: ") local input = read("*") pwHash = hash.digestStr(input .. os.getComputerID()) diff --git a/src/startup.lua b/src/startup.lua index 5e2a087..2dc21e7 100644 --- a/src/startup.lua +++ b/src/startup.lua @@ -1,9 +1,22 @@ --you may change these values local repo = "https://git.brulijam.com/brulijam/Computercraft/raw/branch/main/src" +local labelPrefix = "SPHEAL" print("[Booting]") + + + +if not (fs.exists("brulijam/config/system.txt")) then + local systemConfig = {} + systemConfig["labelPrefix"] = labelPrefix + file = fs.open("brulijam/config/system.txt", "w") + file.write(systemConfig) + file.close() +end + + local motd = settings.get("motd.enable") if motd then shell.run("set motd.enable false")