Uh oh!
There was an error while loading. Please reload this page.
forked from NodeOS/nodeos-boot-multiUser
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
Latest commit
executable file
·67 lines (52 loc) · 1.59 KB
/
Copy pathserver.js
File metadata and controls
executable file
·67 lines (52 loc) · 1.59 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
#!/usr/bin/env node
constreadFile=require('fs').readFile
constbasicEnvironment=require('nodeos-boot-singleUser')
constlinuxCmdline=require('linux-cmdline')
constmountUsersFS=require('nodeos-boot-singleUserMount')
constrimraf=require('rimraf').sync
conststartRepl=require('nodeos-mount-utils').startRepl
constprepareSessions=require('.')
constMOUNTPOINT='/tmp'
/**
* This error handler traces the error and starts a Node.js REPL
*
* @param {Error} error The error that gets traced
*/
functiononerror(error)
{
console.trace(error)
startRepl('NodeOS-boot-multiuser')
}
basicEnvironment(function(error)
{
if(error)returnonerror(error)
// Get Linux kernel command line arguments
readFile('/proc/cmdline','utf8',function(error,data)
{
if(error)returnonerror(error)
varcmdline=linuxCmdline(data)
// Mount users filesystem
mountUsersFS(MOUNTPOINT,cmdline,function(error)
{
if(error)returnonerror(error)
prepareSessions(MOUNTPOINT,cmdline.single,function(error)
{
if(error)returnonerror(error)
// Remove from initramfs the files only needed on boot to free memory
try
{
rimraf('/bin/nodeos-boot-multiuser')
rimraf('/init')
rimraf('/lib/node_modules/nodeos-boot-multiuser')
rimraf('/sbin')
}
catch(error)
{
// If `rootfs` is read-only (like in `vagga`), ignore the error
if(error.code!=='EROFS')returncallback(error)
}
// KTHXBYE >^.^<
})
})
})
})