diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..cdfaa8399 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,43 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + + + +## Description + + +## Expected Behavior + + +## Actual Behavior + + +## Possible Fix + + +## Screenshots or Log + + +## Steps to Reproduce + + +1. +2. +3. +4. + +## Context + + +## Your Environment + +* Operating System used: +* Platform used: +* Node Version used (locally): +* NPM Version used (locally): +* NodeOS Version used: +* Special Environment Variables used: +* Link to your project: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..cecab4519 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** + +> + +**Describe the solution you'd like** + +> + +**Describe alternatives you've considered** + +> + +**Additional context** + +> diff --git a/.gitignore b/.gitignore index d3b0af3c2..9eba4f2c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,15 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + node_modules/ npm-debug.log -out/ .vagga/ -deps/ .vagrant/ -ubuntu-xenial-16.04-cloudimg-console.log +build/ +deps/ +out/ prebuilds/ diff --git a/Contributing.md b/Contributing.md index 6f2a1006e..208fa33f1 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,3 +1,12 @@ + + ## Overview This repository is for: @@ -7,14 +16,16 @@ This repository is for: 3. high-level planning You should feel free to shoot from the hip when posting issues. -Having said that, please take a moment to *search* for [open issues](https://github.com/NodeOS/NodeOS/issues "open issues on NodeOs") before posting. -Long threads are okay. +Having said that, please take a moment to *search* for +[open issues](https://github.com/NodeOS/NodeOS/issues "open issues on NodeOs") +before posting. Long threads are okay. ## Contributing FAQ > Why not a mailing list? -1. it's *yet another* point of contact. This repo should be your single source of truth in exploring node-os. +1. it's *yet another* point of contact. This repo should be your single source + of truth in exploring node-os. 2. github issues can be setup to mail you, and you can reply from email 3. better linking to actual code 4. markdown is good diff --git a/LICENSE.txt b/LICENSE.txt index d89060479..5b783d1ef 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,16 +1,8 @@ MIT License -Copyright (c) 2013-2016 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' and +Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' and other contributors -This software consists of voluntary contributions made by many individuals. For -exact contribution history, see the revision history available at -https://github.com/NodeOS/NodeOS - -The following license applies to all parts of this software: - -==== - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/README.md b/README.md index 0f858b94d..2a5bc18db 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,30 @@ + + [![Build Status](https://semaphoreapp.com/api/v1/projects/71d72807-779a-40d3-a8d4-523cd0a52eb3/356164/shields_badge.svg)](https://semaphoreapp.com/nodeos/nodeos) [![Stories in Ready](https://badge.waffle.io/NodeOS/NodeOS.png?label=ready&title=Ready)](https://waffle.io/NodeOS/NodeOS) [![Join the chat at https://gitter.im/NodeOS/NodeOS](https://badges.gitter.im/NodeOS/NodeOS.svg)](https://gitter.im/NodeOS/NodeOS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![bitHound Overall Score](https://www.bithound.io/github/NodeOS/NodeOS/badges/score.svg)](https://www.bithound.io/github/NodeOS/NodeOS) [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg)](https://opensource.org/licenses/mit-license.php) # NodeOS +[![Greenkeeper badge](https://badges.greenkeeper.io/NodeOS/NodeOS.svg)](https://greenkeeper.io/) + Lightweight operating system using [Node.js](http://nodejs.org) as userspace. -NodeOS is an operating system build entirely in Javascript and managed by -[npm](https://www.npmjs.com). Any package in `npm` is a NodeOS package, which at -last count was 301,660 packages. The goal of NodeOS is to provide just enough to -let `npm` provide the rest. Since anyone can contribute to it, anyone can create -NodeOS packages. +NodeOS is an operating system built entirely in Javascript and managed by +[npm](https://www.npmjs.com). Any package in `npm` is a NodeOS package, that +means a selection of more than 400.000 packages. The goal of NodeOS is to +provide just enough to let `npm` provide the rest. Since anyone can contribute +to it, anyone can create NodeOS packages. -This project won the spanish [9th National Free Software Championship](https://www.concursosoftwarelibre.org/1415) +This project won the Spanish [9th National Free Software Championship](https://www.concursosoftwarelibre.org/1415) on the Systems category and was Honorable Mention of its [10th edition](https://www.concursosoftwarelibre.org/1516). It was also presented as the degree thesis of [Jesús Leganes Combarro](https://github.com/piranna) with a qualification of 10/10 with distinction. @@ -32,8 +42,8 @@ with a qualification of 10/10 with distinction. ## Introduction -NodeOS is a Node.js based operating system, built-off of the Linux kernel. -The NodeOS Project is aiming to, and can already run on some of the following +NodeOS is a Node.js based operating system, built-off of the Linux kernel. The +NodeOS Project is aiming to, and can already run on some of the following platforms: - **real hardware** like desktops, laptops, or SoC's (Raspberry Pi) @@ -47,50 +57,49 @@ adjust better to each target platform, but the general structure is: - *barebones* custom Linux kernel with an initramfs that boots to a Node.js REPL - *initramfs* Initram environment to mount the users partition & boot the system -- *rootfs* Read-only partition image to host Linux kernel and initramfs files - *usersfs* multi-user environment with the same behaviour of traditional OSes ### Booting process All the layers are bootable, leading *barebones* to a raw naked Node.js -[REPL](http://nodejs.org/api/repl.html) prompt as PID 1, while *initramfs* (and -by extension *rootfs*) exec actual NodeOS code to mount the *usersfs* partition. -In all the cases, it will be used an initramfs as root filesystem and all the -changes will be lost when powered-off. +[REPL](http://nodejs.org/api/repl.html) prompt as PID 1, while *initramfs* exec +actual NodeOS code to isolate user code from the core system and, if available, +mount a partition with the users' home directories and root filesystems. If a *usersfs* partition is being set at boot time, it will be mounted and the -system will considerate each one of its folders as the home folder for a valid -user on the system, and will execute a `init` file in the root of each of them. -If found, `root` user will be the first to be considerated and will have access -to all the home directories, but by design it will not be possible to elevate -permissions once the system has booted. +system will consider each one of its folders as the home folder for a valid user +on the system, and will execute a `init` file in the root of each of them. If +found, the `root` user will be the first to be considered and will have access +to all of the home directories, but by design it will not be possible to elevate +permissions once the system has finished booting. ### Hacking -If you are hacking on NodeOS as a somewhat production server, you are likely -building *usersfs* images since each user is isolated of others, but you can be -able to customize all layers. For example, you could be able to modify -*initramfs* to login the users and mount their home folders from a cloud service -or craft a system without global services (no `root` user) or also dedicate a -full NodeOS instance to a single Node.js application. +If you are hacking on NodeOS for a somewhat production environment, you are +likely interested on building a custom *usersfs* image or modify it once booted, +since each user is isolated from the others and everyone can be able to define +its own root filesystem, but you can customize all other layers if you want. For +example, you can modify *initramfs* to login users and mount their home folders +from a cloud service or craft a system without global services (no `root` user), +or also dedicate a full NodeOS instance to a single Node.js application. -# Pre-built Images +## Pre-built Images Ready to use [pre-build images](https://github.com/NodeOS/NodeOS/releases) are automatically generated after each commit in master branch that sucessfully [pass the tests](https://semaphoreapp.com/nodeos/nodeos). To exec them, you'll need to have [QEmu](http://wiki.qemu.org/Main_Page) installed on your system. -The *iso* can be written to a CD-R or flashed to an USB pendrive, but will only -provide the read-only rootfs and the changes will be done in memory loosing them -after reboot, so you'll need to set manually a read-write usersfs partition if -you want to persist them. On the other hand, if you want to flash it to an USB -pendrive, it's recomended to do it by using `bin/installUSB` command so it will -create automatically a read-write usersfs partition to fill the remaining space -so your changes will persist. +The *iso* can be written to a CD-R or flashed to a USB pendrive, but will only +provide the read-only rootfs and the changes will be done in memory, losing them +after reboot, so you'll manually need to set a read-write *usersfs* partition if +you want to persist them. On the other hand, if you want to flash it to a USB +pendrive, We recommended doing it by using `bin/installUSB` command so it will +automatically create a read-write *usersfs* partition to fill the remaining +space and use it as persistent storage. -# Build NodeOS in five steps +## Build NodeOS in five steps 1. Download the project source code: @@ -99,8 +108,8 @@ so your changes will persist. cd NodeOS ``` -2. Install the required build tools, on a Ubuntu based system you can do it by - executing +2. Install the required build tools. On a Ubuntu based system you can do it by + executing: ```bash sudo bin/install-dependencies @@ -110,22 +119,20 @@ so your changes will persist. ```bash npm install - ``` + ``` -3. Build NodeOS: +4. Build NodeOS: ```bash npm run build ``` By default it will generate some files that can be used with QEmu, compiled - for your current machine architecture. You can be able to configure the build - process by passing some environment variables. For example, to force to build - for 32 bits, use `PLATFORM=qemu_32 npm install` instead. - -4. Pick some microwave pop-corn and go to see a movie. No, really, do it. + for your current machine architecture. You can configure the build process + by passing some environment variables. For example, to force to build for 32 + bits, use `BITS=32 npm install` instead. -5. Exec your fresh compiled NodeOS image: +5. Exec your freshly compiled NodeOS image: ```bash npm start @@ -134,20 +141,30 @@ so your changes will persist. It will automatically detect what CPU architecture will need to be used on QEmu and exec the correct emulation. -...and profit! :-D +...profit! :-D 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). -# NodeOS on LXC containers (Docker and vagga) +## 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. -Currently LXC containers support is unmaintained due to the inability to mount -filesystems from inside them. There are some NodeOS images on Docker Hub, but -they are totally outdated. If you are interested in help or testing, you can -build them from source code. +## NodeOS on LXC containers (Docker and vagga) -## Quick Start +NodeOS fully officially supports Docker, published images are available at the +[DockerHub NodeOS organization](https://hub.docker.com/u/nodeos). If you are +interested in helping or testing, you can build them from source code. + +Vagga support is fairly experimental, and help here will be greatly appreciated. + +### Quick Start 1. [Install Docker](http://docs.docker.io/en/latest/installation/) 2. One Liner @@ -156,15 +173,18 @@ build them from source code. sudo docker run -t -i nodeos/nodeos ``` - or learn how to make a [Custom Build](http://node-os.com/blog/get-involved/) - -## Build from Source - -*Warning*: the build process is hairy, it probably won't work the first time. -I'm working on that. +### Build from Source ```bash git clone https://github.com/NodeOS/NodeOS.git cd NodeOS PLATFORM=docker npm install ``` + +## License + +MIT + +This software consists of voluntary contributions made by many individuals. For +exact contribution history, see the revision history available at +https://github.com/NodeOS/NodeOS diff --git a/Vagrantfile b/Vagrantfile index 50a40d202..3556a5190 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,13 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" diff --git a/bin/install-dependencies b/bin/install-dependencies index 13ad143d3..a54a35e63 100755 --- a/bin/install-dependencies +++ b/bin/install-dependencies @@ -1,38 +1,65 @@ #! /usr/bin/env bash -set -o pipefail - - -APT='apt-get -qq -y' - - +# NodeOS # -# Install Ubuntu dependencies -# The dependencies of one level would also be needed for the next ones +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors # +# MIT License -# Update cache -dpkg --add-architecture i386 && -$APT update || exit 1 +# This particular option sets the exit code of a pipeline to that of the +#rightmost command to exit with a non-zero status, +#or to zero if all commands of the pipeline exit successfully. +set -o pipefail + +NODESOURCE=https://deb.nodesource.com/setup_6.x +if [ -f /etc/redhat-release ]; then +PKGMGR='yum' -# Install dependencies $ Node.js -$APT install curl || exit 10 +elif [ -f /etc/arch-release ]; then +PKGMGR='pacman -S -y --noconfirm' +$PKGMGR gcc texinfo python2 || exit 1 # cross compiler +$PKGMGR bc libcurl-gnutls pixman || exit 10 # barebones +$PKGMGR cdrkit || exit 20 # bootfs +$PKGMGR cpio || exit 30 # initramfs +$PKGMGR autoconf automake || exit 40 # usersfs +$PKGMGR sdl || exit 50 # qemu +$PKGMGR nodejs-lts-boron || exit 60 # nodejs +$PKGMGR npm || exit 70 # npm -# cross-compiler -$APT install gcc git || exit 20 +ln -sf /usr/bin/python2 /usr/bin/python # symlink to python 2 +npm config set python /usr/bin/python2 -# barebones -$APT install bc || exit 21 +elif [ -f /etc/gentoo-release ]; then +PKGMGR='emerge --ask n' -# rootfs -$APT install genisoimage libc6-i386 libuuid1:i386 || exit 22 +$PKGMGR sys-devel/gcc texinfo python-2.7 || exit 1 +$PKGMGR sys-devel/bc x11-libs/pixman net-libs/gnutls || exit 10 +$PKGMGR net-misc/curl || exit 21 +$PKGMGR app-cdr/cdrtools || exit 30 +$PKGMGR app-arch || exit 40 +$PKGMGR dev-vcs/git || exit 50 +$PKGMGR sys-fs/mtools || exit 60 +$PKGMGR sys-libs/glibc || exit 70 +$PKGMGR sys-libs/libuuid || exit 80 +$PKGMGR media-libs/libsdl || exit 90 +elif [ -f /etc/SuSE-release ]; then +PKGMGR='zypp' -# qemu -$APT install libsdl1.2-dev || exit 30 +elif [ -f /etc/debian_version ]; then +PKGMGR='apt-get -qq -y' +dpkg --add-architecture i386 && $PKGMGR update || exit 1 +$PKGMGR install curl || exit 10 +$PKGMGR install gcc git || exit 20 +$PKGMGR install bc || exit 21 +$PKGMGR install genisoimage mtools libc6-i386 libuuid1:i386 || exit 22 +$PKGMGR install libsdl1.2-dev || exit 30 # Update Node.js to v6.x (npm3) from the NodeSource repository -curl -sL https://deb.nodesource.com/setup_6.x | bash && -$APT install nodejs || exit 40 +curl -sL $NODESOURCE | bash && $PKGMGR install nodejs || exit 40 + +fi + diff --git a/bin/installUSB b/bin/installUSB index 7af5e39df..5163cbd96 100755 --- a/bin/installUSB +++ b/bin/installUSB @@ -1,5 +1,11 @@ #!/usr/bin/env bash +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License if [ "$#" -ne 3 ]; then echo "Usage: $0 " @@ -9,17 +15,17 @@ fi DEVICE=$1 PARTITION=${DEVICE}2 -ROOTFS=$2 +BOOTFS=$2 USERSFS=$3 -# Copy rootfs & usersfs partition images on USB device +# Copy bootfs & usersfs partition images on USB device -SIZE_ROOTFS=$(stat -L -c%s "$ROOTFS") -SIZE_ROOTFS=$(($SIZE_ROOTFS/512)) +SIZE_BOOTFS=$(stat -L -c%s "$BOOTFS") +SIZE_BOOTFS=$(($SIZE_BOOTFS/512)) -dd if=$ROOTFS of=$DEVICE && -dd if=$USERSFS of=$DEVICE seek=$SIZE_ROOTFS || exit 11 +dd if=$BOOTFS of=$DEVICE && +dd if=$USERSFS of=$DEVICE seek=$SIZE_BOOTFS || exit 11 sync diff --git a/doc/NodeOS Layer 1 - barebonesfs.png b/doc/NodeOS Layer 1 - barebonesfs.png new file mode 100644 index 000000000..4cdb4417a Binary files /dev/null and b/doc/NodeOS Layer 1 - barebonesfs.png differ diff --git a/doc/NodeOS Layer 2 - initramfs.png b/doc/NodeOS Layer 2 - initramfs.png new file mode 100644 index 000000000..bc4ff3e1f Binary files /dev/null and b/doc/NodeOS Layer 2 - initramfs.png differ diff --git a/doc/NodeOS Layer 3 - usersfs.png b/doc/NodeOS Layer 3 - usersfs.png new file mode 100644 index 000000000..5676e6bf7 Binary files /dev/null and b/doc/NodeOS Layer 3 - usersfs.png differ diff --git a/doc/NodeOS bootfs.png b/doc/NodeOS bootfs.png new file mode 100644 index 000000000..f3f7730ce Binary files /dev/null and b/doc/NodeOS bootfs.png differ diff --git a/doc/NodeOS layer 1.png b/doc/NodeOS layer 1.png deleted file mode 100644 index 6eb655128..000000000 Binary files a/doc/NodeOS layer 1.png and /dev/null differ diff --git a/doc/NodeOS layer 2.png b/doc/NodeOS layer 2.png deleted file mode 100644 index 3f556832e..000000000 Binary files a/doc/NodeOS layer 2.png and /dev/null differ diff --git a/doc/NodeOS layer 3.png b/doc/NodeOS layer 3.png deleted file mode 100644 index 572ca168d..000000000 Binary files a/doc/NodeOS layer 3.png and /dev/null differ diff --git a/doc/NodeOS layer 4.png b/doc/NodeOS layer 4.png deleted file mode 100644 index a2880c7ae..000000000 Binary files a/doc/NodeOS layer 4.png and /dev/null differ diff --git a/doc/NodeOS.dia b/doc/NodeOS.dia index dc7f9a067..58766cb87 100644 Binary files a/doc/NodeOS.dia and b/doc/NodeOS.dia differ diff --git a/docs/Design.md b/docs/Design.md new file mode 100644 index 000000000..cfa4bb7ae --- /dev/null +++ b/docs/Design.md @@ -0,0 +1,12 @@ +## Here lies our collective conciousness ## + +Even as we discuss everything in the issues, additionally here you will find drafts for concepts and ideas for NodeOS. Feel free to contribute to an idea and should a great idea come across your mind, create a new Thread and page and link one to another! + + +### Current Designs ### +- [[file system|FileSystem]] +- [[npkg]] +- [[services]] +- [[asgard]] +- [[root]] +- [[init]] \ No newline at end of file diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 000000000..a975f26ce --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1,8 @@ +# NodeOS Frequently Asked Questions # +(Or solutions to problems you seem to have often). + +Not many questions will be actually answered on this page, but rather linked to the respective page thank explains it to you nicely in detail. Hopefully at the start of the page a tl;dr will sum it all up for you if you don't have time. + +Fixing NodeOS Build Errors: [[Fixing-NodeOS-Build-Errors]] + +How do I add startup services?: [[Service Starter (PalmTree)]] \ No newline at end of file diff --git a/docs/FileSystem.md b/docs/FileSystem.md new file mode 100644 index 000000000..ceb30310e --- /dev/null +++ b/docs/FileSystem.md @@ -0,0 +1,60 @@ +## system directories + +The base filesystem is laid out as follows. + +A few standard linux directories are now considered private, +and only included for compatibility with the current *libc*. + +``` +/bin <-- contains latest node executable +/lib +/usr +/etc +``` + +All user-editable content should be in user-directories. +The root user's home is in it's standard `/root` location. + +``` +/root <-- root user +/home <-- non-root users +``` + +The [[root]] user is special because it boots the system. + +Other standard kernel-provided file systems are mounted in their usual locations. + +``` +/dev <-- devfs +/proc <-- procfs +/sys <-- sysfs +/tmp <-- tmpfs +``` + +## user directories + +There are no *global* services, modules, or commands. +Directories that were once system-leve, like `etc`, and `var` are now user-local. + +``` +$HOME/ + bin/ <-- executable commands + ls, cp, mv + lib/ + node_modules/ <-- modules installed by npkg + log/ <-- logs from init jobs + etc/ <-- configuration files + var/ <-- persistent data + tmp/ <-- ephemeral data +``` + +In detail: + +- `bin` contains executable commands, linked during `npkg install`. +- `lib` contains `node_modules` which holds modules installed by `npkg`. +- `log` contains output from services and jobs. +- `etc` contains local config values for services and jobs +- `var` holds persistent data for services and jobs. +- `tmp` holds ephemeral data for services and jobs. + +These directories are used assumed by the `npkg` command. diff --git a/docs/Fixing-NodeOS-Build-Errors.md b/docs/Fixing-NodeOS-Build-Errors.md new file mode 100644 index 000000000..aa594ef37 --- /dev/null +++ b/docs/Fixing-NodeOS-Build-Errors.md @@ -0,0 +1,24 @@ + +> scripts/install: line 93: genext2fs: command not found + +You need to install genext2fs: `sudo apt-get install genext2fs` + +> can not find a C compiler + +The build probably got closed while in progress. Delete the `out` and `obj` folders you find in the sub folders of `node_modules` + +> scripts/start +Could not access KVM kernel module: No such file or directory +failed to initialize KVM: No such file or directory + +Your computer or virtual machine doesn't support kvm. Comment out [this line](https://github.com/NodeOS/NodeOS/blob/master/scripts/start#L34) + +> /usr/bin/env: node: No such file or directory + +Try +``` +sudo apt-get update +sudo apt-get dist-upgrade +``` + +If you have any other errors when building NodeOS, check if there is an issue for the error. If there isn't please create [a new issue](https://github.com/NodeOS/NodeOS/issues/new). \ No newline at end of file diff --git a/docs/GUI.md b/docs/GUI.md new file mode 100644 index 000000000..a5660cb8c --- /dev/null +++ b/docs/GUI.md @@ -0,0 +1,29 @@ +NodeOS is an operating system mainly designed to be run on head-less server machines, and although it's expected to has in mid-term future support for audio & graphics, it will not have a GUI by itself. Instead, NodeOS will offer some graphic primitives that would allow to third-party Node.js modules to build widget components and a GUI by themselves. It's not clear yet how this low-level primitives APIs will be, but due to the relationship of Node.js with Javascript and this last one with the Web ecosystem, there are two clear candidates that would allow an easy transition and/or adaptation to current available applications: + +# canvas +The [canvas](http://www.w3.org/wiki/HTML/Elements/canvas) object offer a bi-dimensional surface where pixels can be painted independently similar to other 2D environments like [SDL](https://www.libsdl.org/) or [DirectFB](http://directfb.org/), so it's a natural choice as a graphic primitive for drawing on a screen, and its API also has support for 3D drawing by using [WebGL](https://www.khronos.org/webgl/). Problem is, though, that the canvas object offer only low-level graphic primitives, so to create richer applications that works with images, windowing or z-buffer, it's needed to use external libraries and runtimes that offer that functionality on top of it. + +## How can be done +This could be done by using [node-canvas](https://github.com/Automattic/node-canvas) by adapting it to use an EGL-backed Cairo graphic library, or [node-openvg-canvas](https://github.com/luismreis/node-openvg-canvas) that's compatible with node-canvas but more focused on screen rendering by using OpenVG library. + +## Use cases +Canvas main use cases are pure Javascript flash-like applications fully build by using a canvas object like games and emulators ported from web browsers, or new Node.js graphical applications build directly by using the canvas object, for example on low-resources environments or if the system will host only a single full-screen applications, like embebed systems. In that case it's encouraged (but not mandatory) to isolate the graphic interface from the logic of the application so this last one can be accessed from several UI clients (maybe richer ones build using a web renderer, see below), both locally or on remote machines. + +# web renderer +Canvas object and other framebuffer-like APIs are too low-level to use as basis for some richer applications. For more advanced desktop-like applications, a good alternative is to use a web renderer, so this way you have all the functionality and flexibility of a standard web browser, at the cost of needing to use a heavier runtime. This is similar to how ChromeOS or FirefoxOS works, and [there's interest on this happening on NodeOS](https://medium.com/javascript-ecosystem/booting-to-node-2d620ac5402), as the project issues [has](https://github.com/NodeOS/NodeOS/issues/78) [shown](https://github.com/NodeOS/NodeOS/issues/79). + +Currently there are some projects with a similar focus like [node-webkit](https://github.com/rogerwang/node-webkit), [atom-shell](https://github.com/atom/atom-shell) or [thrust](https://github.com/breach/thrust). Problems with them is that they are focused on development of desktop apps and integration using web technologies, so they are a little bit bloated for an environment like NodeOS where there's no desktop at all, and a thinner layer like the ones used in ChromeOS or FirefoxOS is a better alternative. Also, node-webkit and atom-shell allow direct access to Node.js functions from the DOM, making it more dificult to access to that applications remotely. + +## How can be done +The best alternative is [Chrome Embebed Framework](https://code.google.com/p/chromiumembedded/) (CEF), already being used by node-webkit, atom-shell and thrust. It should be used as a simple web renderer or web browser without any special intregation with Node.js or NodeOS, just only being compiled and packaged as a NPM package, and access to the Node.js app or NodeOS functionality by using a REST API or WebSockets, depending of the decision of the developer, and the interface files served by a static web server (that could be the same app server). If there's a common pattern on the development process, it could be bundle as a framework, but this is not intended at a short or medium term to allow more flexibility and creation liberty to the developers. + +This architecture allow the interface of the application to be isolated from the server functionality and the Node.js/NodeOS internal, so the app can also be accesible from an external web browser. An example of a Node.js application that somewhat follow this architecture is [Node.js Music Player](https://github.com/benkaiser/node-music-player). This is clearly more focused for daemonized applications, for "one shot" ones there could be used an on-demand stateless web server, but an alternative is to exec the server and open the client window at the same time. + +## Use cases +Depending of the grade of integration between the GUI and the server done by the developer, we can see three kind of applications or use cases: + +* **webapp**: the application is fully build in client-side Javascript and HTML and don't need a server to run it, only a static web server to serve the files. This is the same concept that traditional web apps and will run entirely on the CEF environment. Obviously, canvas-based graphical applications that don't rely on Node.js/NodeOS APIs and are executable on a web browser environment can fall in this category at the same time that they can be run directly on the Linux terminal by using a canvas object as shown previously with some minor adaptions. +* **server-side logic**: the logic of the application is fully on the Node.js server process, and the interface only show the results. This concept is similar to traditional or AJAX-based web architecture. +* **client-side logic**: the logic of the application is on the webapp, and the server acts as a proxy to allow access to the priviledged Node.js/NodeOS APIs (filesystem, TCP ports...). This is similar to the development of ChromeOS or FirefoxOS apps, with the difference that the use of priviledged APIs is not done by custom specific Javascript objects but instead by a custom protocol offered by the proxy server. This could be think to be added in the future as an uniform API on NodeOS itself instead of each developer crafting their own proxy server, for example by showing a REST API to that priviledged functionality or similar. + +At this moment the prefered behaviour is the last one, where the static files are served by [Davius](https://github.com/piranna/Davius) DAV server or any other static HTTP server that autoclose itself. The autoclose mechanism can be implemented by using the [oneshoot](https://github.com/piranna/oneshoot) module or any other similar one. If the application needs to access some extra functionality it could use `oneshoot` or any other module to start an ad-hoc REST or WebSocket server. Also, it should be possible that the applications get executed standalone on a regular web browser without requiring to use any functionality provided by a particular desktop environment, or do it in an optional way. \ No newline at end of file diff --git a/docs/LANGS.md b/docs/LANGS.md new file mode 100644 index 000000000..422b28cf7 --- /dev/null +++ b/docs/LANGS.md @@ -0,0 +1,4 @@ +* [English](en/) +* [French](fr/) +* [Español](es/) +* [Deutsch](de/) \ No newline at end of file diff --git a/docs/Native-modules.md b/docs/Native-modules.md new file mode 100644 index 000000000..b959c832e --- /dev/null +++ b/docs/Native-modules.md @@ -0,0 +1,16 @@ +Native modules require compilation via a `gypfile`. +NodeOS comes with no build environment, and it may be quite a while before one exists. + +Despite a lack of build tools, NodeOS could not function without native dependencies. +Node has no native way to set an IP address, or configure the network gateway. +Node cannot mount file systems, or issue reboot commands. +Many system calls are not exposed natively by node, and as such require a native module interface. + +Some compiled modules required by NodeOS + +- src-sockios +- src-ioctl +- src-mount + +Until npm supports delivering pre-compiled dependencies, NodeOS will need a workaround. +The workaround is currently under development. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..b371f5982 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,11 @@ +# Read wiki... + +[in ENGLISH](./en/) + +[en ESPAÑOL](./es/) + +[en FRANÇAIS](./fr/) + +[auf Deutsch](./de/) + + diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 000000000..451a1cd54 --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,5 @@ +# Summary + +* [Introduction](README.md) +* Home + diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md new file mode 100644 index 000000000..09f3b043d --- /dev/null +++ b/docs/Troubleshooting.md @@ -0,0 +1,119 @@ +# Troubleshooting + +If you have problems to compile your NodeOS version or get errors during the compile process then please look below. + +## NodeOS boots into the REPL + +This error occurs when NodeOS cant mount the filesystem. This will propably happen when you compile your NodeOS with Arch Linux. + +**Solution: No possible Solution** + +## Incorrect NPM Version + +This error mostly occurs when you use NPM 3 with Node.js 5.x because NPM 3 uses a flat dependency structure + +```bash +cp: the call of stat for 'node_modules/nodeos-barebones/out/latest' is not possible: file or directory not found +cp: the call of stat for 'node_modules/nodeos-initramfs/out/latest' is not possible: file or directory not found +cp: the call of stat for 'node_modules/nodeos-usersfs/out/latest' is not possible: file or directory not found +``` + +**Solution: Please change your Node.js version from 5.x to 4.x and your NPM version from 3.x to 2.x** + +Reference: Issue [#223](../issues/223) + +## Dissapearing nodeos-barebones + +This error occurs like the error above on the NPM version + +```bash +$ find . -name adjustEnvVars.sh +./node_modules/nodeos-barebones/node_modules/nodeos-cross-toolchain/scripts/adjustEnvVars.sh + +$ npm install + +> NodeOS@0.0.0 install /home/tbrooks/Projects/nodeos +> scripts/build + +scripts/build: line 7: /home/myprofile/Projects/node_modules/nodeos-barebones/node_modules/nodeos-cross-toolchain/scripts/adjustEnvVars.sh: No such file or directory + +npm ERR! Linux 4.4.1-2-ARCH +npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" +npm ERR! node v5.6.0 +npm ERR! npm v3.7.1 +npm ERR! code ELIFECYCLE +npm ERR! NodeOS@0.0.0 install: `scripts/build` +npm ERR! Exit status 1 +npm ERR! etc... +``` + +**Solution: Please change your Node version from 5.x to 4.x and your NPM version from 3.x to 2.x** + +Reference: Issue [#218](../issues/218) + +## NSH crashes on empty pipe + +If you're using a old NodeOS docker image and enter `|` then you can get something like this + +For the old Docker images: + +```bash +/root/lib/node_modules/bin-nsh/node_modules/lib-cmdparse/index.js:15 + if (env && item[0] != '-' && item.indexOf('=') > 0) { + ^ +TypeError: Object has no method "indexOf" + at /root/lib/node_modules/bin-nsh/node_modules/lib-cmdparse/index.js:15:39 + at Array.forEach (native) + at parse (/root/lib/node_modules/bin-nsh/node_modules/lib-cmdparse/index.js:13:9) + at run (/root/lib/node_modules/bin-nsh/nsh.js:123:16) + at readline (/root/lib/node_modules/bin-nsh/nsh.js:93:7) + at /root/lib/node_modules/bin-nsh/nsh.js:176:5 + at Interface._onLine (readline.js:200:5) + at Interface._line (readline.js:531:8) + at Interface._ttyWrite (readline.js:760:14) + at ReadStream.onkeypress (readline.js:99:10) +``` + +For the new versions: + +```bash +/ # | +readline.js:925 + throw err; + ^ + +TypeError: item.indexOf is not a function + at Stacktrace.. +``` + +**Solution: For now there is no solution for this problem** + +Reference: Issue [#217](../issues/217) + +## Error compiling NodeOS / QEMU + +In older version qemu were a normal dependency, for the new versions of NodeOS, is qemu now a npm dependency + +```bash +{ + [ Error: Command failed: ./configure --prefix=/home/triplebackslash/Documents/nodeos/node_modules/nodeos-barebones/usr --target-list=arm-softmmu,i386-softmmu,x86_64-softmmu,arm-linux-user,i386-linux-user,x86_64-linux-user --disable-docs --disable-vnc --enable-sdl ] + killed: false, + code: 1, + signal: null, + cmd: "./configure --prefix=/home/triplebackslash/Documents/nodeos/node_modules/nodeos-barebones/usr --target-list=arm-softmmu,i386-softmmu,x86_64-softmmu,arm-linux-user,i386-linux-user,x86_64-linux-user --disable-docs --disable-vnc --enable-sdl" +} +``` + +**Solution: Use newer version of NodeOS** + +Reference: Issue [#212](../issues/212) + +## genext2fs: command not found + +```bash +scripts/install: line 93: genext2fs: command not found +``` + +**Solution: You need to install genext2fs** + +## diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md new file mode 100644 index 000000000..291e69d83 --- /dev/null +++ b/docs/_Sidebar.md @@ -0,0 +1,18 @@ +- [[What is NodeOS|Home]] +- [[Introduction]] +- Getting Started + - [[Using precompiled Binaries]] + - [[Building From Source]] + - [Prerequisites](https://github.com/NodeOS/NodeOS/wiki/Building-From-Source#step-1-prerequisites) + - [Debian/Ubuntu dependencies](https://github.com/NodeOS/NodeOS/wiki/Building-From-Source#step-2a-debianubuntu-dependencies) + - [Arch Linux dependencies](https://github.com/NodeOS/NodeOS/wiki/Building-From-Source#step-2b-arch-linux-dependencies) + - [Installation](https://github.com/NodeOS/NodeOS/wiki/Building-From-Source#step-3-installation) + - [Run the build](https://github.com/NodeOS/NodeOS/wiki/Building-From-Source#step-4-run-your-fresh-nodeos-build) + - [Service Starter](https://github.com/NodeOS/NodeOS/wiki/Service-Starter-(PalmTree)) + - [[Commands]] + - [[Filesystem]] +- Roadmaps + - [Alpha Roadmap](https://github.com/NodeOS/NodeOS/issues/37) + - [Beta Roadmap](https://github.com/NodeOS/NodeOS/issues/146) +- [[Contributing]] +- [[Troubleshooting]] diff --git a/docs/asgard.md b/docs/asgard.md new file mode 100644 index 000000000..ee33fee69 --- /dev/null +++ b/docs/asgard.md @@ -0,0 +1,188 @@ +## _Warning! Deprecated_ in place of [[PalmTree|Service Starter (PalmTree)]] ## +NodeOS now uses PalmTree as it's service manager. But we leave this here for now as it's quite a beautiful page :smile: + +*** + +The service-manager (code name asgard) is a task running service. + +Asgard provides a simple abstraction, upon which a tool like [[npkg]] can build a traditional service manager like *systemd* or *forever*. + +Asgard has two abstractions: + +1. a **task** is a real process that must be run +2. a **queue** is an ordered list of tasks + +This is a low-level abstraction, and not really of concern for the end user. The end-user will use a tool like [[npkg]] and in general never need to know about how asgard works. Similar to how there is no *spawn* system call, rather spawning a child process is just a combination of `fork` and `exec`. + +So for anyone who just wants to run your node process, have a look at [[npkg]]. For those interested in the gory details, here are a few high-level features of asgard: + +- tasks are run as soon as they are added to a queue +- tasks run sequentially per queue +- different queues run in parallel +- when a queue is empty, it just waits for new tasks to be added +- there is limited support for manipulating a queue + +Typically queues will only have a few tasks added to them at any time. + +## HTTP IPC + +You communicate with asgard over http using JSON encoded data. + +For example, to start a queue you `PUT` to `/queue/:name` where `:name` is the unique identifier for your queue. + +```json +{ + "tasks": [ + { + "exec": "node", + "args": ["server.js"], + "envs": { + "PATH": "/bin:/root/lib/node_modules/myapp/node_modules/.bin" + }, + "cwd": "/root/lib/node_modules/myapp", + "fds": [...] + } + ] +} +``` + +The following are optional for each *task* + +```javascript +{ + "user" : 2, // prefer numeric id + "group" : 3, +} +``` + +Eventually we would like to support segmenting processes, and limiting them via a quota. +The following are reserved, but not implemented. +For more information see the Linux [clone](http://linux.die.net/man/2/clone) call. + +**these are a draft** + +```javascript +{ + "limit" : { + "memory" : "1GB", + "cpu" : "50%" + }, + "mount": { // create a new mount namespace + // TBD + }, + "iface": { // create a new network namespace + // TBD + }, + "newpid": true, // create a new PID space + "newpic": true, // create a new PIC space +} +``` + +## File Descriptors + +File descriptors are pointers to various IO conduits of a process. There are many *things* that can be represented by a file descriptor, + +- a normal file on the file system +- an unnamed pipe between two processes +- a named pipe +- a network socket +- a unix domain socket +- a block or character device + +Each of the above is represented by a file-descriptor, and various system calls can be made to each descriptor based on the *thing* it represents. + +Going forward, we probably want asgard to work with *all* of the above. + +```javascript +{ // a file + type: "file", + path: "/root/docs/myfile.txt", + mode: "rw", +} + +{ // a unix socket + type: "unix socket", + path: "/root/var/myapp.sock" +} + +{ // a network socket + type: "network socket", + bind: "127.0.0.1", + port: 8080 +} + +{ // a named pipe + type: "named pipe", + path: "..." +} +``` + +I don't want to support all of these yet, but it's something to keep in mind. I'm also not sure how to represent unnamed pipes between processes. + +Asgard should respond with `501 Not Implemented`, rather than a `400/500` error when using an unsupported file type. + +## Authentication + +HTTP + SSL is secure. If you think otherwise, you should stop using the web. We actually punt on handling security in asgard. Instead, we require that you secure the socket asgard is listening to. + +For simple cases, you can bind to `localhost`. Only processes on the same host can access asgard. + +A better approach might be binding to a unix domain socket, for example `/root/var/asgard.sock`. You can use file-system permissions to restrict access to the http server. This is how Docker works. + + +## Permissions + +There is no access-control. Either you have access to everything, or nothing. +In a multi-user environment, each user will run their own asgard service. + +Since each users copy of asgard runs with user-permissions, not root permissions, it can only do as much damage as the user sending jobs to it. + +``` +-+ asgard (root) + \ + +-+ asgard (bob) + | \ + | server.js (bob's server) + | + +-+ asgard (tom) + \ + server.js (tom's server) +``` + +## Restart Semantics + +There are no restart semantics. You can restart a queue by defining a second restart task, e.g. + +```javascript +{ + tasks: [ + {...}, // queue to run + {...} // command to restart queue + ] +} +``` + +The second command can decide how to restart the service, +since different tasks will demand different restart semantics. + +Why restart semantics are difficult: + +- A process that exits immediately due to an error can peg the CPU at 100%. +- Generally we do not want to ever *stop* trying to restart a process. + Do you care more if your CPU gets pegged for a while, or your website goes down? +- Sometimes we want notifications when processes exit. + +We let the caller to asgard decide how they want to handle restart. + +- Tasks are always run serially. + The previous task always exist before the next one starts. +- The exit code of the previous process is available via the + environment variable `TASK_EXIT`. + This will either be the number or signal name that + caused the previous task to exit. + +## Review + +- asgard is simple, yet flexible. +- asgard is focused on running tasks, and queues. +- asgard should export a well-defined API, to allow multiple products interact with it. diff --git a/docs/de/README.md b/docs/de/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/de/SUMMARY.md b/docs/de/SUMMARY.md new file mode 100644 index 000000000..68f863296 --- /dev/null +++ b/docs/de/SUMMARY.md @@ -0,0 +1,4 @@ +* [Was ist NodeOS?](was-ist-nodeos.md) +* [Einleitung](einleitung.md) +* [Erste Schritte](erste-schritte.md) + * \ No newline at end of file diff --git a/docs/de/einleitung.md b/docs/de/einleitung.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/de/erste-schritte.md b/docs/de/erste-schritte.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/de/was-ist-nodeos.md b/docs/de/was-ist-nodeos.md new file mode 100644 index 000000000..c6c6a9339 --- /dev/null +++ b/docs/de/was-ist-nodeos.md @@ -0,0 +1,6 @@ +# Was ist NodeOS? + +NodeOS ist ein minimalistisches Betriebssystem welches Node.js für den "Userspace" benutzt. NodeOS ist vollständig in Javascript gemacht und durch NPM (als Packetmanager) kontrolliert. Jedes Packet dass bei NPM vorhanden ist, ist gleichzeitig auch ein Packet für NodeOS, das heißt dass es 244,180 (nach letzter zählung) potenzielle Packete für NodeOS gibt. + +Das Ziel von NodeOS ist grade soviel bereitzustellen damit NPM den rest bereitstellen kann. +Da jeder auf NPM hochladen kann, kann auch jeder ein NodeOS Packet erstellen. \ No newline at end of file diff --git a/docs/en/Dependencies.md b/docs/en/Dependencies.md new file mode 100644 index 000000000..98b0ea9ce --- /dev/null +++ b/docs/en/Dependencies.md @@ -0,0 +1,235 @@ +# Main repositories +* [NodeOS](https://github.com/NodeOS/NodeOS) + [![Build Status](https://semaphoreapp.com/api/v1/projects/71d72807-779a-40d3-a8d4-523cd0a52eb3/356164/shields_badge.svg)](https://semaphoreapp.com/nodeos/nodeos) + [![Stories in Ready](https://badge.waffle.io/NodeOS/NodeOS.png?label=ready&title=Ready)](https://waffle.io/NodeOS/NodeOS) + [![Join the chat at https://gitter.im/NodeOS/NodeOS](https://badges.gitter.im/NodeOS/NodeOS.svg)](https://gitter.im/NodeOS/NodeOS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + [![bitHound Overall Score](https://www.bithound.io/github/NodeOS/NodeOS/badges/score.svg)](https://www.bithound.io/github/NodeOS/NodeOS) + [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg)](https://opensource.org/licenses/mit-license.php) + * [nodeos-cross-toolchain](https://github.com/NodeOS/nodeos-cross-toolchain) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/nodeos-cross-toolchain/branches/master/shields_badge.svg)](https://semaphoreci.com/nodeos/nodeos-cross-toolchain) + * async + * *download-manager* + * fs-extra + * prebuild-install + * prebuild + * [nodeos-barebones](https://github.com/NodeOS/nodeos-barebones) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/nodeos-barebones/branches/master/badge.svg)](https://semaphoreci.com/nodeos/nodeos-barebones) + * [cpio2tar](https://github.com/piranna/cpio2tar) + * cpio-stream + * tar-stream + * *download-manager* + * minimist (^1.2.0) + * *nodeos-nodejs* + * *qemu* + * suppose (^0.6.1) + * [nodeos-initramfs](https://github.com/NodeOS/nodeos-initramfs) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/nodeos-initramfs/branches/master/badge.svg)](https://semaphoreci.com/nodeos/nodeos-initramfs) + * *download-manager* + * [nodeos-mount-filesystems](https://github.com/NodeOS/nodeos-mount-filesystems) + * async (^1.5.2) + * mkdirp (^0.5.1) + * rimraf (^2.5.2) + * prompt (*) + * [nodeos-mount-utils](https://github.com/NodeOS/nodeos-mount-utils) + * mkdirp (^0.5.1) + * [nodeos-mount](https://github.com/NodeOS/nodeos-mount) + [![bitHound Score](https://www.bithound.io/NodeOS/nodeos-mount/badges/score.svg)](https://www.bithound.io/NodeOS/nodeos-mount) + * async (^1.5.2) + * nan (^2.2.0) + * grunt (~0.4.5) + * grunt-mocha-test (~0.12.7) + * grunt-contrib-watch (~0.6.1) + * grunt-node-gyp (~3.0.0) + * q (~1.4.1) + * posix (^4.0.0) + * chai (^3.5.0) + * errno-codes (^1.0.2) + * istanbul (^0.4.3) + * mocha (^2.4.5) + * proxyquire (^1.7.4) + * rimraf (^2.5.2) + * sinon (^1.17.3) + * sinon-chai (^2.8.0) + * *nodeos-nodejs* + * [usrbinenv](https://github.com/piranna/usrbinenv) + * kexec (^2.0.0) + * *qemu* + * suppose (^0.6.1) + * [nodeos-rootfs](https://github.com/NodeOS/nodeos-rootfs) + * *download-manager* + * [genfatfs](https://github.com/NodeOS/genfatfs) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/genfatfs/branches/master/badge.svg)](https://semaphoreci.com/nodeos/genfatfs) + * prebuild-install (^1.1.0) + * prebuild (^4.2.2) + * *qemu* + * [nodeos-usersfs](https://github.com/NodeOS/nodeos-usersfs) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/nodeos-usersfs/branches/master/badge.svg)](https://semaphoreci.com/nodeos/nodeos-usersfs) + * [bin-man](https://www.npmjs.com/package/bin-man) + * [bin-pwd](https://www.npmjs.com/package/bin-pwd) + * [davius](https://github.com/piranna/Davius) + * finalhandler (^0.4.1) + * fs-extra (^0.26.2) + * minimist (^1.2.0) + * [oneshoot](https://github.com/piranna/oneshoot) + * async (^1.5.0) + * escape-html (^1.0.3) + * serve-static (^1.10.0) + * ws (^0.8.0) + * [recv](https://github.com/piranna/recv) + * rimraf (^2.4.4) + * *[serve-static](https://github.com/piranna/serve-static)* + * parseurl (~1.3.0) + * *[send](https://github.com/piranna/send/tree/index)* + * istanbul (0.4.1) + * mocha (2.3.4) + * supertest (1.1.0) + * dhcpjs (^0.5.0) + * [debugfs](https://github.com/piranna/DebugFS) + * async (^1.5.0) + * *[forever](https://github.com/piranna/forever/tree/starter)* + * *[forever-monitor](https://github.com/piranna/forever-monitor)* + * [genext2fs](https://github.com/NodeOS/genext2fs) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/genext2fs/branches/master/badge.svg)](https://semaphoreci.com/nodeos/genext2fs) + * prebuild-install (1.0.2) + * prebuild (^4.2.2) + * [ifconfig](https://github.com/NodeOS/ifconfig) + * *src-sockios* + * [src-ifaddrs](https://github.com/NodeOS/node-src-ifaddrs) + * nan (^2.0.9) + * [src-errno](https://github.com/NodeOS/node-src-errno) + * nan (^2.0.9) + * [ip](https://github.com/NodeOS/ip) + * *src-sockios* + * loadtest (^1.4.3) + * [logon](https://github.com/piranna/logon) + [![Build Status](https://travis-ci.org/piranna/logon.svg?branch=master)](https://travis-ci.org/piranna/logon) + * colors (^1.1.2) + * kexec (^2.0.2) + * posix (^4.0.0) + * prompt (^1.0.0) + * mocha (^2.4.5) + * mocha-eslint (^2.0.2) + * [node-bin-getty](https://github.com/NodeOS/node-bin-getty) + * [src-unistd](https://github.com/NodeOS/node-src-unistd) + * nan (^2.0.9) + * [src-termios](https://github.com/NodeOS/node-src-termios) + * nan (^2.0.9) + * [node-wget](https://github.com/tylerl0706/wgetjs) + [![NPM version](https://badge.fury.io/js/wgetjs.png?branch=master)](http://badge.fury.io/js/wgetjs) + [![Build Status](https://travis-ci.org/angleman/wgetjs.png?branch=master)](https://travis-ci.org/angleman/wgetjs) + [![Dependency Status](https://gemnasium.com/angleman/wgetjs.png?branch=master)](https://gemnasium.com/angleman/wgetjs) + [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](#licensemit) + * request (~2.27.0) + * license-md (~0.2.5) + * grunt (~0.4.1) + * grunt-bump (~0.0.11) + * grunt-license (~0.1.4) + * mocha (~1.12.0) + * should (~1.2.2) + * *nodeos-nodejs* + * [nodeos-reverse-proxy](https://github.com/piranna/nodeos-reverse-proxy) + [![Build Status](https://travis-ci.org/piranna/nodeos-reverse-proxy.svg?branch=master)](https://travis-ci.org/piranna/nodeos-reverse-proxy) + * basic-auth (^1.0.4) + * concat-stream (^1.5.1) + * finalhandler (^0.5.0) + * http-proxy (^1.14.0) + * kexec (^2.0.2) + * posix (^4.0.2) + * uuid (^2.0.2) + * mocha (^2.5.3) + * supertest (^1.2.0) + * npm (^3.9.6) + * [nsh](https://github.com/piranna/nsh) + [![Build Status](https://travis-ci.org/piranna/nsh.svg?branch=master)](https://travis-ci.org/piranna/nsh) + [![Coverage Status](https://coveralls.io/repos/github/piranna/nsh/badge.svg?branch=master)](https://coveralls.io/github/piranna/nsh?branch=master) + * array-flatten (^2.1.0) + * async (^2.0.1) + * decode-prompt (^0.0.2) + * glob (~7.0.5) + * [lib-pathcomplete](https://github.com/piranna/node-lib-pathcomplete) + * glob (~7.0.5) + * pathchop (0.0.0) + * *[lib-pathsearch](https://github.com/piranna/node-lib-pathsearch)* + * mkdirp (~0.5.1) + * mkfifo (^0.1.5) + * npm-path (^2.0.2) + * shell-parse (^0.0.2) + * to-string-stream (^0.1.0) + * uuid (^2.0.2) + * concat-stream (^1.5.1) + * *easy-coveralls* + * mocha (^2.5.3) + * string-to-stream (^1.1.0) + * ntp-client (^0.5.3) + * performance (^1.1.0) + * [pstree](https://github.com/piranna/pstree) + * archy (^1.0.0) + * async (^1.5.2) + * scanf (^0.7.2) + * slap (^0.1.60) + * *qemu* + +# Common packages +* [download-manager](https://github.com/piranna/download-manager) + [![Build Status](https://travis-ci.org/piranna/download-manager.svg?branch=master)](https://travis-ci.org/piranna/download-manager) + [![Coverage Status](https://coveralls.io/repos/github/piranna/download-manager/badge.svg?branch=master)](https://coveralls.io/github/piranna/download-manager?branch=master) + * async (^2.0.1) + * [bzip2-maybe](https://github.com/piranna/bzip2-maybe) + [![build status](http://img.shields.io/travis/piranna/bzip2-maybe.svg?style=flat)](http://travis-ci.org/piranna/bzip2-maybe) + [![Coverage Status](https://coveralls.io/repos/github/piranna/bzip2-maybe/badge.svg?branch=master)](https://coveralls.io/github/piranna/bzip2-maybe?branch=master) + * is-bzip2 (^1.0.0) + * peek-stream (^1.1.1) + * pumpify (^1.3.5) + * through2 (^2.0.1) + * unbzip2-stream (^1.0.9) + * concat-stream (^1.5.1) + * *easy-coveralls* + * standard (^8.0.0-beta.5) + * tape (^4.6.0) + * diff + * [download-checksum](https://github.com/piranna/download-checksum) + [![Build Status](https://travis-ci.org/piranna/download-checksum.svg?branch=master)](https://travis-ci.org/piranna/download-checksum) + [![Coverage Status](https://coveralls.io/repos/github/piranna/download-checksum/badge.svg?branch=master)](https://coveralls.io/github/piranna/download-checksum?branch=master) + * inherits (^2.0.1) + * openpgp (^2.3.2) + * force-array (^3.1.0) + * got (^6.3.0) + * gunzip-maybe (^1.3.1) + * multi-progress (^2.0.0) + * pump (^1.0.1) + * rimraf (^2.5.4) + * strip-dirs (^2.0.0) + * tar-fs (^1.13.0) + * *easy-coveralls* + * mocha (^3.0.2) + * nock (^8.0.0) + * tmp (0.0.28) +* [nodeos-nodejs](https://github.com/NodeOS/nodejs) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/nodejs/branches/master/badge.svg)](https://semaphoreci.com/nodeos/nodejs) + * prebuild-install (1.0.2) + * [buho](https://github.com/piranna/buho) + [![Build Status](https://travis-ci.org/piranna/buho.svg?branch=master)](https://travis-ci.org/piranna/buho) + [![Coverage Status](https://coveralls.io/repos/github/piranna/buho/badge.svg?branch=master)](https://coveralls.io/github/piranna/buho?branch=master) + * concat-stream (^1.5.1) + * *[github-basic](https://github.com/piranna/github-basic)* + * github-from-package (0.0.0) + * github-url-to-object (^2.2.3) + * minimist (^1.2.0) + * *easy-coveralls* + * mocha (^2.5.3) + * nock (^8.0.0) + * prebuild (^4.2.2) + * *[publish](https://github.com/piranna/node-publish)* +* [qemu](https://github.com/NodeOS/qemu) + [![Build Status](https://semaphoreci.com/api/v1/nodeos/qemu/branches/master/shields_badge.svg)](https://semaphoreci.com/nodeos/qemu) + * prebuild-install (1.0.2) + * prebuild (^4.2.2) +* [src-sockios](https://github.com/NodeOS/sockios) + * nan (^2.0.9) +* [easy-coveralls](https://github.com/piranna/easy-coveralls) + [![Build Status](https://travis-ci.org/piranna/easy-coveralls.svg?branch=master)](https://travis-ci.org/piranna/easy-coveralls) + [![Coverage Status](https://coveralls.io/repos/github/piranna/easy-coveralls/badge.svg?branch=master)](https://coveralls.io/github/piranna/easy-coveralls?branch=master) + * coveralls (^2.11.11) + * fs-extra (^0.30.0) + * *[jscoverage](https://github.com/piranna/jscoverage)* + * mocha-lcov-reporter (^1.2.0) diff --git a/docs/en/README.md b/docs/en/README.md new file mode 100644 index 000000000..77948463b --- /dev/null +++ b/docs/en/README.md @@ -0,0 +1,25 @@ +NodeOS + +# What is NodeOS? + +NodeOS is a lightweight operating system using Node.js as userspace. NodeOS is an operating system built entirely in Javascript and using npm as it's package manager. Any package in npm is a NodeOS package, which at last count was 244,180 packages. The goal of NodeOS is to provide just enough to let npm provide the rest. Since anyone can contribute to npm, anyone can create NodeOS packages. + +**Quick links:** [[Getting Started]] | [[Building From Source](./building_from_source.md)] + +## Contributors + +Here are some great people who have helped NodeOS in some significant way. In no particular order: + +- [David Xu](https://twitter.com/dvdxu) (Early website, testing, and adoption) +- [Forrest Norvell](https://twitter.com/othiym23) (NodeOS on Raspberry Pi) +- [Max Ogden](https://twitter.com/maxogden) (Docker testing, deploy, and evangelizing) +- [Max Bernstein](https://github.com/tekknolagi) (Crazy asm madness and docker testing) +- [Jake Verbaten](https://github.com/raynos) (Giving the wiki a push) +- [Jesús Leganés Combarro](https://github.com/piranna) (In depth discussions) +- [Adam Ulvi](https://github.com/aulvi) (for taking charge of #node-os on irc) +- [Philipp Czarnetzki](https://github.com/luii) (Updating the Wiki) +- [Lite20](https://twitter.com/lightningboy24) (Wiki Maintainer) + +Everyone above is awesome! + + diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md new file mode 100644 index 000000000..8f07f60cd --- /dev/null +++ b/docs/en/SUMMARY.md @@ -0,0 +1,8 @@ +# Summary + +* [Introduction](README.md) +* Contribution Guide +* [Building From Source](building_from_source.md) +* System Modules +* Additional Modules + diff --git a/docs/en/Service-Starter-(PalmTree).md b/docs/en/Service-Starter-(PalmTree).md new file mode 100644 index 000000000..9420d8387 --- /dev/null +++ b/docs/en/Service-Starter-(PalmTree).md @@ -0,0 +1,26 @@ +# PalmTree, the NodeOS Service Starter # +_REPOSITORY:_ [https://github.com/lite20/palmtree](https://github.com/lite20/palmtree) + +_NPM MODULE:_ [https://www.npmjs.com/package/palmtree](https://www.npmjs.com/package/palmtree) + +## Introduction ## +Sometimes we need scripts, or services to launch on startup. This is a remarkably easy task in NodeOS. +The startup program launcher on NodeOS is called PalmTree. PalmTree uses a simple .json file in the /etc/ folder called "palmtree.json". In this file, which we will refer to as the palmtree, is simply a JSON encoded array of objects. Each object contains at minimum the command to execute. Additionally, you may specify a name, or arguments to go along. Let's take a look at an example palmtree. + +`[ + { + "command": "plexdl", + "name": "PlexDL", + "args": ['beta-gui'] + } +]` + +As you can see, a command is specified, a name for the program, and an argument. Only the command is necessary. +On startup, with this palmtree, PalmTree would run the command "plexdl" with the argument "-beta-gui" and if there were any issues, it would report them and refer to the command as "PlexDL". + +## Adding or Removing Commands ## +### Manually ### +To add or remove scripts/services from startup, simply remove the object from your palmtree. A graphical GUI is underworks to allow you to do this easily. + +### Programatically ### +To add or remove scripts/services from startup programatically, the palmtree.json file is a perfectly formatted JSON file. In NodeJS, you can use `require` to load it, or use the fs module and JSON parse it. Then make your adjustments, be it adding or removing a program, then re-serialize the JSON object and write it back to the file. \ No newline at end of file diff --git a/docs/en/building_from_source.md b/docs/en/building_from_source.md new file mode 100644 index 000000000..48bc6d6b3 --- /dev/null +++ b/docs/en/building_from_source.md @@ -0,0 +1,128 @@ +**Note: This document has not yet been revised.** +# Building From Source + +## Step 1: Prerequisites + +- **Git**. To install using: + + - for **Debian/Ubuntu**: `apt-get install git` + - for **Arch**: `pacman -S git` + +- Node 4.x +- NPM 2.x + +**_Note: If you're using Node 5.x and NPM 3.x, the build process will crash, further Information under [[Troubleshooting]] or Issue #218_** + +After you installed the prerequisites just clone the repository + +```bash +$ git clone https://github.com/NodeOS/NodeOS.git +``` + +## Step 2 (Debian/Ubuntu): Dependencies + +Once you've installed the prerequisites you need the dependencies for Debian/Ubuntu using `apt-get`. First you need to update your cache. To do so run + +```bash +$ dpkg --add-architecture i386 +$ apt-get -qq -y update +``` + +Then you install the dependencies listed below + +- cross compiler dependencies: `apt-get -qq -y gcc g++ realpath texinfo` +- barebones dependencies: `apt-get -qq -y bc libpixman-1-dev` +- rootfs dependencies: `apt-get -qq -y genisoimage libuuid:i386` +- userfs dependencies: `apt-get -qq -y autoconf automake` +- qemu dependencies: `apt-get -qq -y libsdl1.2-dev` + +Or as a one liner: + +```bash +$ apt-get -qq -y gcc g++ realpath texinfo bc libpixman-1-dev genisoimage libuuid:i386 autoconf automake libsdl1.2-dev +``` + +Or just run if you're outside the folder + +```bash +$ cd NodeOS/ +$ bin/install-debian-deps +``` + +## Step 2 (Arch Linux): Dependencies + +Once you have installed the prerequisites you need the dependencies for Arch Linux + +- cross compiler dependencies: `pacman -S gcc texinfo python2` +- barebones dependencies: `pacman -S bc pixman lib32-pixman` +- rootfs dependencies: `pacman -S cdrkit` +- initramfs dependencies: `pacman -S cpio` +- userfs dependencies: `pacman -S autoconf automake` +- qemu dependencies: `pacman -S sdl` + +**_Note: The initramfs dependencies are not shipped with the installation of Arch Linux thats why we need to install them on Arch Linux_** + +Or as one liner: + +```bash +$ pacman -S gcc texinfo python2 bc pixman lib32-pixman cdrkit cpio autoconf automake sdl +``` + +Or just run if you're outside the folder + +```bash +$ cd NodeOS/ +$ bin/install-arch-deps +``` + +## Step 3: Installation + +Once you've installed the correct dependencies for your operating system you can start with the installation of NodeOS. + +**_Note: If you have Arch Linux you need to set python2 as default binary when you run `python`. Because the standard python binary is python3 and nodegyp doesn't uses it._** To do this, run following commands: + +```bash +$ cd /usr/bin +$ ln -sf python2 python +``` + +The next step is to install the npm dependencies and the bundled dependencies to do this run following command: + +```bash +$ npm install +``` + +If you want to change the target platform to build NodeOS for, just prepend the `PLATFORM` argument before `npm install`. Example (NodeOS for QEMU 32bit): + +```bash +$ PLATFORM=qemu_32 npm install +or +$ PLATFORM=docker npm install +``` + +Now it should install correctly. This process can take some time, so pick some microwave pop-corn and go to see a movie. No, really... do it. + +## Step 4: Run your fresh NodeOS build + +Now you can run your fresh build with: + +```bash +$ npm start +``` + +If NodeOS does not boot into the REPL, unless you wanted that, then everything was compiled correctly. **If not look under [[Troubleshooting]]** + +After NodeOS has booted up you should see something like: + +``` +Hello! I'm a user init script :-) +``` + +Now you're prompted to enter your username and password. By default, the username and password is `nodeos` and cannot be changed without altering code. + +``` +$ username: nodeos +$ password: nodeos +``` + +**Note: This is not permanent on later versions this will be changed** diff --git a/docs/en/nsh/Commands.md b/docs/en/nsh/Commands.md new file mode 100644 index 000000000..fa773ab4e --- /dev/null +++ b/docs/en/nsh/Commands.md @@ -0,0 +1,31 @@ +# Commands + +This site describes all available Commands in NodeOS. At the moment there are not many commands but they can be extended by NPM Or you create your own commands. + +This list is helpful for Linux beginners, on the list below you find the Name and the description for the corresponding command. + +## List of Commands + +- `cat` - is one of the most frequently used commands on Unix-like operating systems. It has three related functions with regard to text files: displaying them, combining copies of them and creating new ones. +- `cp` - is an internel command of a unix shell to copy files. +- `davius` - Davius is a HTTP/WebDAV server that offer the content from the filesystem. +- `env` - is a unix command, that shows the environment variables when called with no arguments or it starts a program in another environment without changing the variables of the active one. +- `ln` - is a standard Unix command utility used to create a hard link (link) or a symbolic link (symlink) to an existing file. +- `ls` - is a command to list files in Unix and Unix-like operating systems. +- `man` - is used to format and display man (or manual) pages +- `mkdir` - is used to create a new folder +- `mv` - is used to move files or folders +- `node` - This is the node binary +- `npm` - is NodeOS's package Manager (like: pacman (Arch); yaourt (Arch); apt-get (Debian/Ubuntu)) +- `nsh` - is the shell of NodeOS (both "no shell" and "node shell" accurately describe nsh) +- `pwd` - Returns the current working directory +- `rm` - is a basic UNIX command used to remove objects such as files, directories, device nodes, symbolic links, and so on from the filesystem. +- `sh` - is a command language interpreter that shall execute commands read from a command line string, the standard input, or a specified file. +- `wget` - is a computer program that retrieves content from web servers. +- `ip` - The `ip` command is similar to ifconfig, but more powerful and is intented to be a replacement for it. +- `ifconfig` - stands for "interface configuration". It is used to view and change the configuration of the network interfaces on your system. +- `pstree` - pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. +- `performance` - is a benchmark tool to check the speed of some (javascript?) functions +- `loadtest` - Runs a load test on the selected HTTP or WebSockets URL. +- `testserver-loadtest` - This command will show the number of requests received per second, the latency in answering requests and the headers for selected requests. +- `node-ntp-client` - This binary implements the NTP Protocol which gets the Network time over a specific Server (like 'pool.ntp.org') diff --git a/docs/en/nsh/README.md b/docs/en/nsh/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/es/README.md b/docs/es/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/es/SUMMARY.md b/docs/es/SUMMARY.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/fr/README.md b/docs/fr/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/fr/SUMMARY.md b/docs/fr/SUMMARY.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/help.md b/docs/help.md new file mode 100644 index 000000000..4b3c27688 --- /dev/null +++ b/docs/help.md @@ -0,0 +1,2 @@ +The `help` command will be there to guide people through node-os. +This is a lot less like `man` and more like a http://nodeschool.io lesson. diff --git a/docs/init.md b/docs/init.md new file mode 100644 index 000000000..545151886 --- /dev/null +++ b/docs/init.md @@ -0,0 +1,27 @@ +Init *will* be a super-simple process. + +1. periodically reap dead children +2. start the root service manager [[asgard]] + +## zombies + +The way Linux works, +when a parent process dies it's children become children of PID 1. +When those children exit, +their PID number and exit status are recorded in the kernels process table. +The parent, in this case init, +needs to periodically call `wait` or `waitpid` to clear the process table. +Processes which have exited but have not been cleared are called **zombies**. + +You don't want too many zombies. + +Init will inherit a lot of children, +and when they die it needs to stop the zombie apocalypse. + +## service manager + +We want to keep init simple. +Once init is up and ready to be the grim reaper, +it needs to pass control to someone else. + +The service manager [[asgard]] is what launches all the interesting processes on the system. diff --git a/docs/product.md b/docs/product.md new file mode 100644 index 000000000..d14129f6d --- /dev/null +++ b/docs/product.md @@ -0,0 +1,98 @@ +Let's define some terminology used for this project. + +1. The **technology** is the clever abstraction. + It is performant, modularized, and flexible. + You need a mental model present to work with a technology, + but once it's in place you can do a lot. + + Unfortunately technology doesn't sell. + Technology is necessary, but it is not the end goal. +2. The **product** is the human face on technology. + It is specific, and focused. + If often uses only one aspect of a technology, + but it solves a real human problem. + + Designing a product is harder than designing a technology. + Smart people find products hard to design, + because products are all about compromise. + +Node-os is *both* a technology and a product, +so it's important to understand which part we're talking about at any given time. +For example: + +- [[asgard]] and [[init]] are a technologies, + they are clever abstractions that makes building + certain os-related products easier. +- [[npkg]] is a product. + It's designed to meet a human need, + and not require a lot of foreknowledge to use. +- [[help]] is a product. In many ways `help` should be the ambassador for the system. + Help is not `man` or `info`. It is not exhaustive; it is focused. + The `help` command focuses on guiding people through the system. +- A few things like the [[FileSystem]] are hybrids of technology and product. + We move things around to technically organize the system, + but we don't want the file system to seem foreign to users. + +## the product experience + +What should a users first experience with node-os be like? + +> users should want to have the node-os experience everywhere + +To that end, we want `npkg` to be the gateway to a users first experience. +It should quickly facilitate + +1. installing packages +2. running services +3. discovering packages +4. giving helpful feedback + +Where (4) may be most important. +There will not be an engineer standing over the should of most people's first +node-os experience. +You should be able to use node-os from the command line experience alone. + +### first experience + +What do we want the first experience to look like? *(let's improve on this)* + +```bash +welcome to node-os + +type help to get started + +$ +``` + +Typing `help` should display + +```bash +Try the following + + 1. help npkg learn about the npkg command + 2. help home learn about your home directory + +$ +``` + +Ideas + +1. make `help` stateful, so it can offer you conextual help + +### ongoing experience + +Why are people using node-os, and what problems are they trying to solve? +Answering these quesitons are important to creating a product that people will want to use. + +#### vanilla + +1. people want to run their node app quickly, without fussing around with init config files +2. people want to configure a system consistently without puppet/chef or other config-management tools + +#### wild + +1. people want to write a distributed file system with leveldb and http + +#### ultimate + +1. people want to do tcp/ip parsing in user-space with javascript diff --git a/docs/root.md b/docs/root.md new file mode 100644 index 000000000..2398b58e5 --- /dev/null +++ b/docs/root.md @@ -0,0 +1,34 @@ +The root user is like any other [user directory](FileSystem#user-directories) +but it's also in charge of booting the system. + +``` +/root/ + bin/ + init <-- boots the system + asgard <-- service manager started by init + lib/ <-- installed node_modules for init/asgard + log/ <-- log files from init and other root services + var/ <-- persistent data for root services +``` + +The root directory at minimum needs the above, but will likely contain other modules helpful to booting the system. + +## the kernel and init + +During boot after the kernel has loaded, +it passes control to another process typically called the *init process*. +The init process has PID 1, and *must* start the rest of the system. +If init fails to boot the rest of the system, +the kernel either panics or your box does nothing interesting. + +Typically on Linux init is located at `/sbin/init`. +In you don't specify where your init process is, +the kernel will automatically look in that spot. +During boot however any other process can be booted as your PID 1. +This is done by passing the kernel an `INIT=` argument on startup. + +On node-os there is no process at `/sbin/init`. +Instead our init command is simply an executable installed to `/root/bin/`. +Init is a node module, with a `bin` key in it's `package.json` file. +Any node module can be the node-os init, +but we try to provide a very useful, but minimal, init module. diff --git a/docs/services.md b/docs/services.md new file mode 100644 index 000000000..5378d66bd --- /dev/null +++ b/docs/services.md @@ -0,0 +1,26 @@ +Services are long-running processes that provide utility to the system. +Common services you might find on a Linux system are + +- `sshd` for ssh access +- `dhcpd` to set the IP address at boot +- `getty` for connecting the console to a login session +- `ntpd` for setting the time from the network + +These services are generally *automated* and *long running*. +Let's itemize the actual requirements of a service. + +1. services can be started at boot automatically +2. services should make an effort to retry on failure +3. users should be able to start services at runtime +4. services should survive a user logging out + +The above are standard for almost every service manager today. +Typically [[init]] or another service manager handles system services. + +- Mac OS X uses `launchd` +- Ubuntu uses `upstard` +- RHEL uses `systemd` +- Windows uses ? +- SmartOS uses `SMF` + +NodeOS uses PalmTree as it's service starter. You can read more about working with it here on the wiki (see [[Service Starter|Service Starter (PalmTree)]]) and explore it's [repository](https://github.org/lite20/palmtree) too. \ No newline at end of file diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 000000000..3be958503 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,161 @@ +/** + * NodeOS + * + * @copyright 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' + * and other contributors + * + * @license MIT + */ + +const fs = require('fs') +const join = require('path').join +const spawnSync = require('child_process').spawnSync + +const processArguments = require('nodeos-barebones/scripts/processArguments') + + +function checkKvm(qemuBin) +{ + let contents = "" + + try + { + contents = fs.readFileSync('/proc/cpuinfo') + } catch(e){ + if(e.code !== 'ENOENT') throw(e) + + return false + } + + if(! /(vmx|svm|0xc0f)/.test(contents)) return false + + // We have support for KVM, let's see if QEmu has permissions to use it + try + { + spawnSync(qemuBin, ['-nographic'], {timeout: 1000}) + } catch(e){ + return true + } +} + + +function prepareCommandLine(argv, output) +{ + const args = processArguments(argv) + const link = fs.readlinkSync('out/latest').split('/') || [] + + const cpu_family = args.cpu_family || link[link.length-3] + const machine = args.machine || link[link.length-2] + const platform = args.platform || link[link.length-1] + + const cpu = args.cpu + + let command = 'qemu-system-'+cpu_family + + argv = + [ + '-machine', machine, + '-m', '256M', + '-vga', 'std', + '-net', 'nic', + '-net', 'user,id=eth0,hostfwd=tcp::50080-:80', + '-net', 'user,id=eth1,hostfwd=tcp::50443-:443' + ] + + switch(output) + { + case 'curses' : argv.push('-curses') ; break + case 'nographic': argv.push('-nographic'); break + } + + // check if kvm is supported + let timeout_rate = 1 + + function qemuKvm() + { + if(checkKvm(command)) + { + argv.push('-enable-kvm') + timeout_rate = 0.1 + } + } + + // CWD + const cwd = join('out', cpu_family, machine, platform) + + switch(platform) + { + case 'disk': + qemuKvm() + + argv.push('-hda', 'disk.img') + break + + case 'docker': + command = 'docker' + argv = + [ + 'run', '-it', + '--cap-add', 'SYS_ADMIN', + '--security-opt=apparmor:unconfined', + '--device', '/dev/fuse', + 'nodeos/nodeos', + // '-v', 'usersfs:/tmp' + ] + break + + case 'img': + qemuKvm() + + argv.push('-hda', 'bootfs.img', + '-hdb', 'usersfs.img') + break + + case 'iso': + qemuKvm() + + argv.push('-cdrom', 'bootfs.iso', + '-hda' , 'usersfs.img') + break + + case 'qemu': + qemuKvm() + + const append = + [ + 'root=/dev/sda', + 'ip=dhcp' + ] + + switch(output) + { + case 'nographic': + append.push('console=ttyS0') // redirect to terminal + break + + case 'curses': + append.push('vga=extended') // 80x50 + break + + default: + append.push('vga=0x344') // 1024x768x32 + } + + argv.push('--kernel', 'kernel', + '--initrd', 'initramfs.cpio.gz', + '-drive', `file=usersfs.img,format=raw,index=0`, + '-append', append.join(' ')) + break + + case 'tar': + case 'vagga': break + + default: + throw 'Unknown platform "'+platform+'"' + } + + return {command, argv, cwd, platform, timeout_rate} +} + + +module.exports = prepareCommandLine diff --git a/package.json b/package.json index 9abba370f..38084a2f4 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,15 @@ { "name": "NodeOS", - "version": "1.0.0-RC2", + "version": "1.0.0-RC3", "description": "Lightweight operating system using Node.js as userspace", + "main": "lib", "scripts": { "BigRedButton": "scripts/BigRedButton", - "docker": "scripts/docker", "dockerBuild": "scripts/dockerBuild", + "dockerClean": "docker volume rm $(docker volume ls -qf dangling=true) || exit 0", "build": "scripts/build", "postbuild": "scripts/postbuild", + "postinstall": "scripts/postinstall", "publish": "scripts/publish", "start": "scripts/start", "test": "scripts/test", @@ -33,19 +35,18 @@ "homepage": "http://node-os.com", "private": true, "dependencies": { - "nodeos-barebones": "NodeOS/nodeos-barebones", - "nodeos-cross-toolchain": "NodeOS/nodeos-cross-toolchain", + "nodeos-barebones": "^1.0.0-RC3.1", "nodeos-initramfs": "NodeOS/nodeos-initramfs", - "nodeos-rootfs": "NodeOS/nodeos-rootfs", "nodeos-usersfs": "NodeOS/nodeos-usersfs" }, "devDependencies": { + "cpio2tar": "^0.0.5", + "minimist": "^1.2.0", + "nodeos-bootfs": "NodeOS/nodeos-bootfs", + "nodeos-cross-toolchain": "^1.0.0-RC3.1", "prebuild": "piranna/prebuild#prerelease", - "qemu": "NodeOS/qemu", - "suppose": "^0.6.1" - }, - "engines": { - "node": "^0.12.0", - "npm": "^3.0.0" + "qemu": "^2.9.0", + "suppose": "jprichardson/node-suppose", + "tar2ext": "^0.0.2" } } diff --git a/resources/Dockerfile b/resources/Dockerfile new file mode 100644 index 000000000..800c32a70 --- /dev/null +++ b/resources/Dockerfile @@ -0,0 +1,19 @@ +# Autogenerated by `npm run dockerBuild` + +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +FROM nodeos/initramfs + +MAINTAINER Jesús Leganés Combarro 'piranna' + +VOLUME /tmp +ADD usersfs.tar.gz /tmp/ + +ENV root container + +ENTRYPOINT ["/init"] diff --git a/Dockerfile b/resources/Dockerfile-initramfs similarity index 50% rename from Dockerfile rename to resources/Dockerfile-initramfs index 3bf3a283f..fb1ebf4e2 100644 --- a/Dockerfile +++ b/resources/Dockerfile-initramfs @@ -1,5 +1,9 @@ -FROM rootfs +# Autogenerated by `npm run dockerBuild` + +FROM nodeos/barebones MAINTAINER Jesús Leganés Combarro 'piranna' +ADD initramfs.tar.gz / + ENTRYPOINT ["/init"] diff --git a/resources/palmtree.json b/resources/palmtree.json new file mode 100644 index 000000000..9845d58de --- /dev/null +++ b/resources/palmtree.json @@ -0,0 +1,12 @@ +[ + { + "command": "/bin/logon", + "minUptime": 2000, + "enabled": true + }, + { + "command": "/bin/nodeos-reverse-proxy", + "minUptime": 2000, + "enabled": true + } +] diff --git a/resources/runners/README.md b/resources/runners/README.md index 710b3c512..f9140bbd4 100644 --- a/resources/runners/README.md +++ b/resources/runners/README.md @@ -1,6 +1,30 @@ + + +# NodeOS This zip file host a pre-build NodeOS instance with a demo users filesystem, you can find info about how to build your own users filesystem at [NodeOS-usersfs](node_modules/nodeos-usersfs/README.md) package. -To run this demo, simply exec the ```run.sh``` script. You'll need to have -[QEmu](http://wiki.qemu.org/Main_Page) installed. +## Getting started +This pre-build requires [QEmu](http://wiki.qemu.org/Main_Page). +Please make sure that it's installed. + +To run this demo, simply exec the ```run.sh``` script in the root directory. + +You should be greeted by the NodeOS-usersfs. +It will ask you for a username and a password. +``` +$ username: nodeos +$ password: nodeos +``` +If you run into trouble, please checkout the [troubleshooting here](https://github.com/NodeOS/NodeOS/wiki/Troubleshooting) + +## What now? +When you have NodeOS up and running you should take a look at the [commands](https://github.com/NodeOS/NodeOS/wiki/Commands) diff --git a/resources/runners/README_docker.md b/resources/runners/README_docker.md new file mode 100644 index 000000000..ad3004f06 --- /dev/null +++ b/resources/runners/README_docker.md @@ -0,0 +1,28 @@ + + +#NodeOS +This zip file host a pre-build NodeOS instance with a demo users filesystem, you +can find info about how to build your own users filesystem at +[NodeOS-usersfs](node_modules/nodeos-usersfs/README.md) package. + +## Getting started +You'll need to have [Docker](https://www.docker.com) installed. + +To run this demo, simply exec the ```run.sh``` script in the root directory. + +You should be greeted by the NodeOS-usersfs. +It will ask you for a username and a password. +``` +$ username: nodeos +$ password: nodeos +``` +If you run into trouble, please checkout the [troubleshooting here](https://github.com/NodeOS/NodeOS/wiki/Troubleshooting) +## What now? +When you have NodeOS up and running you should take a look at the [commands](https://github.com/NodeOS/NodeOS/wiki/Commands) diff --git a/resources/runners/README_iso.md b/resources/runners/README_iso.md new file mode 100644 index 000000000..1c934e8cc --- /dev/null +++ b/resources/runners/README_iso.md @@ -0,0 +1,42 @@ + + +# NodeOS +This zip file host a pre-build NodeOS instance with a demo users filesystem, you +can find info about how to build your own users filesystem at +[NodeOS-usersfs](node_modules/nodeos-usersfs/README.md) package. + +## Getting started +This pre-build requires [QEmu](http://wiki.qemu.org/Main_Page). +Please make sure that it's installed. + +To run this demo, simply exec the ```run.sh``` script in the root directory. + +You should be greeted by the NodeOS-usersfs. +It will ask you for a username and a password. +``` +$ username: nodeos +$ password: nodeos +``` +If you run into trouble, please checkout the [troubleshooting here](https://github.com/NodeOS/NodeOS/wiki/Troubleshooting) + +## Burning to CD or USB +This is the ISO release, so it can be burned to a CD-R or a USB flashdrive. +However it will run as readonly which means everything is handled in memory and it will be +lost on shutdown. + +You can use the script `installUSB`, which will automatically create a read/write filesystem. +You must provide the script with the device to write to, the rootfs and the usersfs files. + +*Tip: run the script with no arguments for the usage* + +The script will use the remaining space on the USB drive for the filesystem. + +## What now? +When you have NodeOS up and running you should take a look at the [commands](https://github.com/NodeOS/NodeOS/wiki/Commands) diff --git a/resources/runners/README_vagga.md b/resources/runners/README_vagga.md index ac859d6ec..b732cd3c8 100644 --- a/resources/runners/README_vagga.md +++ b/resources/runners/README_vagga.md @@ -1,6 +1,28 @@ + + +#NodeOS This zip file host a pre-build NodeOS instance with a demo users filesystem, you can find info about how to build your own users filesystem at [NodeOS-usersfs](node_modules/nodeos-usersfs/README.md) package. -To run this demo, simply exec ```vagga run```. You'll need to have -[vagga](https://github.com/tailhook/vagga) installed. +## Getting started +You'll need to have [vagga](https://github.com/tailhook/vagga) installed. + +To run this demo, simply exec ```vagga run``` in the root directory. + +You should be greeted by the NodeOS-usersfs. +It will ask you for a username and a password. +``` +$ username: nodeos +$ password: nodeos +``` +If you run into trouble, please checkout the [troubleshooting here](https://github.com/NodeOS/NodeOS/wiki/Troubleshooting) +## What now? +When you have NodeOS up and running you should take a look at the [commands](https://github.com/NodeOS/NodeOS/wiki/Commands) diff --git a/resources/runners/disk.sh b/resources/runners/disk.sh new file mode 100644 index 000000000..b24072522 --- /dev/null +++ b/resources/runners/disk.sh @@ -0,0 +1,28 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +while [ ! $# -eq 0 ] +do + case "$1" in + --terminal | -t) + QEMU="$QEMU -nographic" + ;; + esac + shift +done + +grep -q -e "vmx" -e "svm" /proc/cpuinfo +if [ $? -eq 0 ]; then + QEMU="$QEMU -enable-kvm" +fi + +$QEMU \ + -vga std \ + -m 256M \ + -redir tcp:50080::80 \ + -redir tcp:50443::443 \ + -hda disk.img diff --git a/resources/runners/docker.sh b/resources/runners/docker.sh new file mode 100644 index 000000000..2b306f750 --- /dev/null +++ b/resources/runners/docker.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +docker import barebones.tar.gz nodeos/barebones +docker build -t nodeos/initramfs . + +docker run -it \ + --cap-add SYS_ADMIN \ + --security-opt=apparmor:unconfined \ + --device /dev/fuse \ + nodeos/initramfs diff --git a/resources/runners/img.sh b/resources/runners/img.sh new file mode 100644 index 000000000..4c1a2f208 --- /dev/null +++ b/resources/runners/img.sh @@ -0,0 +1,29 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +while [ ! $# -eq 0 ] +do + case "$1" in + --terminal | -t) + QEMU="$QEMU -nographic" + ;; + esac + shift +done + +grep -q -e "vmx" -e "svm" /proc/cpuinfo +if [ $? -eq 0 ]; then + QEMU="$QEMU -enable-kvm" +fi + +$QEMU \ + -vga std \ + -m 256M \ + -redir tcp:50080::80 \ + -redir tcp:50443::443 \ + -hda bootfs.img \ + -hdb usersfs.img diff --git a/resources/runners/iso.sh b/resources/runners/iso.sh index 3e8069a11..23a7ada1b 100644 --- a/resources/runners/iso.sh +++ b/resources/runners/iso.sh @@ -1,3 +1,10 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + while [ ! $# -eq 0 ] do case "$1" in @@ -18,5 +25,5 @@ $QEMU \ -m 256M \ -redir tcp:50080::80 \ -redir tcp:50443::443 \ - -hda rootfs \ - -hdb usersfs + -cdrom bootfs.iso \ + -hda usersfs.img diff --git a/resources/runners/qemu.sh b/resources/runners/qemu.sh index beddb8820..a7dfeff92 100644 --- a/resources/runners/qemu.sh +++ b/resources/runners/qemu.sh @@ -1,3 +1,10 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + APPEND="root=/dev/sda ip=dhcp vga=0x344" while [ ! $# -eq 0 ] do @@ -15,12 +22,12 @@ if [ $? -eq 0 ]; then QEMU="$QEMU -enable-kvm" fi -$QEMU \ - -vga std \ - -m 256M \ - -redir tcp:50080::80 \ - -redir tcp:50443::443 \ - --kernel barebones \ - --initrd initramfs \ - -hda usersfs \ +$QEMU \ + -vga std \ + -m 256M \ + -redir tcp:50080::80 \ + -redir tcp:50443::443 \ + --kernel kernel \ + --initrd initramfs.cpio.gz \ + -hda usersfs.img \ -append "$APPEND" diff --git a/resources/runners/runner_header.sh b/resources/runners/runner_header.sh index fe32f6c20..6176fa074 100644 --- a/resources/runners/runner_header.sh +++ b/resources/runners/runner_header.sh @@ -1,3 +1,10 @@ #!/usr/bin/env sh +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + QEMU=qemu-system-$CPU_FAMILY diff --git a/resources/sfdisk.txt b/resources/sfdisk.txt deleted file mode 100644 index 0f8a332a2..000000000 --- a/resources/sfdisk.txt +++ /dev/null @@ -1,2 +0,0 @@ -$SIZE_MBR,$SIZE_ROOTFS,0C,* -$START_USERSFS,,, diff --git a/resources/vagga.yaml b/resources/vagga.yaml index a6c642c8a..aaf047cc9 100644 --- a/resources/vagga.yaml +++ b/resources/vagga.yaml @@ -1,3 +1,10 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + containers: NodeOS: setup: @@ -5,17 +12,21 @@ containers: url: ./barebones - !Tar url: ./initramfs - volumes: - /tmp: !BindRW ./usersfs + usersfs: + data-dirs: [/nodeos, /root] + setup: + - !Tar + url: ./usersfs commands: run: !Command description: Start NodeOS - container: NodeOS + container: bootfs + volumes: + /tmp: !Container usersfs environ: - PWD: / - root: '' +# PWD: / + root: 'container' pid1mode: exec run: [/init] -# run: /tmp/bin/logon write-mode: transient-hard-link-copy diff --git a/scripts/BigRedButton b/scripts/BigRedButton index c6e128596..290450d4a 100755 --- a/scripts/BigRedButton +++ b/scripts/BigRedButton @@ -1,10 +1,45 @@ #!/usr/bin/env bash +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License -PLATFORM=iso_32 npm run build --no-spin && npm test || exit 1 -PLATFORM=iso_64 npm run build --no-spin && npm test || exit 2 -PLATFORM=qemu_32 npm run build --no-spin || exit 3 -PLATFORM=qemu_64 npm run build --no-spin && npm test || exit 4 -#PLATFORM=raspberry npm run build --no-spin && npm test || exit 5 -PLATFORM=vagga_32 npm run build --no-spin && npm test || exit 6 -PLATFORM=vagga_64 npm run build --no-spin && npm test || exit 7 +# This script should generate all the possible build combinations of NodeOS and +# test them by being able to login and exec a Node.js REPL. In some cases This +# is not fully possible and so they should be improved in the future + + +BUILD="npm run build --no-spin" +DOCKER="npm run dockerBuild" +TEST="npm test" + + +eval MACHINE=pc PLATFORM=disk BITS=32 $BUILD && $TEST || exit 1 +eval MACHINE=pc PLATFORM=disk BITS=64 $BUILD && $TEST || exit 2 +eval MACHINE=pc PLATFORM=img BITS=32 $BUILD && $TEST || exit 3 +eval MACHINE=pc PLATFORM=img BITS=64 $BUILD && $TEST || exit 4 +eval MACHINE=pc PLATFORM=iso BITS=32 $BUILD && $TEST || exit 5 +eval MACHINE=pc PLATFORM=iso BITS=64 $BUILD && $TEST || exit 6 +eval MACHINE=pc PLATFORM=qemu BITS=32 $BUILD && $TEST || exit 7 +eval MACHINE=pc PLATFORM=qemu BITS=64 $BUILD && $TEST || exit 8 + +# Docket tests disabled because SemaphoreCI don't support OverlayFS (yet) +eval MACHINE=pc PLATFORM=docker BITS=32 $BUILD && $DOCKER || exit 9 +eval MACHINE=pc PLATFORM=docker BITS=64 $BUILD && $DOCKER || exit 10 +# eval MACHINE=pc PLATFORM=docker BITS=32 $BUILD && $DOCKER && $TEST || exit 9 +# eval MACHINE=pc PLATFORM=docker BITS=64 $BUILD && $DOCKER && $TEST || exit 10 + +# eval MACHINE=pc PLATFORM=tar BITS=32 $BUILD && $TEST || exit 11 +# eval MACHINE=pc PLATFORM=tar BITS=64 $BUILD && $TEST || exit 12 +# eval MACHINE=pc PLATFORM=vagga BITS=32 $BUILD && $TEST || exit 13 +# eval MACHINE=pc PLATFORM=vagga BITS=64 $BUILD && $TEST || exit 14 + +# eval MACHINE=raspi PLATFORM=disk $BUILD && $TEST || exit 15 +# eval MACHINE=raspi PLATFORM=img $BUILD && $TEST || exit 16 +# eval MACHINE=raspi PLATFORM=qemu $BUILD && $TEST || exit 17 +# eval MACHINE=raspi2 PLATFORM=disk $BUILD && $TEST || exit 18 +# eval MACHINE=raspi2 PLATFORM=img $BUILD && $TEST || exit 19 +# eval MACHINE=raspi2 PLATFORM=qemu $BUILD && $TEST || exit 20 diff --git a/scripts/build b/scripts/build index 7e74867a0..48871ad98 100755 --- a/scripts/build +++ b/scripts/build @@ -1,41 +1,244 @@ #!/usr/bin/env bash -TOOLCHAIN=`pwd`/node_modules/nodeos-cross-toolchain +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +set -o pipefail + + +while getopts ":k:p:" opt; do + case $opt in + k) + KERNEL="$OPTARG" # linux, netbsd, nokernel + ;; + + p) + PLATFORM="$OPTARG" # lxc, qemu, wsl + ;; + esac +done + + +# Default kernel and platform +if [[ -z "$KERNEL" ]]; then + KERNEL=linux +fi + +if [[ -z "$PLATFORM" ]]; then + PLATFORM=qemu +fi + + +TOOLCHAIN=`node -p "require('nodeos-cross-toolchain')"` +BAREBONES=`node -p "require('nodeos-barebones')"` +INITRAMFS=`node -p "require('nodeos-initramfs')"` +USERSFS=` node -p "require('nodeos-usersfs')"` source $TOOLCHAIN/scripts/adjustEnvVars.sh || exit $? +OUT_DIR=`pwd`/out/$CPU_FAMILY/$MACHINE/$PLATFORM + +export MACHINE + +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" + + # # Build each layer up # -( cd node_modules/nodeos-barebones ; npm run build ) && -( cd node_modules/nodeos-initramfs ; npm run build ) && -( cd node_modules/nodeos-rootfs ; npm run build ) && -( cd node_modules/nodeos-usersfs ; npm run build ) || err $? +( cd $BAREBONES && $NPMi ) && +( 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 # -OUT_DIR=`pwd`/out/$CPU_FAMILY/$PLATFORM -mkdir -p $OUT_DIR -case $PLATFORM in - *_qemu|docker|vagga) - cp node_modules/nodeos-barebones/out/latest $OUT_DIR/barebones - cp node_modules/nodeos-initramfs/out/latest $OUT_DIR/initramfs +BAREBONES=$BAREBONES/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-$SINGLE_USER || err 21 +} + +case $MACHINE in + pc) + case $PLATFORM in + disk) + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 30 + + nodeos-bootfs \ + -F $PLATFORM \ + -K $BAREBONES/bzImage \ + -I $INITRAMFS \ + -O $STEP_DIR/disk.img \ + -U $STEP_DIR/usersfs.img || err 31 + + rm -f $STEP_DIR/usersfs.img || err 32 + ;; + + docker) + copyAndConvertInitrams || exit $? + + # Docker already provides `/dev/console` by default + gunzip $STEP_DIR/barebones -c | \ + tar --delete dev/console | \ + gzip > $STEP_DIR/barebones.tar.gz || err 40 + + 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 + + gunzip $USERSFS -c | \ + tar --delete root/etc/palmtree.json > $STEP_DIR/usersfs.tar || err 43 + + tar -f $STEP_DIR/usersfs.tar -r root/etc/palmtree.json || err 44 + gzip -f $STEP_DIR/usersfs.tar || err 45 + + # Delete temporal initrams + rm -rf root $STEP_DIR/barebones $STEP_DIR/usersfs.tar || err 46 + ;; + + img) + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 50 + + nodeos-bootfs \ + -F $PLATFORM \ + -K $BAREBONES/bzImage \ + -I $INITRAMFS \ + -O $STEP_DIR/bootfs.img \ + -U $STEP_DIR/usersfs.img || err 51 + ;; + + iso) + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 60 + + nodeos-bootfs \ + -F $PLATFORM \ + -K $BAREBONES/bzImage \ + -I $INITRAMFS \ + -O $STEP_DIR/bootfs.iso \ + -U $STEP_DIR/usersfs.img || err 61 + ;; + + qemu) + cp $BAREBONES/bzImage $STEP_DIR/kernel || err 70 + cp $INITRAMFS $STEP_DIR/initramfs.cpio.gz || err 71 + + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 72 + ;; + + tar) + copyAndConvertInitrams || exit $? + + 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-$SINGLE_USER || err 82 + ;; + + vagga) + copyAndConvertInitrams || exit $? + + gunzip $STEP_DIR/barebones -c | \ + tar --delete dev/console sbin/init | \ + gzip > $STEP_DIR/barebones.tar.gz || err 90 + + mv $STEP_DIR/initramfs-$SINGLE_USER $STEP_DIR/initramfs.tar.gz || err 91 + + cp $USERSFS $STEP_DIR/usersfs.tar.gz || err 92 + + # Delete temporal initrams + rm -f $STEP_DIR/barebones || err 93 + ;; + + *) + echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" + err 100 + ;; + esac ;; - *_iso|*_img) - cp node_modules/nodeos-rootfs/out/latest $OUT_DIR/rootfs + raspi|raspi2|raspi3) + case $PLATFORM in + disk) + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 110 + + nodeos-bootfs \ + -D $BAREBONES/dts \ + -F $PLATFORM \ + -K $BAREBONES/zImage \ + -I $INITRAMFS \ + -O $STEP_DIR/disk.img \ + -U $STEP_DIR/usersfs.img || err 111 + + rm -f $STEP_DIR/usersfs.img || err 112 + ;; + + img) + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 120 + + nodeos-bootfs \ + -D $BAREBONES/dts \ + -F $PLATFORM \ + -K $BAREBONES/zImage \ + -I $INITRAMFS \ + -O $STEP_DIR/bootfs.img \ + -U $STEP_DIR/usersfs.img || err 121 + ;; + + qemu) + cp $BAREBONES/zImage $STEP_DIR/kernel || err 130 + + mkdir -p $STEP_DIR/dts && + cp -r $BAREBONES/dts/* $STEP_DIR/dts || err 131 + + cp $INITRAMFS $STEP_DIR/initramfs.cpio.gz || err 132 + + tar2ext $USERSFS nodeos 1 1 $STEP_DIR/usersfs.img || err 133 + ;; + + *) + echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" + err 140 + ;; + esac ;; *) - echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" - exit 10 + echo -e "${RED}Unknown machine '$MACHINE'${CLR}" + exit 150 ;; esac -cp node_modules/nodeos-usersfs/out/latest $OUT_DIR/usersfs -ln -sfn $CPU_FAMILY/$PLATFORM out/latest +ln -sfn $CPU_FAMILY/$MACHINE/$PLATFORM out/latest diff --git a/scripts/docker b/scripts/docker deleted file mode 100755 index 016bf6c47..000000000 --- a/scripts/docker +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env sh - -IMAGE=NodeOS -USERSFS=out/latest/usersfs - -docker run -it \ - --cap-add SYS_ADMIN \ - --device /dev/fuse \ - -v $USERSFS:/dev/sda \ - $IMAGE diff --git a/scripts/dockerBuild b/scripts/dockerBuild index 523471e2b..d7e129393 100755 --- a/scripts/dockerBuild +++ b/scripts/dockerBuild @@ -1,39 +1,50 @@ #!/usr/bin/env bash +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +set -o pipefail + + BLD=$(tput bold) +CLR="\e[0m" + +GRN="\e[32m" GRY="\e[90m" +WHT="\e[37m" + + +CONTEXT=out/latest + + +cp resources/Dockerfile $CONTEXT || exit 10 +cp resources/Dockerfile-initramfs $CONTEXT || exit 12 +cd $CONTEXT || exit 20 -TOOLCHAIN=`pwd`/node_modules/nodeos-cross-toolchain +ORG=nodeos -source $TOOLCHAIN/scripts/adjustEnvVars.sh || exit $? +docker import barebones.tar.gz $ORG/barebones || exit 30 +docker build -t $ORG/initramfs -f Dockerfile-initramfs . || exit 31 +#docker volume create --name $ORG/usersfs || exit 32 +#cat usersfs.tar.gz | docker cp - $ORG/usersfs:/ || exit 33 -( - cd node_modules/nodeos-barebones && - npm run dockerBuild || exit 10 -) && -( - cd node_modules/nodeos-initramfs && - npm run dockerBuild || exit 20 -) && -( - cd node_modules/nodeos-rootfs && - npm run dockerBuild || exit 30 -) && -( - docker build -t nodeos . || exit 40 -) || exit $? +docker build -t $ORG/nodeos . || exit 34 -echo -e "${GRY}------------------------------------------${CLR}" +echo -e "${GRY}-----------------------------------------${CLR}" echo -e "${GRN}${BLD}Success!${CLR}" echo -e "${GRN}You just registered a custom NodeOS image${CLR}" -echo -e "${GRY}------------------------------------------${CLR}" +echo -e "${GRY}-----------------------------------------${CLR}" echo echo -e "- Interactively run your image with:" -echo -e "${WHT} npm run docker${CLR}" +echo -e "${WHT} npm start${CLR}" echo echo -e "- Share your creation with:" -echo -e "${WHT} docker push NodeOS${CLR}" +echo -e "${WHT} docker push $ORG/nodeos${CLR}" diff --git a/scripts/postbuild b/scripts/postbuild index af6ecf347..a49970051 100755 --- a/scripts/postbuild +++ b/scripts/postbuild @@ -1,5 +1,12 @@ #!/usr/bin/env bash +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + BLD=$(tput bold) GRY="\e[90m" @@ -9,93 +16,163 @@ TOOLCHAIN=`pwd`/node_modules/nodeos-cross-toolchain source $TOOLCHAIN/scripts/adjustEnvVars.sh || exit $? -OUT_DIR=`pwd`/out/$CPU_FAMILY/$PLATFORM - - -# Disk images are a composition of rootfs and usersfs -function createDiskImage() { - mkdir -p `dirname $OBJECTS` - - # ToDo: sizes would need to be on cylinders and retain DOS compatibility - # http://elinux.org/RPi_Advanced_Setup#Advanced_SD_card_setup - - ROOTFS=$OUT_DIR/rootfs - USERSFS=$OUT_DIR/usersfs - - SIZE_MBR=$((2*1024)) - SIZE_ROOTFS=$(stat -L -c%s "$ROOTFS") - SIZE_ROOTFS=$(($SIZE_ROOTFS/512)) - START_USERSFS=$(($SIZE_MBR+$SIZE_ROOTFS)) +# Default kernel and platform +if [[ -z "$PLATFORM" ]]; then + PLATFORM=qemu +fi - dd if=/dev/zero of=$OBJECTS count=$SIZE_MBR && - cat $ROOTFS >> $OBJECTS && - cat $USERSFS >> $OBJECTS || exit 10 - eval "echo \"$(< resources/sfdisk.txt)\"" | \ - /sbin/sfdisk -uS --force $OBJECTS || exit 11 -} +OUT_DIR=`pwd`/out/$CPU_FAMILY/$MACHINE/$PLATFORM if [[ ! -z "$RELEASE" ]]; then - ZIP_FILE=prebuilds/$CPU_FAMILY-$PLATFORM.zip + ZIP_FILE=prebuilds/$CPU_FAMILY-$MACHINE-$PLATFORM.zip mkdir -p prebuilds rm -f $ZIP_FILE - case $PLATFORM in - pc_qemu) - zip -j $ZIP_FILE \ - resources/runners/README.md \ - $OUT_DIR/barebones \ - $OUT_DIR/initramfs \ - $OUT_DIR/usersfs || exit 20 - - eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && - cat resources/runners/qemu.sh >> /tmp/run.sh || exit 21 - - chmod +x /tmp/run.sh && - zip -j $ZIP_FILE /tmp/run.sh || exit 22 + case $MACHINE in + pc) + case $PLATFORM in + disk) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/disk.sh >> /tmp/run.sh || exit 30 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 31 + + zip -j $ZIP_FILE \ + resources/runners/README.md \ + $OUT_DIR/disk.img || exit 32 + ;; + + docker) + cp resources/runners/README_docker.md /tmp/README.md || exit 20 + + cp resources/runners/docker.sh /tmp/run.sh && + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 21 + + zip -j $ZIP_FILE \ + /tmp/README.md \ + $OUT_DIR/barebones.tar.gz \ + $OUT_DIR/initramfs.tar.gz \ + $OUT_DIR/usersfs.tar.gz \ + resources/Dockerfile || exit 22 + ;; + + img) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/img.sh >> /tmp/run.sh || exit 30 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 31 + + zip -j $ZIP_FILE \ + resources/runners/README.md \ + $OUT_DIR/bootfs.img \ + $OUT_DIR/usersfs.img || exit 32 + ;; + + iso) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/iso.sh >> /tmp/run.sh && + cp resources/runners/README_iso.md /tmp/README.md || exit 40 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 41 + + zip -j $ZIP_FILE \ + /tmp/README.md \ + bin/installUSB \ + $OUT_DIR/bootfs.iso \ + $OUT_DIR/usersfs.img || exit 42 + ;; + + qemu) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/qemu.sh >> /tmp/run.sh || exit 50 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 51 + + zip -j $ZIP_FILE \ + resources/runners/README.md \ + $OUT_DIR/kernel \ + $OUT_DIR/initramfs.cpio.gz \ + $OUT_DIR/usersfs.img || exit 52 + ;; + + vagga) + cp resources/runners/README_vagga.md /tmp/README.md || exit 60 + + zip -j $ZIP_FILE \ + /tmp/README.md \ + $OUT_DIR/barebones.tar.gz \ + $OUT_DIR/initramfs.tar.gz \ + $OUT_DIR/usersfs.tar.gz \ + resources/vagga.yaml || exit 61 + ;; + + *) + echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" + exit 70 + ;; + esac ;; - pc_iso) - zip -j $ZIP_FILE \ - resources/runners/README.md \ - $OUT_DIR/rootfs \ - $OUT_DIR/usersfs || exit 30 - - eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && - cat resources/runners/iso.sh >> /tmp/run.sh || exit 31 - - chmod +x /tmp/run.sh && - zip -j $ZIP_FILE /tmp/run.sh || exit 32 - ;; - - raspberry_image) - createDiskImage || exit $? - - eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && - cat resources/runners/raspberry.sh >> /tmp/run.sh || exit 40 - - chmod +x /tmp/run.sh && - zip -j $ZIP_FILE /tmp/run.sh || exit 41 - - zip -j $ZIP_FILE resources/runners/README.md || exit 42 - ;; - - vagga) - cp resources/runners/README_vagga.md /tmp/README.md || exit 50 - - zip -j $ZIP_FILE \ - /tmp/README.md \ - $OUT_DIR/barebones \ - $OUT_DIR/initramfs \ - $OUT_DIR/usersfs \ - resources/vagga.yaml || exit 51 + raspi|raspi2|raspi3) + case $PLATFORM in + disk) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/disk.sh >> /tmp/run.sh || exit 30 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 31 + + zip -j $ZIP_FILE \ + resources/runners/README.md \ + $OUT_DIR/disk.img || exit 32 + ;; + + img) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/img.sh >> /tmp/run.sh || exit 80 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 81 + + zip -j $ZIP_FILE \ + resources/runners/README.md \ + $OUT_DIR/bootfs.img \ + $OUT_DIR/usersfs.img || exit 82 + ;; + + qemu) + eval "echo -e \"$(< resources/runners/runner_header.sh)\"" > /tmp/run.sh && + cat resources/runners/qemu.sh >> /tmp/run.sh || exit 90 + + chmod +x /tmp/run.sh && + zip -j $ZIP_FILE /tmp/run.sh || exit 91 + + zip -j $ZIP_FILE \ + resources/runners/README.md \ + $OUT_DIR/kernel \ + $OUT_DIR/dts \ + $OUT_DIR/initramfs.cpio.gz \ + $OUT_DIR/usersfs.img || exit 92 + ;; + + *) + echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" + exit 100 + ;; + esac ;; *) - echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" - exit 60 + echo -e "${RED}Unknown machine '$MACHINE'${CLR}" + exit 110 ;; esac fi @@ -109,24 +186,25 @@ echo echo -e "- Interactively run your image with:" case $PLATFORM in + disk|img|iso|qemu) + echo -e "${WHT} npm start${CLR}" + ;; + docker) - echo -e "${WHT} npm run dockerBuild ${CLR}" - echo -e "${WHT} docker run -t -i NodeOS${CLR}" + echo -e "${WHT} npm run dockerBuild${CLR}" + echo -e "${WHT} npm start${CLR}" echo echo -e "- Share your creation with:" - echo -e "${WHT} docker push NodeOS${CLR}" + echo -e "${WHT} docker push nodeos/nodeos${CLR}" + echo + echo -e "You would need administrator permissions to exec that commands" ;; vagga) echo -e "${WHT} vagga run${CLR}" ;; - *_img|*_iso|*_qemu) - echo -e "${WHT} npm start${CLR}" - ;; - *) echo -e "${RED}Unknown platform '$PLATFORM'${CLR}" - exit 70 ;; esac diff --git a/scripts/postinstall b/scripts/postinstall new file mode 100755 index 000000000..464c3e264 --- /dev/null +++ b/scripts/postinstall @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +# HACK `npm` add all the binaries to the `node_modules/.bin` folder without +# matter what package installed it, so `env` from `usrbinenv` gets available on +# the `$PATH` during build process, making it to fail since its shebang is +# `#!/bin/node`, that's only valid on NodeOS, so we need to remove the symlink +# to make it not interfere with the build process + +rm -f node_modules/.bin/env diff --git a/scripts/publish b/scripts/publish index 690851df0..dbec97450 100755 --- a/scripts/publish +++ b/scripts/publish @@ -1,5 +1,14 @@ #!/usr/bin/env node +/** + * NodeOS + * + * @copyright 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' + * and other contributors + * + * @license MIT + */ + const readdir = require('fs').readdir const upload = require('prebuild/upload') diff --git a/scripts/start b/scripts/start index 28be88b1a..7087362c0 100755 --- a/scripts/start +++ b/scripts/start @@ -1,105 +1,26 @@ #!/usr/bin/env node -var fs = require('fs') -var join = require('path').join -var spawn = require('child_process').spawn +/** + * NodeOS + * + * @copyright 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' + * and other contributors + * + * @license MIT + */ +const spawn = require('child_process').spawn -const QEMU_SYSTEM = 'qemu-system-' +const prepareCommandLine = require('..') -var link = fs.readlinkSync('out/latest').split('/'); +const {command, argv, cwd} = prepareCommandLine(process.argv.slice(2)) -var cpu_family = link[link.length-2] -var platform = link[link.length-1] -var type = platform.split('_')[1] - -var machine -switch(cpu_family) -{ - case 'arm': - machine = 'versatilepb' - break -} - - -var command = QEMU_SYSTEM+cpu_family - -var args = -[ - '-enable-kvm', - '-vga', 'std', - '-m', '256M', - '-redir', 'tcp:50080::80', - '-redir', 'tcp:50443::443' -] - -const outDir = join('out', cpu_family, platform) -switch(type) -{ - case 'img': - args.push('-hda', join(outDir, 'rootfs')) - args.push('-hdb', join(outDir, 'usersfs')) - break - - case 'iso': - args.push('-cdrom', join(outDir, 'rootfs')) - args.push('-hdb' , join(outDir, 'usersfs')) - break - - case 'qemu': - var append = - [ - 'root=/dev/sda', - 'ip=dhcp' - ] - - switch(process.argv[2]) - { - case 'nographic': - append.push('console=ttyS0') // redirect to terminal - args.push('-nographic') - break - - case 'curses': - append.push('vga=extended') // 80x50 - args.push('-curses') - break - - default: - append.push('vga=0x344') // 1024x768x32 - } - - args.push('--kernel', join(outDir, 'barebones')) - args.push('--initrd', join(outDir, 'initramfs')) - args.push('-hda', join(outDir, 'usersfs')) - args.push('-append', append.join(' ')) - break - - default: - throw 'Unknown platform "'+platform+'"' -} - -if(machine) args.unshift('-machine', machine) - -// check if kvm is supported -var kvm = /(vmx|svm)/; -var contents = ""; - -try +// Exec NodeOS +spawn(command, argv, {stdio: 'inherit', cwd}) +.on('error', console.trace.bind(console)) +.on('exit', function(code, signal) { - contents = fs.readFileSync('/proc/cpuinfo'); -} catch(e){ - throw(e); -} - -if(kvm.test(contents) === false) -{ - // disable kvm - console.log("Your computer does not support kvm. NodeOS will be slower without it."); - args.shift(); -} - -spawn(command, args, {stdio: 'inherit'}) -.on('error', console.trace.bind(console)); + process.exit(code || signal) +}) diff --git a/scripts/test b/scripts/test index 661d5a233..437f87b99 100755 --- a/scripts/test +++ b/scripts/test @@ -1,132 +1,81 @@ #!/usr/bin/env node -var join = require('path').join -var fs = require('fs') +/** + * NodeOS + * + * @copyright 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' + * and other contributors + * + * @license MIT + */ -var suppose = require('suppose') +const join = require('path').join -var processArguments = require('nodeos-barebones/scripts/processArguments') +const suppose = require('suppose') +const prepareCommandLine = require('..') -const TIMEOUT = 300 // seconds +const TIMEOUT = 300 // seconds -var link = fs.readlinkSync('out/latest').split('/'); -var cpu_family = link[link.length-2] -var platform = link[link.length-1] +let {command, argv, cwd, platform, timeout_rate} = + prepareCommandLine(process.argv.slice(2), 'nographic') -var type = platform.split('_')[1] || platform +switch(platform) +{ + case 'tar': + fs.accessSync(join(cwd, 'bootfs.tar.gz')) + fs.accessSync(join(cwd, 'usersfs.tar.gz')) + process.exit() + break -var args = processArguments(process.argv.slice(2)) + case 'vagga': + fs.accessSync(join(cwd, 'barebones.tar.gz')) + fs.accessSync(join(cwd, 'initramfs.tar.gz')) + fs.accessSync(join(cwd, 'usersfs.tar.gz')) + process.exit() + break +} -var cpu = args.cpu -var machine = args.machine -var exe -var timeout = setTimeout(function() +// Exec test +let exe +let timeout = setTimeout(function() { exe.kill() console.error('Timeout while waiting an answer') process.exit(-2) -}, TIMEOUT*1000) +}, TIMEOUT*timeout_rate*1000) -var command = 'qemu-system-'+args.cpu_family +const options = {stripAnsi: true, debug: true, cwd} +//const options = {stripAnsi: true, debug: process.argv[2] === 'debug', cwd} +exe = suppose(command, argv, options) -var args = -[ -// '-enable-kvm', - '-nographic', -] +// On disk images, hook on the bootloader and force kernel to output to console +if(platform === 'disk' || platform === 'img' || platform === 'iso') + exe.when('boot: ').respond('NodeOS console=ttyS0\n') -const outDir = join('out', cpu_family, platform) -switch(type) +exe +.when(/username: /, 'nodeos\n') +.when(/password: /, 'nodeos\n') +.when('~ > ' , 'node\n') +.when('> ', 'setTimeout(console.log, 2000, "this is","a test")\n') +.when(/this is a test/, function(exe) { - case 'img': - fs.accessSync(join(outDir, 'rootfs')) - fs.accessSync(join(outDir, 'usersfs')) - process.exit() - - // args.push('-hda', join(outDir, 'rootfs')) - // args.push('-hdb', join(outDir, 'usersfs')) - break - - case 'iso': - fs.accessSync(join(outDir, 'rootfs')) - fs.accessSync(join(outDir, 'usersfs')) - process.exit() - -// args.push('-cdrom', join(outDir, 'rootfs')) -// args.push('-hdb' , join(outDir, 'usersfs')) - break - - case 'qemu': - var append = - [ - 'root=/dev/sda', - 'console=ttyS0' - ] - - args.push('--kernel', join(outDir, 'barebones'), - '--initrd', join(outDir, 'initramfs'), - '-hda', join(outDir, 'usersfs'), - '-append', append.join(' ')) - break - - case 'vagga': - fs.accessSync(join(outDir, 'barebones')) - fs.accessSync(join(outDir, 'initramfs')) - fs.accessSync(join(outDir, 'usersfs')) - process.exit() - -// args.push('-cdrom', join(outDir, 'rootfs')) -// args.push('-hdb' , join(outDir, 'usersfs')) - break - - default: - throw 'Unknown platform "'+platform+'"' -} + exe.kill() +}) +.on('error', function(error) +{ + if(error.message.indexOf('terminating on signal 15 from pid') < 0) + console.trace(error) +}) +.end(function() +{ + clearTimeout(timeout) -// // check if kvm is supported -// var kvm = /(vmx|svm)/; -// var contents = ""; -// -// try -// { -// contents = fs.readFileSync('/proc/cpuinfo'); -// } catch(e){ -// throw(e); -// } -// -// if(kvm.test(contents) === false) -// { -// // disable kvm -// console.log("Your computer does not support kvm. NodeOS will be slower without it."); -// args.shift(); -// } - -if(machine) args.unshift('-machine', machine) - -exe = suppose(command, args, {debug: true, stripAnsi: true}) - .when('username: ').respond('nodeos\n') - .when('password: ').respond('nodeos\n') - .when('# ').respond('node\n') - .when('> ').respond('setTimeout(console.log, 2000, "this is","a test")\n') - .when(/this is a test/, function(exe) - { - exe.kill() - }) - .on('error', function(error) - { - if(error.message.indexOf('terminating on signal 15 from pid') < 0) - console.trace(error) - }) - .end(function() - { - clearTimeout(timeout) - - var expects = this.expects.length - if(expects) process.exit(expects) - }) + var expects = this.expects.length + if(expects) process.exit(expects) +}) diff --git a/scripts/unbuild b/scripts/unbuild index a5839d321..bd58a74c0 100755 --- a/scripts/unbuild +++ b/scripts/unbuild @@ -1,3 +1,10 @@ #!/usr/bin/env sh -rm -rf deps/ out/ prebuilds/ || exit $? +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + +rm -rf deps/ build/ out/ prebuilds/ || exit $? diff --git a/vagga.yaml b/vagga.yaml index e95c3c726..b803a59ab 100644 --- a/vagga.yaml +++ b/vagga.yaml @@ -1,21 +1,37 @@ +# NodeOS +# +# Copyright (c) 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna' +# and other contributors +# +# MIT License + containers: - NodeOS: + bootfs: + auto-clean: true + hosts-file-path: null + resolv-conf-path: null setup: - !Tar - url: ./out/latest/barebones + url: ./out/latest/barebones.tar.gz + - !Tar + url: ./out/latest/initramfs.tar.gz - !Tar - url: ./out/latest/initramfs + url: ./out/latest/usersfs.tar.gz + path: /tmp volumes: - /tmp: !BindRW ./out/latest/usersfs + /tmp: !Persistent usersfs commands: run: !Command description: Start NodeOS - container: NodeOS + container: bootfs +# volumes: +# /tmp: !Persistent +# name: usersfs environ: - PWD: / - root: '' - pid1mode: exec +# PWD: / +# root: '' + root: 'container' +# pid1mode: exec run: [/init] -# run: /tmp/bin/logon write-mode: transient-hard-link-copy