Skip to content

Commit c5c4d9d

Browse files
committed
Delete boot files only after booting successfully
1 parent a7401e7 commit c5c4d9d

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

lib/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ function usersSessions(usersFolder, callback)
3030
{
3131
function done(error)
3232
{
33-
// Remove the modules from initramfs to free memory
34-
// rimraf('/lib/node_modules')
35-
rimraf('/lib/node_modules/jocker')
36-
3733
// Make '/usr' a opaque folder (OverlayFS feature)
34+
// TODO Is this needed to be done here? Can it be done in a cleaner place?
3835
rimraf('/usr')
3936

4037
callback(error)

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
"rimraf": "^2.5.4"
3232
},
3333
"devDependencies": {
34-
"jocker": "^0.0.0",
34+
"jocker": "^0.0.1",
3535
"prompt": "^1.0.0"
36-
},
37-
"peerDependencies": {
38-
"jocker": "^0.0.1"
3936
}
4037
}

server.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const readFile = require('fs').readFile
55
const basicEnvironment = require('nodeos-boot-singleUser')
66
const linuxCmdline = require('linux-cmdline')
77
const mountUsersFS = require('nodeos-boot-singleUserMount')
8+
const rimraf = require('rimraf').sync
89
const startRepl = require('nodeos-mount-utils').startRepl
910

1011
const prepareSessions = require('.')
@@ -45,6 +46,20 @@ basicEnvironment(function(error)
4546
{
4647
if(error) return onerror(error)
4748

49+
// Remove from initramfs the files only needed on boot to free memory
50+
try
51+
{
52+
rimraf('/bin/nodeos-boot-multiuser')
53+
rimraf('/init')
54+
rimraf('/lib/node_modules/nodeos-boot-multiuser')
55+
rimraf('/sbin')
56+
}
57+
catch(error)
58+
{
59+
// If `rootfs` is read-only (like in `vagga`), ignore the error
60+
if(error.code !== 'EROFS') return callback(error)
61+
}
62+
4863
// KTHXBYE >^.^<
4964
})
5065
})

0 commit comments

Comments
 (0)