55 lines
1.5 KiB
Lua
55 lines
1.5 KiB
Lua
local createInstallerDisk = require('/apis/libinstallerdisk');
|
|
local createVersion = require('/apis/libversion');
|
|
|
|
local function printUsage()
|
|
print('trapos-create-installer-disk usage:');
|
|
print();
|
|
print('\t\ttrapos-create-installer-disk');
|
|
print('\t\ttrapos-create-installer-disk version');
|
|
print('\t\ttrapos-create-installer-disk help');
|
|
end
|
|
|
|
local function printColored(msg, color)
|
|
if term.isColor and term.isColor() then
|
|
local previous = term.getTextColor();
|
|
term.setTextColor(color);
|
|
print(msg);
|
|
term.setTextColor(previous);
|
|
else
|
|
print(msg);
|
|
end
|
|
end
|
|
|
|
local args = table.pack(...);
|
|
local command = args[1];
|
|
|
|
if command == 'version' or command == '-version' or command == '--version' then
|
|
print('v' .. createVersion().forSelf());
|
|
return;
|
|
end
|
|
|
|
if command == 'help' or command == '-help' or command == '--help' then
|
|
printUsage();
|
|
return;
|
|
end
|
|
|
|
if command ~= nil and command ~= '' then
|
|
printUsage();
|
|
return;
|
|
end
|
|
|
|
local ok, result = createInstallerDisk().create();
|
|
if not ok then
|
|
printColored(result, colors.red);
|
|
return;
|
|
end
|
|
|
|
printColored('=> TrapOS installer disk created on ' .. result.name .. '.', colors.lime);
|
|
print('Label: ' .. result.label);
|
|
if result.settingsCopied then
|
|
print('Cloned /.settings to ' .. fs.combine(result.mountPath, '.settings'));
|
|
elseif result.settingsWarning then
|
|
printColored('Warning: /.settings not found; installer disk has no cloned settings.', colors.orange);
|
|
end
|
|
print('Insert this disk into a blank computer and reboot it.');
|