-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
159 lines (140 loc) · 5.54 KB
/
install
File metadata and controls
159 lines (140 loc) · 5.54 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
-- Auto-generated Nova installer
local root = "https://fozogt-jpg.github.io/NovaShell/os"
local files = {
-- Lua files (entry points and CraftOS-required files)
{ url = root.."/nova/sys/bios.lua", path = "/nova/.sys/bios.lua" },
{ url = root.."/nova/sys/shell.lua", path = "/nova/.sys/shell.lua" },
{ url = root.."/nova/sys/bin/cp.lua", path = "/nova/.sys/bin/cp.lua" },
{ url = root.."/nova/sys/bin/dir.lua", path = "/nova/.sys/bin/dir.lua" },
{ url = root.."/nova/sys/bin/ls.lua", path = "/nova/.sys/bin/ls.lua" },
{ url = root.."/nova/sys/bin/mv.lua", path = "/nova/.sys/bin/mv.lua" },
{ url = root.."/nova/sys/bin/nam.lua", path = "/nova/.sys/bin/nam.lua" },
{ url = root.."/nova/sys/bin/rm.lua", path = "/nova/.sys/bin/rm.lua" },
{ url = root.."/nova/sys/boot/kernel.lua", path = "/nova/.sys/boot/kernel.lua" },
{ url = root.."/nova/sys/boot/nova.lua", path = "/nova/.sys/boot/nova.lua" },
{ url = root.."/nova/sys/boot/desktop/gwm.lua", path = "/nova/.sys/boot/desktop/gwm.lua" },
{ url = root.."/nova/sys/boot/desktop/workspace.lua", path = "/nova/.sys/boot/desktop/workspace.lua" },
{ url = root.."/nova/sys/boot/menu/bootmenu.lua",path = "/nova/.sys/boot/menu/bootmenu.lua" },
{ url = root.."/nova/sys/boot/menu/reboot1.lua", path = "/nova/.sys/boot/menu/reboot1.lua" },
{ url = root.."/nova/sys/boot/menu/shutdown1.lua",path = "/nova/.sys/boot/menu/shutdown1.lua" },
{ url = root.."/nova/sys/desktop/screensaver.lua",path = "/nova/.sys/desktop/screensaver.lua" },
{ url = root.."/nova/sys/utils/autofill.lua", path = "/nova/.sys/utils/autofill.lua" },
{ url = root.."/nova/sys/utils/loading.lua", path = "/nova/.sys/utils/loading.lua" },
{ url = root.."/nova/sys/v", path = "/nova/.sys/v" },
{ url = root.."/startup.lua", path = "startup.lua" },
-- Nova Script runtime (v5.1+)
{ url = root.."/nova/sys/nv_runtime.lua", path = "/nova/.sys/nv_runtime.lua" },
-- Nova Script (.nv) OS files (v5.1+)
{ url = root.."/nova/sys/boot/kernel.nv", path = "/nova/.sys/boot/kernel.nv" },
{ url = root.."/nova/sys/bios.nv", path = "/nova/.sys/bios.nv" },
{ url = root.."/nova/sys/boot/nova.nv", path = "/nova/.sys/boot/nova.nv" },
{ url = root.."/nova/sys/boot/menu/bootmenu.nv", path = "/nova/.sys/boot/menu/bootmenu.nv" },
{ url = root.."/nova/sys/utils/loading.nv", path = "/nova/.sys/utils/loading.nv" },
-- CraftOS Compat Layer (v5.1+)
{ url = root.."/nova/sys/bin/COCL.lua", path = "/nova/.sys/bin/COCL.lua" },
}
-- Default update exclude list
local update_exclude = {
"",
}
local args = {...}
local mode = args[1] or ""
-- Clean terminal and header
if term and term.clear then term.clear() end
if term and term.setCursorPos then term.setCursorPos(1,1) end
if term and term.setTextColor then term.setTextColor(colors.purple) end
print("Nova Installer")
if term and term.setTextColor then term.setTextColor(colors.white) end
-- Disk handling: target will be /disk or /disk2
local disk_target = nil
if mode == "-d" then
local function findAvailableDisks()
local avail = {}
if fs.exists("/disk") then table.insert(avail, "/disk") end
if fs.exists("/disk2") then table.insert(avail, "/disk2") end
return avail
end
local avail = findAvailableDisks()
while #avail == 0 do
print("No disks mounted at /disk or /disk2. Insert a disk and press Enter to retry, or type 'c' to cancel.")
local ans = read()
if ans == "c" then
print("Disk install cancelled")
return
end
avail = findAvailableDisks()
end
if #avail == 1 then
disk_target = avail[1]
else
print("Select target disk:")
for i, v in ipairs(avail) do
print(i..") "..v)
end
local sel = tonumber(read()) or 1
disk_target = avail[sel] or avail[1]
end
print("Installing to "..disk_target)
if not fs.exists(disk_target.."/nova") then fs.makeDir(disk_target.."/nova") end
end
-- Ensure HTTP API is available
if not http then
print("Error: HTTP API disabled")
return
end
local function ensureDir(p)
local dir = p:match("(.+)/[^/]+$")
if dir and not fs.exists(dir) then fs.makeDir(dir) end
end
local function isExcluded(path)
for _, v in ipairs(update_exclude) do
if v == path then return true end
end
return false
end
local function download(f)
if mode == "-u" and isExcluded(f.path) then
print(" Skipping excluded file "..f.path)
return true
end
local writePath = f.path
if disk_target then
if f.path == "/startup.lua" then
writePath = disk_target.."/startup.lua"
else
writePath = disk_target..f.path
end
end
if writePath == "/startup.lua" and fs.exists("/startup.lua") then
print(" Existing startup.lua found. Renaming to startup_old.lua")
if fs.exists("/startup_old.lua") then fs.delete("/startup_old.lua") end
fs.move("/startup.lua", "/startup_old.lua")
elseif fs.exists(writePath) then
fs.delete(writePath)
end
ensureDir(writePath)
local res = http.get(f.url)
if not res then
print(" FAILED to fetch "..f.url)
return false
end
local h = fs.open(writePath, "w")
h.write(res.readAll())
h.close()
res.close()
return true
end
for _, f in ipairs(files) do
if not download(f) then
print("Installation aborted.")
return
end
end
if not fs.exists("/nova/packages") then fs.makeDir("/nova/packages") end
print()
print("Installation complete")
if mode ~= "-u" then
sleep(1.5)
print("Rebooting...")
pcall(shell.run, "reboot")
end