Merge branch 'master' into v1.2

This commit is contained in:
aj 2017-10-23 23:21:01 +00:00
commit 6c182d4736
6 changed files with 76 additions and 33 deletions

View File

@ -19,18 +19,19 @@ Pre-requisites:
* You own a domain * You own a domain
* through Daplie Domains * through Daplie Domains
* or you understand domains and DNS and all that stuff * or you understand domains and DNS and all that stuff
* Install bower `npm install -g bower`
Choose a domain Choose a domain
--------------- ---------------
For the purpose of this instruction we'll assume that your domain is `example.com`, For the purpose of this instruction we'll assume that your domain is `foo.com`,
but you can use, say, `johndoe.daplie.me` for testing through Daplie Domains. but you can use, say, `johndoe.daplie.me` for testing through Daplie Domains.
Anyway, go ahead and set the bash variable `$my_domain` for the purposes of the Anyway, go ahead and set the bash variable `$my_domain` for the purposes of the
rest of this tutorial: rest of this tutorial:
``` ```
my_domain=example.com my_domain=foo.com
``` ```
You can purchase a domain with daplie tools You can purchase a domain with daplie tools
@ -47,17 +48,17 @@ Subdomains
Auth will be loaded with the following domains Auth will be loaded with the following domains
``` ```
provider.example.com provider.foo.com
api.provider.example.com api.provider.foo.com
``` ```
The Hello World app will be loaded with the following domains The Hello World app will be loaded with the following domains
``` ```
example.com foo.com
www.example.com www.foo.com
api.example.com api.foo.com
assets.example.com assets.foo.com
``` ```
The domains can be setup through the Daplie Desktop App or with daplie-tools The domains can be setup through the Daplie Desktop App or with daplie-tools
@ -69,6 +70,9 @@ Replace `foodevice` with whatever you like to call this device
my_device=foodevice my_device=foodevice
# curl https://api.oauth3.org/api/tunnel@oauth3.org/checkip # curl https://api.oauth3.org/api/tunnel@oauth3.org/checkip
# READ THIS: localhost is being used as an example.
# Your IP address should be public facing (i.e. port-forwarding is enabled on your router).
# If it isn't, then you need something like goldilocks providing a tunnel.
my_address=127.0.0.1 my_address=127.0.0.1
# set device address and attach primary domain # set device address and attach primary domain
@ -92,7 +96,7 @@ Walnut must sit behind a proxy that properly terminates https and sets the `X-Fo
Goldilocks can do this, as well as manage daplie domains, tunneling, etc. Goldilocks can do this, as well as manage daplie domains, tunneling, etc.
```bash ```bash
curl https://daplie.me/install-scripts | bash curl https://git.daplie.com/Daplie/daplie-snippets/raw/master/install.sh | bash
daplie-install-goldilocks daplie-install-goldilocks
``` ```
@ -101,16 +105,16 @@ daplie-install-goldilocks
Example `/etc/goldilocks/goldilocks.yml`: Example `/etc/goldilocks/goldilocks.yml`:
```yml ```yml
tls: tls:
email: domains@example.com email: user@mailservice.com
servernames: servernames:
- example.com - foo.com
- www.example.com - www.foo.com
- api.example.com - api.foo.com
- assets.example.com - assets.foo.com
- cloud.example.com - cloud.foo.com
- api.cloud.example.com - api.cloud.foo.com
- provider.example.com - provider.foo.com
- api.provider.example.com - api.provider.foo.com
http: http:
trust_proxy: true trust_proxy: true
@ -125,7 +129,7 @@ Basic Walnut Install
-------------------- --------------------
```bash ```bash
curl https://daplie.me/install-scripts | bash curl https://git.daplie.com/Daplie/daplie-snippets/raw/master/install.sh | bash
daplie-install-walnut daplie-install-walnut
``` ```
@ -162,8 +166,8 @@ Resetting the Initialization
Once you run the app the initialization files will appear in these locations Once you run the app the initialization files will appear in these locations
``` ```
/srv/walnut/var/com.daplie.walnut.config.sqlite3 /srv/walnut/var/walnut+config@daplie.com.sqlite3
/srv/walnut/config/<domain.tld>/config.json /srv/walnut/config/foo.com.json
``` ```
Deleting those files and restarting walnut will reset it to its bootstrap state. Deleting those files and restarting walnut will reset it to its bootstrap state.
@ -188,7 +192,7 @@ For the APIs for that we'll install the `issuer@oauth3.org` API package and enab
```bash ```bash
# API packaged for walnut # API packaged for walnut
git clone https://git.daplie.com/OAuth3/org.oauth3.provider.git /srv/walnut/packages/rest/issuer@oauth3.org git clone https://git.daplie.com/OAuth3/issuer_oauth3.org.git /srv/walnut/packages/rest/issuer@oauth3.org
pushd /srv/walnut/packages/rest/issuer@oauth3.org/ pushd /srv/walnut/packages/rest/issuer@oauth3.org/
git checkout v1.2 git checkout v1.2
npm install npm install
@ -224,13 +228,13 @@ It is intended to provide a way to use various mail services in the future,
just bear with us for the time being (or open a Merge Request). just bear with us for the time being (or open a Merge Request).
```bash ```bash
vim /srv/walnut/var/$my_domain/config.json mkdir -p /srv/walnut/var/provider.$my_domain
vim /srv/walnut/var/provider.$my_domain/config.json
``` ```
```json ```json
{ "mailgun.org": { { "mailgun.org": {
"apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
, "apiPublicKey": "pubkey-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
, "auth": { , "auth": {
"user": "robtherobot@example.com" "user": "robtherobot@example.com"
, "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" , "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
@ -266,8 +270,9 @@ What it should look like:
models.js models.js
rest.js rest.js
/srv/walnut/packages/client-api-grants/example.com /srv/walnut/packages/client-api-grants/provider.foo.com
''' '''
issuer@oauth3.org
hello@example.com hello@example.com
''' '''
``` ```

View File

@ -55,6 +55,19 @@ We're still in a stage where the installation generally requires many manual ste
See [INSTALL.md](/INSTALL.md) See [INSTALL.md](/INSTALL.md)
Usage
-----
Here's how you run the thing, once installed:
```
/opt/walnut/bin/node /srv/walnut/core/bin/walnut.js
```
It listens on all addresses, port 3000.
TODO: Add config to restrict listening to localhost.
API API
--- ---

View File

@ -27,7 +27,7 @@ Group=www-data
# Set a sane working directory, sane flags, and specify how to reload the config file # Set a sane working directory, sane flags, and specify how to reload the config file
WorkingDirectory=/srv/www WorkingDirectory=/srv/www
ExecStart=/usr/local/bin/node /srv/walnut/core/bin/walnut.js --config=/etc/walnut/walnut.yml ExecStart=/opt/walnut/bin/node /srv/walnut/core/bin/walnut.js --config=/etc/walnut/walnut.yml
ExecReload=/bin/kill -USR1 $MAINPID ExecReload=/bin/kill -USR1 $MAINPID
# Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings. # Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings.

View File

@ -249,7 +249,6 @@ install_my_app()
ln -sf ../node_modules /srv/walnut/core/node_modules ln -sf ../node_modules /srv/walnut/core/node_modules
mkdir -p /srv/walnut/var/sites mkdir -p /srv/walnut/var/sites
mkdir -p /srv/walnut/etc/org.oauth3.consumer mkdir -p /srv/walnut/etc/org.oauth3.consumer
mkdir -p /srv/walnut/etc/org.oauth3.provider
mkdir -p /srv/walnut/etc/client-api-grants mkdir -p /srv/walnut/etc/client-api-grants
mkdir -p /srv/walnut/packages/{rest,api,pages,services} mkdir -p /srv/walnut/packages/{rest,api,pages,services}
@ -264,11 +263,13 @@ install_my_app()
if [ ! -d "./.git/" ]; then if [ ! -d "./.git/" ]; then
echo "'/srv/walnut/core/lib/walnut@daplie.com/setup' exists but is not a git repository... not sure what to do here..." echo "'/srv/walnut/core/lib/walnut@daplie.com/setup' exists but is not a git repository... not sure what to do here..."
fi fi
git checkout v1 git checkout master
git pull git pull
popd popd
pushd /srv/walnut/core pushd /srv/walnut/core
export NODE_PATH=/opt/walnut/lib/node_modules
export NPM_CONFIG_PREFIX=/opt/walnut
/opt/walnut/bin/npm install /opt/walnut/bin/npm install
popd popd
} }

View File

@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
# Not every platform has or needs sudo, gotta save them O(1)s...
sudo_cmd=""
((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo"
set -e set -e
set -u set -u
@ -54,9 +58,9 @@ detect_http_get
install_walnut() install_walnut()
{ {
sudo mkdir -p /srv/walnut/{var,etc,packages,node_modules} $sudo_cmd mkdir -p /srv/walnut/{var,etc,packages,node_modules}
# www-data exists on linux, _www exists on mac OS # www-data exists on linux, _www exists on mac OS
sudo chown -R $(whoami):www-data /srv/walnut || sudo chown -R $(whoami):_www /srv/walnut $sudo_cmd chown -R $(whoami):www-data /srv/walnut || $sudo_cmd chown -R $(whoami):_www /srv/walnut
if [ ! -d "/srv/walnut/core/" ]; then if [ ! -d "/srv/walnut/core/" ]; then
git clone https://git.daplie.com/Daplie/walnut.js.git /srv/walnut/core git clone https://git.daplie.com/Daplie/walnut.js.git /srv/walnut/core
fi fi
@ -64,7 +68,7 @@ install_walnut()
if [ ! -d "./.git/" ]; then if [ ! -d "./.git/" ]; then
echo "'/srv/walnut/core' exists but is not a git repository... not sure what to do here..." echo "'/srv/walnut/core' exists but is not a git repository... not sure what to do here..."
fi fi
git checkout v1 git checkout master
git pull git pull
popd popd
rm -rf /srv/walnut/core/node_modules rm -rf /srv/walnut/core/node_modules
@ -72,20 +76,37 @@ install_walnut()
/srv/walnut/core/install-helper.sh /srv/walnut /srv/walnut/core/install-helper.sh /srv/walnut
# Now that the install is finished we need to set the owner to the user that will actually # Now that the install is finished we need to set the owner to the user that will actually
# be running the walnut server. # be running the walnut server.
sudo chown -R www-data:www-data /srv/walnut || sudo chown -R _www:_www /srv/walnut $sudo_cmd chown -R www-data:www-data /srv/walnut || $sudo_cmd chown -R _www:_www /srv/walnut
} }
# Install node # Install node
echo "----Installing Nodejs and NPM----"
echo "v8.2.1" > /tmp/NODEJS_VER echo "v8.2.1" > /tmp/NODEJS_VER
daplie-install-node-dev daplie-install-node-dev
npm install -g npm@4 npm install -g npm@4
# Install goldilocks # Install goldilocks
echo "----Installing goldilocks.js----"
daplie-install-goldilocks daplie-install-goldilocks
echo "----Installing walnut.js----"
#$sudo_cmd mkdir -p /opt/goldilocks/{lib,bin,etc}
#export NODE_PATH=/opt/walnut/lib/node_modules
#export NPM_CONFIG_PREFIX=/opt/walnut
old_PATH=$PATH
export PATH=/opt/walnut/bin:$PATH
# Install walnut # Install walnut
install_walnut install_walnut
# Install bower, some systems may be missing it, and it is a dependency
/opt/walnut/bin/npm install -g bower
touch /.bowerrc
echo '{ "allow_root": true }' > /.bowerrc
# Restore PATH to original value
export PATH=$old_PATH
echo "" echo ""
echo "You must have some set of domain set up to properly use goldilocks+walnut:" echo "You must have some set of domain set up to properly use goldilocks+walnut:"
echo "" echo ""

View File

@ -47,6 +47,7 @@
"connect-cors": "0.5.x", "connect-cors": "0.5.x",
"connect-recase": "^1.0.2", "connect-recase": "^1.0.2",
"connect-send-error": "1.x", "connect-send-error": "1.x",
"cookie-parser": "^1.4.3",
"escape-html": "^1.0.2", "escape-html": "^1.0.2",
"escape-string-regexp": "1.x", "escape-string-regexp": "1.x",
"express": "4.x", "express": "4.x",
@ -62,7 +63,9 @@
"nodemailer": "^1.4.0", "nodemailer": "^1.4.0",
"nodemailer-mailgun-transport": "1.x", "nodemailer-mailgun-transport": "1.x",
"oauth3.js": "git+https://git.daplie.com/OAuth3/oauth3.js.git", "oauth3.js": "git+https://git.daplie.com/OAuth3/oauth3.js.git",
"recase": "^1.0.4",
"request": "^2.81.0", "request": "^2.81.0",
"scmp": "^2.0.0",
"serve-static": "1.x", "serve-static": "1.x",
"sqlite3-cluster": "git+https://git.daplie.com/coolaj86/sqlite3-cluster.git#v2", "sqlite3-cluster": "git+https://git.daplie.com/coolaj86/sqlite3-cluster.git#v2",
"stripe": "^4.22.0", "stripe": "^4.22.0",