-
Notifications
You must be signed in to change notification settings - Fork 0
/
testhd
21899 lines (21899 loc) · 687 KB
/
testhd
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
sector0 = {},
sector1 = {
folders = {
"boot",
"vit",
"etc",
"etc/repositories",
"etc/services.d",
"etc/.installed",
"etc/.installed/clinux",
"etc/.installed/main",
"test",
"bin",
"home",
"home/test",
"home/root",
"sys",
"lib",
"rom",
"rom/help",
"rom/help/licenses",
"rom/autorun",
"rom/programs",
"rom/programs/fun",
"rom/programs/fun/advanced",
"rom/programs/fun/advanced/levels",
"rom/programs/pocket",
"rom/programs/http",
"rom/programs/rednet",
"rom/programs/advanced",
"rom/programs/command",
"rom/programs/turtle",
"rom/apis",
"rom/apis/pocket",
"rom/apis/command",
"rom/apis/turtle",
},
files = {
"boot/load",
"boot/CraftOS",
"boot/clinux.i",
"vit/alive",
"etc/repositories/clinux",
"etc/repositories/main",
"etc/repolist",
"etc/services.conf",
"etc/services.d/rednet",
"etc/.installed/clinux/luaide",
"etc/.installed/clinux/updater",
"etc/.installed/clinux/edit",
"etc/.installed/main/packman",
"KrapFile",
"bin/cd",
"bin/luaide",
"bin/packman",
"bin/UpdateCLinux",
"bin/ls",
"bin/rm",
"bin/edit",
"bin/ps",
"bin/mkdir",
"bin/clear",
"grubcfg",
"home/test/.aliases",
"home/test/.bashcol",
"sys/thread.l",
"sys/.rootpw",
"sys/usrData",
"sys/perm.l",
"sys/sThread.l",
"sys/rednet",
"sys/shell.lua",
"sys/fs.l",
"sys/cmdbak",
"lib/sha.l",
"lib/xstr.l",
"lib/services.l",
"startup",
"rom/help/cd",
"rom/help/repeat",
"rom/help/modems",
"rom/help/help",
"rom/help/gpsapi",
"rom/help/move",
"rom/help/time",
"rom/help/os",
"rom/help/multishell",
"rom/help/keys",
"rom/help/chat",
"rom/help/math",
"rom/help/alias",
"rom/help/type",
"rom/help/redstoneapi",
"rom/help/go",
"rom/help/drives",
"rom/help/http",
"rom/help/commands",
"rom/help/vector",
"rom/help/dj",
"rom/help/licenses/luaj",
"rom/help/whatsnew",
"rom/help/rs",
"rom/help/bundled",
"rom/help/lua",
"rom/help/adventure",
"rom/help/term",
"rom/help/reboot",
"rom/help/io",
"rom/help/programs",
"rom/help/textutils",
"rom/help/bg",
"rom/help/list",
"rom/help/tunnel",
"rom/help/sleep",
"rom/help/set",
"rom/help/printers",
"rom/help/craft",
"rom/help/falling",
"rom/help/excavate",
"rom/help/colors",
"rom/help/fs",
"rom/help/wget",
"rom/help/rednet",
"rom/help/delete",
"rom/help/unequip",
"rom/help/peripheral",
"rom/help/turn",
"rom/help/settings",
"rom/help/redstone",
"rom/help/refuel",
"rom/help/redirection",
"rom/help/parallel",
"rom/help/events",
"rom/help/changelog",
"rom/help/dance",
"rom/help/commandsapi",
"rom/help/edit",
"rom/help/exit",
"rom/help/copy",
"rom/help/label",
"rom/help/programming",
"rom/help/workbench",
"rom/help/drive",
"rom/help/worm",
"rom/help/credits",
"rom/help/shutdown",
"rom/help/disk",
"rom/help/mkdir",
"rom/help/helpapi",
"rom/help/pastebin",
"rom/help/gps",
"rom/help/eject",
"rom/help/hello",
"rom/help/peripherals",
"rom/help/coroutine",
"rom/help/bit",
"rom/help/monitor",
"rom/help/earth",
"rom/help/shellapi",
"rom/help/id",
"rom/help/apis",
"rom/help/string",
"rom/help/equip",
"rom/help/paint",
"rom/help/window",
"rom/help/rename",
"rom/help/paintutils",
"rom/help/clear",
"rom/help/shell",
"rom/help/turtle",
"rom/help/colours",
"rom/help/exec",
"rom/help/table",
"rom/help/intro",
"rom/help/monitors",
"rom/help/fg",
"rom/autorun/.ignoreme",
"rom/programs/cd",
"rom/programs/help",
"rom/programs/fun/dj",
"rom/programs/fun/adventure",
"rom/programs/fun/advanced/levels/6",
"rom/programs/fun/advanced/levels/12",
"rom/programs/fun/advanced/levels/1",
"rom/programs/fun/advanced/levels/7",
"rom/programs/fun/advanced/levels/3",
"rom/programs/fun/advanced/levels/2",
"rom/programs/fun/advanced/levels/5",
"rom/programs/fun/advanced/levels/9",
"rom/programs/fun/advanced/levels/4",
"rom/programs/fun/advanced/levels/10",
"rom/programs/fun/advanced/levels/0",
"rom/programs/fun/advanced/levels/8",
"rom/programs/fun/advanced/levels/11",
"rom/programs/fun/advanced/redirection",
"rom/programs/fun/advanced/paint",
"rom/programs/fun/worm",
"rom/programs/fun/hello",
"rom/programs/pocket/falling",
"rom/programs/move",
"rom/programs/time",
"rom/programs/alias",
"rom/programs/type",
"rom/programs/http/wget",
"rom/programs/http/pastebin",
"rom/programs/lua",
"rom/programs/reboot",
"rom/programs/programs",
"rom/programs/list",
"rom/programs/set",
"rom/programs/rednet/repeat",
"rom/programs/rednet/chat",
"rom/programs/delete",
"rom/programs/redstone",
"rom/programs/advanced/multishell",
"rom/programs/advanced/bg",
"rom/programs/advanced/fg",
"rom/programs/edit",
"rom/programs/exit",
"rom/programs/copy",
"rom/programs/label",
"rom/programs/drive",
"rom/programs/shutdown",
"rom/programs/mkdir",
"rom/programs/gps",
"rom/programs/eject",
"rom/programs/peripherals",
"rom/programs/command/commands",
"rom/programs/command/exec",
"rom/programs/monitor",
"rom/programs/id",
"rom/programs/apis",
"rom/programs/rename",
"rom/programs/clear",
"rom/programs/shell",
"rom/programs/turtle/go",
"rom/programs/turtle/tunnel",
"rom/programs/turtle/craft",
"rom/programs/turtle/excavate",
"rom/programs/turtle/unequip",
"rom/programs/turtle/turn",
"rom/programs/turtle/refuel",
"rom/programs/turtle/dance",
"rom/programs/turtle/equip",
"rom/startup",
"rom/apis/help",
"rom/apis/keys",
"rom/apis/vector",
"rom/apis/term",
"rom/apis/io",
"rom/apis/textutils",
"rom/apis/colors",
"rom/apis/rednet",
"rom/apis/peripheral",
"rom/apis/settings",
"rom/apis/parallel",
"rom/apis/disk",
"rom/apis/gps",
"rom/apis/command/commands",
"rom/apis/window",
"rom/apis/paintutils",
"rom/apis/turtle/turtle",
"rom/apis/colours",
"loadall",
},
fileData = {
"--[[\
\009cLinux : Lore of the Day!\
\009Made by Piorjade, daelvn\
\
\009NAME: /boot/load\
\009CATEGORY: boot\
\009SET: Boot II\
\009VERSION: 01:alpha0\
\009DESCRIPTION:\
\009\009This script is ran after /boot/clinux.i\
\009\009and loads important libraries up\
\009\009and starts the shell at the end.\
]]--\
\
if _G['flag'] and _G['flag']['STATE_INIT'] then\
\009if not fs.exists(\"/sys/fs.l\") then\
\009\009cLinuxPrintError(\"/sys/fs.l not found...\")\
\009\009sleep(2)\
\009\009flag.STATE_DEAD = true\
\009elseif not fs.exists(\"/sys/perm.l\") then\
\009\009cLinuxPrintError(\"/sys/perm.l not found...\")\
\009\009sleep(2)\
\009\009flag.STATE_DEAD = true\
\009elseif not fs.exists(\"/sys/thread.l\") then\
\009\009cLinuxPrintError(\"/sys/thread.l not found...\")\
\009\009sleep(2)\
\009\009flag.STATE_DEAD = true\
\009elseif not fs.exists(\"/sys/sThread.l\") then\
\009\009cLinuxPrintError(\"/sys/sThread.l not found...\")\
\009\009sleep(2)\
\009\009flag.STATE_DEAD = true\
\009end\
\
\009print(\"Loading perm API\")\
\009local ok, err = loadAPI(\"/sys/perm.l\")\
\009if ok == false or _G.lib.perm == nil then\
\009\009cLinuxPrintError(\"[perm.l] \"..tostring(err))\
\009\009flag.STATE_DEAD = true\
\009\009sleep(1)\
\009\009return\
\009end\
\009sleep(0.5)\
\009print(\"Loading FS API\")\
\009local ok, err = loadAPI(\"/sys/fs.l\")\
\009if ok == false or _G.fs == nil then\
\009\009cLinuxPrintError(\"[fs.l] \"..tostring(err))\
\009\009flag.STATE_DEAD = true\
\009\009sleep(1)\
\009\009return\
\009end\
\009sleep(0.5)\
\009print(\"Loading thread API\")\
\009local ok, err = loadAPI(\"/sys/thread.l\")\
\009if ok == false or _G.thread == nil then\
\009\009cLinuxPrintError(\"[thread.l] \"..tostring(err))\
\009\009flag.STATE_DEAD = true\
\009\009sleep(1)\
\009\009return\
\009end\
\009print(\"Loading sThread API\")\
\009local ok, err = loadAPI(\"/sys/sThread.l\")\
\009if ok == false or _G.sThread == nil then\
\009\009cLinuxPrintError(\"[thread.l] \"..tostring(err))\
\009\009flag.STATE_DEAD = true\
\009\009sleep(1)\
\009\009return\
\009end\
\009sleep(0.5)\
\009for _, a in ipairs(fs.list(\"/lib/\")) do\
\009\009print(\"Loading \"..a)\
\009\009local ok, err = loadAPI(\"/lib/\"..a)\
\009\009if ok == false then\
\009\009\009local c = term.getTextColor()\
\009\009\009term.setTextColor(colors.red)\
\009\009\009print(\"[\"..a..\"] \"..tostring(err))\
\009\009\009term.setTextColor(c)\
\009\009\009sleep(0.5)\
\009\009else\
\009\009\009local c = term.getTextColor()\
\009\009\009term.setTextColor(colors.green)\
\009\009\009term.write(\"[OK]\")\
\009\009\009term.setTextColor(c)\
\009\009\009print(\" \"..a..\" loaded!\")\
\009\009\009sleep(0.5)\
\009\009end\
\009end\
\009print(\"Finished!\")\
\009sleep(0.5)\
\009if _G.lib.os then\
\009\009_G.lib.os['shutdown'] = os.shutdown\
\009\009_G.lib.os['reboot'] = os.reboot\
\009end\
\
\009--initiate shell-level-tasklist\
\009local tasks = {}\
\009tasks['list'] = {}\
\009tasks['last_uid'] = 0\
\009tasks['somethingInFG'] = false\
\
\009local xBox = {}\
\
\009for _, a in pairs(_G) do\
\009\009xBox[_] = a\
\009end\
\009--xBox._G = xBox\
\009--setmetatable(xBox, {__index = xBox.lib})\
\009--xBox._G = xBox\
\009local x, err = thread.new(\"/sys/shell.lua\", xBox, \"Shell\", tasks)\
\009if x == false then\
\009\009cLinuxPrintError(\"Shell\", err)\
\009\009sleep(2)\
\009end\
\009local running = true\
\009local evt = {}\
\009while running do\
\009\009local ok = thread.resumeAll(tasks, evt)\
\009\009evt = {os.pullEventRaw()}\
\009\009if ok == false then\
\009\009\009running = false\
\009\009end\
\009end\
\009flag.STATE_DEAD = true\
else\
\009term.clear(1,1)\
\009term.setCursorPos(1,1)\
\009printError(\"cLinux not initialized, boot cLinux.i\")\
end",
"--[[\
THIS PROGRAM FINISHES THE GRUB LOOP OFF\
TO BOOT CraftOS\
\
\
...nothing special...\
]]",
"--[[\
\009cLinux : Lore of the Day!\
\009Made by Piorjade, daelvn\
\
\009NAME: /boot/clinux.i\
\009CATEGORY: boot\
\009SET: Boot I\
\009VERSION: 01:alpha0\
\009DESCRIPTION:\
\009\009This script is ran after /startup and\
\009\009it sets flags manually, also loading\
\009\009some utils for posterior scripts.\
]]--\
\
\
\
print(\"Welcome to cLinux !\")\
sleep(2)\
\
\
\
--Modify the os.loadAPI and others.... NOTE: I think loadAPI is useless here, as I already did that in the right way in thread.l\
local bos = {}\
\
for k, v in pairs(_G.os) do\
\009bos[k] = v\
end\
\
local tAPIsLoading = {}\
function bos.loadAPI( _sPath )\
\009\009print(\"Loading \".._sPath)\
local sName = fs.getName( _sPath )\
if tAPIsLoading[sName] == true then\
printError( \"API \"..sName..\" is already being loaded\" )\
return false\
end\
tAPIsLoading[sName] = true\
\
local tEnv = {}\
setmetatable( tEnv, { __index = _G } )\
local fnAPI, err = loadfile( _sPath, tEnv )\
if fnAPI then\
local ok, err = pcall( fnAPI )\
if not ok then\
printError( err )\
tAPIsLoading[sName] = nil\
return false\
end\
else\
printError( err )\
tAPIsLoading[sName] = nil\
return false\
end\
\
local tAPI = {}\
for k,v in pairs( tEnv ) do\
if k ~= \"_ENV\" then\
tAPI[k] = v\
end\
end\
tAPIsLoading[sName] = nil\
\009\009--Edited part\
return true, _putLib(sName, tAPI), _put(sName, tAPI)\
end\
\
local oos = {}\
for k, v in pairs(_G.os) do\
oos[k] = v\
end\
\
--There was an error with returning the right event, this should fix it\
function bos.pullEvent(_filtr)\
if _filtr then\
repeat\
local evt = {oos.pullEvent()}\
until evt[1] == _filtr\
return unpack(evt)\
else\
return oos.pullEvent()\
end\
end\
\
function bos.pullEventRaw(_filtr)\
if _filtr then\
repeat\
local _, a, b, c = oos.pullEventRaw()\
until _ == _filtr\
return _, a, b, c\
else\
return oos.pullEventRaw()\
end\
end\
\
\
--Load the API, in the cLinux way (use _putLib in the API, for example)\
function loadAPI(path)\
\009local ok, err = loadfile(path)\
\009if not ok then\
\009\009return false, err\
\009else\
\009\009local ok, err = ok()\
\009\009if ok == false then\
\009\009\009return false, err\
\009\009else\
\009\009\009return true\
\009\009end\
\009end\
end\
\
-- Put in _G\
function _put(a,b) _G[a]=b end\
\
\
\
local lib = {}\
function _putLib(a,b) _G['lib'][a]=b end\
\
_put('_put', _put)\
_put('lib', lib)\
_put('_putLib', _putLib)\
_putLib('os', bos)\
function _check(a)\
\009if _G[a] == nil then\
\009\009return false\
\009else\
\009\009return true\
\009end\
end\
_put('_check', _check)\
\
-- Put in _G.flag\
_put('flag', {})\
\
\
local ok, err = loadAPI(\"/sys/thread.l\")\
if not ok then\
\009printError(err)\
\009return\
end\
\
\
function _flag(a,b) _G.flag[a] = b end\
_put('_flag', _flag)\
_put('loadAPI', loadAPI)\
-- Get _G.flag[flag]\
function _getflag(flag) return flag[flag] end\
_put('_getflag', _getflag)\
-- Loadfile, securely\
_put('_REQUIRECACHE', {})\
local function require(file)\
\009local function go()\
\009\009loadfile(file)\
\009end\
\009local ok, ret = pcall(go)\
\009if ok then\
\009\009_REQUIRECACHE[#_REQUIRECACHE+1] = file\
\009\009return true\
\009else\
\009\009return false\
\009end\
end\
local function cLinuxPrintError(status, message)\
\009local c = term.getTextColor()\
\009term.setTextColor(colors.red)\
\009print(\"[\"..tostring(status)..\"] \"..tostring(message))\
\009term.setTextColor(c)\
end\
\
_put('cLinuxPrintError', cLinuxPrintError)\
_put('require', require)\
-- Set system flags\
--- Debug level, set to 0 by default, use /startup\
_flag('SYSDEBUG', 0)\
-- Starting the OS, can't be changed\
_flag('STATE_INIT', true)\
-- Ignore the current services.conf, for example to start the commandline\
_flag('text', false)\
\
\
\
_arg = {...}\
if #_arg > 0 then\
\009for _,arg in pairs(_arg) do\
\009\009if arg == \"sysdebug\" then\
\009\009 flag.SYSDEBUG = flag.SYSDEBUG + 1\
\009\009elseif arg == \"rescue\" then\
\009\009\009flag.RESCUE = true\
\009\009elseif arg == \"text\" then\
\009\009\009flag.text = true\
\009\009end\
\009end\
end\
-- Top Level Corroutine Override\
local syserror = printError\
_put('syserror', syserror)\
_G.printError = function()\
\009_G.printError = syserror\
\009_G['rednet'] = nil\
\009local evt = {}\
\009\009--initiate ground-environment\
\009\009local newenv = {}\
\009\009for k, v in pairs(_G) do\
\009\009\009newenv[k] = v\
\009\009end\
\009\009setmetatable(newenv, {})\
\009\009--initiate ground-tasklist\
\009\009local tasks = {}\
\009\009tasks['list'] = {}\
\009\009tasks['last_uid'] = 0\
\009\009tasks['somethingInFG'] = false\
\
\
\
\009\009print(\"Loading core\")\
\009\009sleep(0.5)\
\009\009local ok, err = thread.new(\"/boot/load\", newenv, \"Core\", tasks)\
\009\009if not ok then\
\009\009\009cLinuxPrintError(\"Core\", err)\
\009\009end\
\009\009print(\"Loading alive\")\
\009\009sleep(0.5)\
\009\009local ok, err = thread.new(\"/vit/alive\", newenv, \"Alive\", tasks, tasks)\
\009\009if not ok then\
\009\009\009cLinuxPrintError(\"Alive\", err)\
\009\009end\
\
\009\009sleep(0.5)\
\
\
\009\009local running = true\
\009\009while running do\
\009\009\009local ok = thread.resumeAll(tasks, evt)\
\009\009\009evt = {os.pullEventRaw()}\
\009\009\009if ok == false then\
\009\009\009\009running = false\
\009\009\009end\
\009\009end\
\009\009print(err)\
\009\009sleep(2)\
\009--end\
\009print(\"Looks like /vit/alive failed..\")\
\009sleep(1)\
\009os.reboot()\
\009-- NOTE: /boot/load is now in charge of all files to run. If that you know when is\
\009-- that branch going to die, please do _flag('STATUS_DEAD') to force a restart.\
end\
os.queueEvent(\"modem_message\", 0)",
"-- Keep the TLCO alive\
-- Create a coroutine with alive, and execute the other.\
\
--catch the ground-tasklist\
\
local tasks = {}\
for k, v in pairs(startArgs) do\
\009tasks[k] = v\
end\
local function drawBlueScreen()\
\009if flag.STATE_CRASHED then\
\009\009term.setCursorPos(1,1)\
\009\009term.setBackgroundColor(colors.blue)\
\009\009term.setTextColor(colors.white)\
\009\009term.clear()\
\009\009local msg1 = \"Whoops, cLinux crashed!\"\
\009\009term.setCursorPos(26-#msg1/2, 2)\
\009\009term.write(msg1)\
\009\009local msg2 = flag.STATE_CRASHED\
\009\009local part1 = nil\
\009\009local part2 = nil\
\009\009if #msg2 > 51 then\
\009\009\009part1 = string.sub(msg2, 1, 51)\
\009\009\009part2 = string.sub(msg2, 52, #msg2)\
\009\009end\
\
\009\009if not part1 then\
\009\009\009term.setCursorPos(26-#msg2/2, 4)\
\009\009\009term.setTextColor(colors.red)\
\009\009\009term.write(msg2)\
\009\009else\
\009\009\009term.setCursorPos(26-#part1/2, 4)\
\009\009\009term.setTextColor(colors.red)\
\009\009\009term.write(part1)\
\009\009\009term.setCursorPos(26-#part2/2, 5)\
\009\009\009term.setTextColor(colors.red)\
\009\009\009term.write(part2)\
\009\009end\
\
\009\009local msg3 = \"Please report bugs in GitHub/my post.\"\
\009\009term.setCursorPos(26-#msg3/2, 15)\
\009\009term.setTextColor(colors.white)\
\009\009term.write(msg3)\
\009\009local msg4 = \"The computer tries to reboot now...\"\
\009\009term.setCursorPos(26-#msg4/2, 17)\
\009\009term.write(msg4)\
\009end\
end\
\
\
while true do\
\009local ok, err = thread.getStatus(\"Core\", tasks)\
\009if ok == \"dead\" or flag.STATE_DEAD or ok == nil then\
\009\009term.setTextColor(colors.red)\
\009\009print(\"/vit/alive : STATE_DEAD detected. Restarting...\")\
\009\009term.setCursorBlink(false)\
\009\009sleep(2)\
\009\009print(\"Trying to reboot\")\
\009\009os.reboot()\
\009elseif flag.STATE_CRASHED then\
\009\009drawBlueScreen()\
\009\009sleep(4)\
\009\009os.reboot()\
\009elseif flag.STATE_SHUTDOWN then\
\009\009term.setTextColor(colors.red)\
\009\009print(\"/vit/alive : Shutting down...\")\
\009\009term.setCursorBlink(false)\
\009\009sleep(2)\
\009\009print(\"Trying shutdown.\")\
\009\009os.shutdown()\
\009else\
\009\009sleep(0.1)\
\009end\
end",
"name = edit\
\009type = raw\
\009\009url = https://raw.githubusercontent.com/Piorjade/cLinuxREPO/master/repo/edit\
\009\009filename = edit\
\009dependencies = none\
\009version = 1.0\
\009size = 17287\
end\
\
name = luaide\
\009type = raw\
\009\009url = http://pastebin.com/raw/vyAZc6tJ\
\009\009filename = luaide\
\009dependencies = none\
\009version = 1.0\
\009size = 61948\
end\
\
name = doorX\
\009type = raw\
\009\009url = http://pastebin.com/raw/Rnp97GRT\
\009\009filename = InstallDoorX\
\009dependencies = none\
\009cleanup = InstallDoorX uninstall\
\009version = 2.1\
\009size = 4210\
end\
\
name = updater\
\009type = raw\
\009\009url = http://pastebin.com/raw/NKEKjfpb\
\009\009filename = UpdateCLinux\
\009dependencies = none\
\009version = 1.0\
\009size = 4350\
end\
\
name = fseapi\
\009type = raw\
\009\009url = http://pastebin.com/raw/8JRrW0Va\
\009\009filename = fsEAPI\
\009dependencies = none\
\009version = 1.0\
\009size = 4350\
end\
\
name = fsexpose\
\009type = raw\
\009\009url = http://pastebin.com/raw/Wqp7RnVh\
\009\009filename = fsexpose\
\009dependencies = none\
\009version = 2.5\
\009size = 18195\
end",
"name = packman\
\009type = raw\
\009\009url = https://raw.githubusercontent.com/lyqyd/cc-packman/master/packman\
\009\009filename = packman\
\009category = utility\
\009dependencies = none\
\009version = 0.3\
\009size = 17110\
end\
\
name = easy-shell\
\009type = pastebin\
\009\009url = wzWFmaav\
\009\009filename = easy-shell\
\009setup = easy-shell install\
\009cleanup = easy-shell remove\
\009category = shell\
\009dependencies = none\
\009version = 0.2\
\009size = 1626\
end",
"clinux http://pastebin.com/raw/WfwDCSg5",
"{\
rednet = false,\
[ \"/sys/cmdbak\" ] = \"core\",\
}",
"os.loadAPI(\"/sys/rednet\")\
rednet.run()",
"1.0\
bin/luaide",
"1.0\
/bin/UpdateCLinux",
"1.0\
bin/edit",
"0.3\
/bin/packman\
/etc/api/package\
/etc/repolist\
etc/repositories/main\
etc/repositories/clinux\
/etc/repositories/clinux",
"version = \"1.1\"\
----------------------------------------------------------\
-- ~\". _^_ \"~ -- KrapFile Version 1.1 --\
-- ~\" (____) \"~ -- Created by TehRockettek --\
-- ~\"(______) \"~ -- --\
-- \" (________) \"~ -- KrapFile is a simple file --\
-- (____________) \" -- managing program and is --\
-- KRAP SOFTWARE -- a much more optimized --\
-- \"Its like someone -- version. This program will --\
-- litteraly made -- have much more features --\
-- this whilst on -- over time! --\
-- the toilet... \" -- --\
----------------------------------------------------------\
\
-- I sometimes livestream to youtube! --\
-- https://www.youtube.com/channel/UC_WsSgl1UL1USK4K0RplcnQ/live --\
\
-- Older versions of craftOS dont support the characters used in\
-- KrapFile, if this is so just run -o after the program\
\
term.clear()\
term.setCursorPos(1,1)\
\
if shell then\
pgrm = \"/\" .. shell.getRunningProgram()\
else\
\009pgrm = \"/KrapFile.lua\"\
printError(\"Hmm, cant find shell api.\")\
os.pullEvent(\"key\")\
end\
\
args = { ... }\
\
if http then\
\009local pbl = http.get(\"http://pastebin.com/raw/wscpHypE\")\
\009if not pbl then\
\009\009printError(\"Could not connect to pastebin\")\
\009else\
\009\009latestver = string.gsub(pbl.readLine(),\"version = \",\"\")\
\009\009latestver = string.gsub(latestver,\"\\\"\",\"\")\
\009end\
end\
\
term.clear()\
terminal = term.current()\
resolution = {term.getSize()}\
dialoguevisible = false\
print(\"Debug use only\")\
if _CC_VERSION then\
supportspecialchars = (tonumber(_CC_VERSION) >= 1.76)\
\009print(\"cc-ver: \" .. _CC_VERSION)\
end\
if _HOST then\
supportspecialchars = (tonumber(string.sub(string.gsub(_HOST,\"ComputerCraft \",\"\"),1,string.find(string.gsub(_HOST,\"ComputerCraft \",\"\"),\" \"))) >= 1.76)\
\009print(\"host: \" .. _HOST)\
end\
if not supportspecialchars or args[1] == \"-o\" then\
back = \"<\"\
up = \"^\"\
\009print(\"ssc: false\")\
else\
back = \"\017\"\
up = \"\030\"\
\009print(\"ssc: true\")\
end\
print(\"kf-ver: \" .. version)\
print(\"pb-ver: \" .. latestver)\
print(\"rpgrm: \" .. pgrm)\
sleep(1)\
local function minBytes(bytes)\
if bytes > 1000000 then\
return string.sub(bytes/1000000,1,string.len(math.ceil(bytes/1000000))+2) .. \"M\"\
elseif bytes > 1000 then\
return string.sub(bytes/1000,1,string.len(math.ceil(bytes/1000))+2) .. \"K\"\
else\
return bytes .. \"B\"\
end\
end\
\
if string.find(pgrm,\"pastebin\") then -- Detect if using pastebin run (show installer)\
\009term.clear()\
\009paintutils.drawFilledBox(1,1,resolution[1],resolution[2],colours.cyan)\
\009local pastebin = http.get(\"http://www.pastebin.com/raw/wscpHypE\")\
\009filesize = minBytes(string.len(pastebin.readAll()))\
\009term.setCursorPos(1,resolution[2])\
\009term.write(\"File size: \" ..\009filesize)\
\009term.setCursorPos((resolution[1]-9)/2,resolution[2]/2)\
\009term.write(\"Download!\")\
\009os.pullEvent(\"mouse_click\")\
\009term.clear()\
paintutils.drawFilledBox(1,1,resolution[1],3,colours.cyan)\
paintutils.drawFilledBox(1,4,resolution[1],resolution[2],colours.white)\
\009term.setCursorPos(2,2)\
term.setBackgroundColour(colours.cyan)\
term.setTextColour(colours.white)\
textutils.slowPrint(\"KrapFile installer\")\
term.setTextColour(colours.cyan)\
term.setBackgroundColour(colours.white)\
term.setCursorPos(1,5)\
term.write(\" Loading...\")\
sleep(2)\
local pbl = http.get(\"http://pastebin.com/raw/wscpHypE\")\
if not pbl then\
printError(\" Could not connect to pastebin!\")\
print(\" Error during update!\\n Computer will now reboot...\")\
textutils.slowPrint(string.rep(\"*\",resolution[1]-2))\
os.reboot()\
end\
latestver = string.gsub(pbl.readLine(),\"version = \",\"\")\
latestver = string.gsub(latestver,\"\\\"\",\"\")\
pbl.close()\
term.setCursorPos(1,5)\
print(\" Latest version: \" .. latestver .. \"\\n Download? (Y/N)\")\
term.setCursorPos(2,10)\
local _,id = os.pullEvent(\"key\")\
if id == 21 then\
print(\"\\n Downloading...\")\
term.setCursorPos(1,12)\
term.write(\" Connecting to pastebin...\")\
local pbl = http.get(\"http://pastebin.com/raw/wscpHypE\")\
if pbl then\
print(\" Success\")\
else\
printError(\" Failed\")\
print(\" Error during update!\\n Computer will reboot...\")\
textutils.slowPrint(string.rep(\"*\",resolution[1]-2))\
os.reboot()\
end\
print(\" Saving to file...\")\
if fs.exists(\"KrapFile\") then fs.delete(\"/KrapFile\") end\
krapfile = fs.open(\"/KrapFile\",\"w\")\
krapfile.write(pbl.readAll())\
print(\" Finished! Downloaded \" .. latestver .. \"\\n\\n Computer will reboot...\")\
term.setCursorPos(2,resolution[2])\
textutils.slowPrint(string.rep(\"*\",resolution[1]-2))\
os.reboot()\
else\
print(\"Returing to Shell...\")\
term.setCursorPos(2,resolution[2])\
textutils.slowPrint(string.rep(\"*\",resolution[1]-2))\
term.clear()\
\009\009textutils.setTextColour(colours.white)\
\009\009textutils.setBackgroundColour(colours.black)\
term.setCursorPos(1,1)\
shell.run(\"shell\")\
end\
end\
\
if resolution[1] < 26 or resolution[2] < 5 then\
\009printError(\"Sorry! Your computer must be atleast 26x5 to run this! (\" .. resolution[1] .. \"x\" .. resolution[2] .. \")\")\
\009return\
elseif not colors then\
\009printError(\"Sorry! Your computer doesn't seem to support colour. Monochrome support for KrapFile will be released shortly\")\
\009return\
end\
\
paintutils.drawFilledBox(1,1,resolution[1],resolution[2],colours.cyan)\
term.setCursorPos((resolution[1]-string.len(\"KrapFile\"))/2,(resolution[2]/5)*2)\
term.write(\"KrapFile\")\
term.setCursorPos(1,resolution[2])\
term.write(version)\
term.setCursorPos(resolution[1]-string.len(\"By TehRockettek\")+1,resolution[2])\
\
term.write(\"By TehRockettek\")\
local comments = {\"To continue, enter your SS Number:\",\"Piorjade liking pie is a conspiracy\",\"Enter your credit card details\",\"Free one-time payment of £499\",\"Now with more loading time!\",\"May include nuts\",\"Attempt to index nil\",\"Now in 1080p!\",\"I got molested by a toaster\",\"I am bender, insert girder\",\"May include bugs\",\"This litteraly took 12 hours to make\",\"Im not joking\",\"You pirated free software!\",\"Child Lock is enabled\",\"Have you tried a gun? I have\",\"Screw switchcraft,i want my plot back\",\"Sample comment\",\"Wow, thats so racist\",\"file.flushDownToilet()\",\"I cunt speel properply\",\"What's the wecommended amount of dedotated wam\",\"Subscribe to my YT: Teh Rockettek\",\"Try doing 5x26, It works!\",\"If stuff is showing as ?, run with -o\",\"I have a fetish for keemstar's beard\",\"I play pokemon go\",\"Redirection is a good game\",\"Dan200, more like err... dan smelly hundred\",\"*Air horns*\",\"~You hear the windows xp startup noise~\"}\
local fits = {}\
for i=1,#comments,1 do\
if #comments[i] <= resolution[1] then\
table.insert(fits,comments[i])\
end\
end\
if resolution[2] < 10 then\
\009fits = {\"This is small!\"}\
end\
local num = math.random(1,#fits)\
term.setCursorPos((resolution[1]-string.len(fits[num]))/2,(resolution[2]/5)*4)\
term.write(fits[num])\
\
sleep(2)\
term.clear()\
\
local windows = {}\
windows.HUD = window.create(terminal,1,1,resolution[1],3)\