Skip to content

Commit

Permalink
Single Process OS
Browse files Browse the repository at this point in the history
  • Loading branch information
piranna committed Jun 30, 2017
1 parent dc47227 commit 3801639
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ If you encounter an error when building NodeOS, take a look at
[the wiki](https://github.com/NodeOS/NodeOS/wiki/Fixing-NodeOS-Build-Errors) or
open an [issue](https://github.com/NodeOS/NodeOS/issues).

## Single Process OS

NodeOS can be used as a Single Process OS, where only run a single executable.
To do so, set the `SINGLE_USER` environment variable to the name of a `npm`
module when executing `npm run build`. This will run fully from initram,
persistence can be achieved by setting this environment variable to an empty
string and later using a custom `usersfs` partition, but this is still
experimental.

## NodeOS on LXC containers (Docker and vagga)

NodeOS fully officially supports Docker, published images are available at the
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"private": true,
"dependencies": {
"nodeos-barebones": "^1.0.0-RC3.1",
"nodeos-initramfs": "^1.0.0-RC3.2",
"nodeos-initramfs": "NodeOS/nodeos-initramfs",
"nodeos-usersfs": "NodeOS/nodeos-usersfs"
},
"devDependencies": {
Expand Down
32 changes: 19 additions & 13 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ if [[ "$PLATFORM" == "docker" ]]; then
export KERNEL=nokernel
fi

# Default: multiple users system
export SINGLE_USER=${SINGLE_USER-"nodeos-boot-multiUser"}

NPMi="npm install --arch=$NODE_ARCH --production"


Expand All @@ -57,25 +60,28 @@ NPMi="npm install --arch=$NODE_ARCH --production"
#

( cd $BAREBONES && $NPMi ) &&
( cd $INITRAMFS && $NPMi ) &&
( cd $USERSFS && $NPMi ) || exit 10
( cd $INITRAMFS && $NPMi ) || exit 10

if [ "$SINGLE_USER" == "nodeos-boot-multiUser" ]; then
( cd $USERSFS && $NPMi ) || exit 11
fi


#
# Wrap the system up and pack it
#

BAREBONES=$BAREBONES/out/$CPU
INITRAMFS=$INITRAMFS/out/$CPU
INITRAMFS=$INITRAMFS/out/$CPU-$SINGLE_USER
USERSFS=$USERSFS/out/$CPU.tar.gz

STEP_DIR=$OUT_DIR

mkdir -p $STEP_DIR

function copyAndConvertInitrams() {
cpio2tar $BAREBONES/barebones.cpio.gz | gzip -c > $STEP_DIR/barebones || err 20
cpio2tar $INITRAMFS | gzip -c > $STEP_DIR/initramfs || err 21
cpio2tar $BAREBONES/barebones.cpio.gz | gzip -c > $STEP_DIR/barebones || err 20
cpio2tar $INITRAMFS | gzip -c > $STEP_DIR/initramfs-$SINGLE_USER || err 21
}

case $MACHINE in
Expand All @@ -102,7 +108,7 @@ case $MACHINE in
tar --delete dev/console | \
gzip > $STEP_DIR/barebones.tar.gz || err 40

mv $STEP_DIR/initramfs $STEP_DIR/initramfs.tar.gz || err 41
mv $STEP_DIR/initramfs-$SINGLE_USER $STEP_DIR/initramfs.tar.gz || err 41

# Exec `logon` directly instead of use `node-bin-getty` on the console
mkdir -p root/etc && cp resources/palmtree.json root/etc || err 42
Expand Down Expand Up @@ -149,16 +155,16 @@ case $MACHINE in
tar)
copyAndConvertInitrams || exit $?

nodeos-bootfs \
-B $STEP_DIR/barebones \
-F $PLATFORM \
-I $STEP_DIR/initramfs \
-O $STEP_DIR/bootfs.tar.gz || err 80
nodeos-bootfs \
-B $STEP_DIR/barebones \
-F $PLATFORM \
-I $STEP_DIR/initramfs-$SINGLE_USER \
-O $STEP_DIR/bootfs.tar.gz || err 80

cp $USERSFS $STEP_DIR/usersfs.tar.gz || err 81

# Delete temporal initrams
rm -f $STEP_DIR/barebones $STEP_DIR/initramfs || err 82
rm -f $STEP_DIR/barebones $STEP_DIR/initramfs-$SINGLE_USER || err 82
;;

vagga)
Expand All @@ -168,7 +174,7 @@ case $MACHINE in
tar --delete dev/console sbin/init | \
gzip > $STEP_DIR/barebones.tar.gz || err 90

mv $STEP_DIR/initramfs $STEP_DIR/initramfs.tar.gz || err 91
mv $STEP_DIR/initramfs-$SINGLE_USER $STEP_DIR/initramfs.tar.gz || err 91

cp $USERSFS $STEP_DIR/usersfs.tar.gz || err 92

Expand Down

0 comments on commit 3801639

Please sign in to comment.