From 3a05a88d4d64e84ff9c78fd0bdf8e7677af0a56a Mon Sep 17 00:00:00 2001 From: brulijam Date: Sat, 8 Jun 2024 02:04:15 +0200 Subject: [PATCH] a --- src/brulijam/lib/basic.lua | 5 +++++ src/brulijam/lib/networking.lua | 1 + src/brulijam/systemlock.lua | 22 ++++++++++++++++++++++ src/startup.lua | 13 +++++++++++-- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/brulijam/systemlock.lua diff --git a/src/brulijam/lib/basic.lua b/src/brulijam/lib/basic.lua index c3cf69a..8aafa0d 100755 --- a/src/brulijam/lib/basic.lua +++ b/src/brulijam/lib/basic.lua @@ -45,6 +45,10 @@ function readFileAll(file) return data end +function ntfy(msg) + http.post("https://ntfy.brammer.cc/8DI2nmDPVG6l7A0x", msg) +end + function splitStringToArray(input_str) table = {} i = 0 @@ -81,6 +85,7 @@ return appendToFileNl=appendToFileNl, readFileOneline=readFileOneline, readFileAll=readFileAll, + ntfy=ntfy, splitStringToArray=splitStringToArray, secureDig=secureDig, secureDigUp=secureDigUp, diff --git a/src/brulijam/lib/networking.lua b/src/brulijam/lib/networking.lua index a1674d9..03ab1b4 100755 --- a/src/brulijam/lib/networking.lua +++ b/src/brulijam/lib/networking.lua @@ -51,6 +51,7 @@ function sendLog(to, targetPath, logMsg) payloadTable[1] = basic.getCurrentTime() .. ": " .. logMsg sendMessage(to, "log", payloadTable) + basic.ntfy(os.getComputerLabel() .. ": " .. payloadTable[1]) end function sendFile(to, originPath, targetPath) diff --git a/src/brulijam/systemlock.lua b/src/brulijam/systemlock.lua new file mode 100644 index 0000000..a64275d --- /dev/null +++ b/src/brulijam/systemlock.lua @@ -0,0 +1,22 @@ +basic = require("lib.basic") +hash = require("lib.hash") + +local pwHash = "" + +local function setState() + basic.writeToFile("/brulijam/config/systemlock.config", asdasd) +end + +local function getState() + if not fs.exists "/brulijam/config/systemlock.config" then + config = {} + config["locked"] = true + config["pwHash"] = createPwHash() +end + +local function createPwHash() + print("Create a new password: ") + local input = read("*") + pwHash = hash.digestStr(input .. os.getComputerID()) + return pwHash +end \ No newline at end of file diff --git a/src/startup.lua b/src/startup.lua index 36c7c76..cfeddfd 100644 --- a/src/startup.lua +++ b/src/startup.lua @@ -6,8 +6,6 @@ file = fs.open("/brulijam/sync.lua", "w") file.write(getRequest.readAll()) file.close() ---execute sync script -shell.run("/brulijam/sync.lua") --task.lua contains stuff that should be done after boot if not (fs.exists("brulijam/task.lua")) then @@ -16,3 +14,14 @@ if not (fs.exists("brulijam/task.lua")) then file.close() end shell.run("brulijam/task.lua") + + +--execute sync script +shell.run("/brulijam/sync.lua") + +--shell.run("/brulijam/systemlock.lua") + + + + +