-
Notifications
You must be signed in to change notification settings - Fork 8
/
installer.lua
92 lines (78 loc) · 2.33 KB
/
installer.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
local computer = require("computer")
local fs = require("filesystem")
local kb = require("keyboard")
local event = require("event")
local shell = require("shell")
local term = require("term")
local running = true
local function greeting()
term.clear()
term.setCursor(1,1)
print("Welcome to the SecureOS installer!")
print("This installer will help guide you through setting up and installing SecureOS.")
print("Press any key to continue.")
local event = event.pull("key_down")
if event and not kb.isControlDown() then
term.clear()
term.setCursor(1,1)
end
end
local function downLoad()
if not fs.exists("/tmp/.root") then
r = io.open("/tmp/.root", "w")
r:write("true")
r:close()
end
if not fs.exists("/tmp/.install") then
input = io.open("/tmp/.install", "w")
input:write(os.date())
input:close()
end
if not fs.exists("/etc/update.cfg") then
c = io.open("/etc/update.cfg", "w")
c:write("release")
c:close()
end
term.write("Please wait while the files are downloaded and installed.")
os.sleep(1)
term.setCursor(1,2)
shell.execute("wget -q https://raw.githubusercontent.com/Shuudoushi/SecureOS/release/sbin/update.lua /sbin/update.lua \n")
shell.execute("/sbin/update.lua")
end
local function userInfo()
term.clear()
term.setCursor(1,1)
term.write("Please enter a username and password.")
term.setCursor(1,2)
term.write("Username: ")
username = string.lower(io.read())
term.setCursor(1,3)
term.write("Password: ")
password = string.gsub(term.read(nil, nil, nil, ""), "\n", "")
require("auth").addUser(username, password, true)
if not fs.exists("/home/" .. username .. "/") then
fs.makeDirectory("/home/" .. username .. "/")
fs.makeDirectory("/home/" .. username .. "/bin/")
fs.makeDirectory("/home/" .. username .. "/lib/")
fs.makeDirectory("/home/" .. username .. "/var/")
end
term.clear()
term.setCursor(1,1)
term.write("Would you like to restart now? [Y/n]")
term.setCursor(1,2)
input = string.lower(io.read())
if input == "y" or input == "yes" then
computer.shutdown(true)
elseif input == "n" or input == "no" then
io.write("Returning to shell.")
os.sleep(1.5)
term.clear()
term.setCursor(1,1)
running = false
end
end
while running do
greeting()
downLoad()
userInfo()
end