mirror of
https://github.com/key-networks/ztncui.git
synced 2025-06-05 01:33:44 +02:00
Added dotenv to easily add environment variables in .env file
This commit is contained in:
parent
0e8afc9ca6
commit
f5cbc66943
5 changed files with 39 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ etc/passwd
|
||||||
etc/storage/
|
etc/storage/
|
||||||
node_modules/
|
node_modules/
|
||||||
*.swp
|
*.swp
|
||||||
|
.env
|
||||||
|
|
35
README.md
35
README.md
|
@ -16,7 +16,7 @@ sudo npm install -g node-gyp
|
||||||
|
|
||||||
* ztncui requires [ZeroTier One](https://www.zerotier.com/download.shtml) to be installed on the same machine. This will run as the network controller to establish ZeroTier networks.
|
* ztncui requires [ZeroTier One](https://www.zerotier.com/download.shtml) to be installed on the same machine. This will run as the network controller to establish ZeroTier networks.
|
||||||
|
|
||||||
* ztncui has been developed on a Linux platform and expects the ZT home directory to be in `/var/lib/zerotier-one`. It should be easy to modify for other platforms - please feed back if this is required.
|
* ztncui has been developed on a Linux platform and expects the ZT home directory to be in `/var/lib/zerotier-one`. It should be easy to modify for other platforms - please feed back if this is required. (Edit: it should be easier to run on any platform now using a `.env` file - see below).
|
||||||
|
|
||||||
### Installing
|
### Installing
|
||||||
##### 1. Clone the repository on a machine running ZeroTier One:
|
##### 1. Clone the repository on a machine running ZeroTier One:
|
||||||
|
@ -30,7 +30,11 @@ cd ztncui
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 3. Allow access to /var/lib/zerotier-one/authtoken.secret
|
##### 3. authtoken.secret
|
||||||
|
|
||||||
|
The app needs to know the zerotier-one authtoken.secret. Their are two options:
|
||||||
|
|
||||||
|
###### A: Allow access to /var/lib/zerotier-one/authtoken.secret
|
||||||
The user running the ztncui app needs read access to authtoken.secret. This can be achieved with:
|
The user running the ztncui app needs read access to authtoken.secret. This can be achieved with:
|
||||||
```shell
|
```shell
|
||||||
sudo usermod -aG zerotier-one username
|
sudo usermod -aG zerotier-one username
|
||||||
|
@ -41,6 +45,27 @@ Where:
|
||||||
|
|
||||||
Note that you need to log out and in again to apply the new group membership.
|
Note that you need to log out and in again to apply the new group membership.
|
||||||
|
|
||||||
|
###### OR
|
||||||
|
###### B: Make a .env file
|
||||||
|
In the root of the ztncui directory, create a `.env` file with the content:
|
||||||
|
```
|
||||||
|
ZT_TOKEN=########################
|
||||||
|
```
|
||||||
|
Where:
|
||||||
|
* ######################## is the token string.
|
||||||
|
|
||||||
|
You can also specify in the `.env` file a different address for the zerotier-one API (which defaults to localhost:9993):
|
||||||
|
```
|
||||||
|
ZT_ADDR=localhost:9995
|
||||||
|
```
|
||||||
|
|
||||||
|
Make `.env` readable by the user running ztncui only:
|
||||||
|
```shell
|
||||||
|
chmod 600 .env
|
||||||
|
```
|
||||||
|
|
||||||
|
The `.env` file should make it easier to run ztncui on a non-Linux platform.
|
||||||
|
|
||||||
##### 4. Copy the default passwd file
|
##### 4. Copy the default passwd file
|
||||||
To prevent git from over-writing your password file every time you pull updates from the repository, the etc/passwd file has been added to .gitignore. So you need to copy the default file after the first time you do a git clone. All these things ideally need to be done with a package installer script:
|
To prevent git from over-writing your password file every time you pull updates from the repository, the etc/passwd file has been added to .gitignore. So you need to copy the default file after the first time you do a git clone. All these things ideally need to be done with a package installer script:
|
||||||
```shell
|
```shell
|
||||||
|
@ -51,9 +76,9 @@ cp -v etc/default.passwd etc/passwd
|
||||||
```shell
|
```shell
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
This will run the app on TCP port 3000 by default. If port 3000 is already in use, you can specify a different port, e.g.:
|
This will run the app on TCP port 3000 by default. If port 3000 is already in use, you can specify a different port in the `.env` file (see 3B above), e.g.:
|
||||||
```shell
|
```
|
||||||
PORT=3456 npm start
|
PORT=3456
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 6. Start the app automatically
|
##### 6. Start the app automatically
|
||||||
|
|
2
app.js
2
app.js
|
@ -4,6 +4,8 @@
|
||||||
Licensed under GPLv3 - see LICENSE for details.
|
Licensed under GPLv3 - see LICENSE for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const favicon = require('serve-favicon');
|
const favicon = require('serve-favicon');
|
||||||
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -534,6 +534,11 @@
|
||||||
"is-obj": "1.0.1"
|
"is-obj": "1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dotenv": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0="
|
||||||
|
},
|
||||||
"duplexer": {
|
"duplexer": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
"cookie-parser": "~1.4.3",
|
"cookie-parser": "~1.4.3",
|
||||||
"debug": "~3.1.0",
|
"debug": "~3.1.0",
|
||||||
|
"dotenv": "^4.0.0",
|
||||||
"express": "~4.16.2",
|
"express": "~4.16.2",
|
||||||
"express-session": "^1.15.6",
|
"express-session": "^1.15.6",
|
||||||
"express-validator": "^4.3.0",
|
"express-validator": "^4.3.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue