28 changed files with 3609 additions and 351 deletions
@ -1,21 +1,28 @@ |
|||||
{ |
{ |
||||
"env": { |
"env": { |
||||
"node": true |
"node": true, |
||||
}, |
"es6": true |
||||
"extends": "eslint:recommended", |
}, |
||||
"rules": { |
"extends": "eslint:recommended", |
||||
"no-console": "off", |
"rules": { |
||||
"indent": [ |
"no-console": "off", |
||||
"error", |
"indent": [ |
||||
"tab" |
"error", |
||||
], |
"tab" |
||||
"linebreak-style": [ |
], |
||||
"error", |
"linebreak-style": [ |
||||
"unix" |
"error", |
||||
], |
"unix" |
||||
"semi": [ |
], |
||||
"error", |
"semi": [ |
||||
"always" |
"error", |
||||
] |
"always" |
||||
} |
], |
||||
|
"prefer-const": "error", |
||||
|
"prefer-destructuring": "error", |
||||
|
"no-var": "error", |
||||
|
"strict": "error", |
||||
|
"eol-last": "error", |
||||
|
"max-len": "error" |
||||
|
} |
||||
} |
} |
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"editor.insertSpaces": false, |
||||
|
"editor.tabSize": 4, |
||||
|
"files.eol": "\n" |
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
# Contributor Covenant Code of Conduct |
||||
|
|
||||
|
## Our Pledge |
||||
|
|
||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. |
||||
|
|
||||
|
## Our Standards |
||||
|
|
||||
|
Examples of behavior that contributes to creating a positive environment include: |
||||
|
|
||||
|
* Using welcoming and inclusive language |
||||
|
* Being respectful of differing viewpoints and experiences |
||||
|
* Gracefully accepting constructive criticism |
||||
|
* Focusing on what is best for the community |
||||
|
* Showing empathy towards other community members |
||||
|
|
||||
|
Examples of unacceptable behavior by participants include: |
||||
|
|
||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances |
||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks |
||||
|
* Public or private harassment |
||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission |
||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting |
||||
|
|
||||
|
## Our Responsibilities |
||||
|
|
||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. |
||||
|
|
||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. |
||||
|
|
||||
|
## Scope |
||||
|
|
||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. |
||||
|
|
||||
|
## Enforcement |
||||
|
|
||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@thefeathers.in. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. |
||||
|
|
||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. |
||||
|
|
||||
|
## Attribution |
||||
|
|
||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] |
||||
|
|
||||
|
[homepage]: http://contributor-covenant.org |
||||
|
[version]: http://contributor-covenant.org/version/1/4/ |
@ -0,0 +1,13 @@ |
|||||
|
# Changelog / Version history |
||||
|
|
||||
|
## `up` v. 0.2.0 |
||||
|
|
||||
|
Changelog: |
||||
|
|
||||
|
- Under the hood BREAKING changes. Working directories change. |
||||
|
- `/var/www/` to `/etc/up-serve/static/` |
||||
|
- `/etc/nginx/sites-available/` to `/etc/nginx/conf.d` |
||||
|
- `up static|proxy <domain>` adds the server to `/etc/up-serve/servers.up` list. |
||||
|
- `up kill <domain>` removes server from `servers.up` list. |
||||
|
- `up list` lists available servers from /etc/up-serve/servers.up! |
||||
|
- `up kill-all` destroys all servers and places a `default.conf` in `/etc/nginx/sites-enabled`. |
@ -0,0 +1,21 @@ |
|||||
|
MIT License |
||||
|
|
||||
|
Copyright (c) 2017 Anu Rahul Nandhan a.k.a Muthu Kumar & CodeFeathers |
||||
|
|
||||
|
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 |
||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
copies of the Software, and to permit persons to whom the Software is |
||||
|
furnished to do so, subject to the following conditions: |
||||
|
|
||||
|
The above copyright notice and this permission notice shall be included in all |
||||
|
copies or substantial portions of the Software. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
|
SOFTWARE. |
@ -0,0 +1,38 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const shell = require('shelljs'); |
||||
|
|
||||
|
const { EOL } = require('os'); |
||||
|
|
||||
|
const npath = require('../utils/nginxPath'); |
||||
|
const conf = require('../utils/nginxConf'); |
||||
|
|
||||
|
function killALL () { |
||||
|
shell.rm('-Rf', npath.serversBakUp); |
||||
|
shell.mv(npath.serversUp(), npath.serversBakUp()); |
||||
|
shell.rm('-Rf', npath() + "sites-available"); |
||||
|
shell.rm('-Rf', npath.confD()); |
||||
|
shell.rm('-Rf', npath.enabledSites()); |
||||
|
shell.rm('-Rf', npath.webRoot()); |
||||
|
shell.mkdir('-p', npath.confD()); |
||||
|
shell.mkdir('-p', npath.enabledSites()); |
||||
|
shell.mkdir('-p', npath.webRoot()); |
||||
|
shell.cp('./build/defaultNginx.conf', conf(npath.confD())); |
||||
|
// Create the default.conf file
|
||||
|
shell.ln('-sf', npath.confD() + "default.conf", |
||||
|
npath.enabledSites() + "default.conf"); |
||||
|
// Symlink the default.conf file from confD to sites-enabled
|
||||
|
console.log("All servers were killed and reverted to default."); |
||||
|
console.log(EOL + [ |
||||
|
"A backup of your old servers.up is " + |
||||
|
"saved in /etc/up-serve/servers.bak.up.", |
||||
|
"Check this if you need to." |
||||
|
].join(EOL) + EOL); |
||||
|
} |
||||
|
|
||||
|
function noKill () { |
||||
|
console.log("\nkill-all was interrupted by user."); |
||||
|
} |
||||
|
|
||||
|
module.exports.kill = killALL; |
||||
|
module.exports.noKill = noKill; |
@ -0,0 +1,18 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const readlineSync = require('readline-sync'); |
||||
|
const killALL = require('./killALL').kill; |
||||
|
const { noKill } = require('./killALL'); |
||||
|
|
||||
|
function killAllConfirm() { |
||||
|
console.log("\nThis action will destroy all nginx servers and return " |
||||
|
+ "to default configuration."); |
||||
|
if (readlineSync.keyInYN("Are you sure you want to do this?")) { |
||||
|
killALL(); |
||||
|
} |
||||
|
else { |
||||
|
noKill(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = killAllConfirm; |
@ -1,15 +1,19 @@ |
|||||
var shell = require('shelljs'); |
'use strict'; |
||||
|
|
||||
var npath = require('../utils/nginxPath'); |
const shell = require('shelljs'); |
||||
var conf = require('../utils/nginxConf'); |
|
||||
var nginxReload = require('../utils/nginxReload'); |
const npath = require('../utils/nginxPath'); |
||||
|
const conf = require('../utils/nginxConf'); |
||||
|
const nginxReload = require('../utils/nginxReload'); |
||||
|
const { removeFromList } = require('../utils/listFile'); |
||||
|
|
||||
function killServer(domain, outPort) { |
function killServer(domain, outPort) { |
||||
shell.rm('-rf', conf(npath.enabledSites(), domain, outPort)); |
shell.rm('-rf', conf(npath.enabledSites(), domain, outPort)); |
||||
shell.rm('-rf', conf(npath.availableSites(), domain, outPort)); |
shell.rm('-rf', conf(npath.confD(), domain, outPort)); |
||||
shell.rm('-rf', npath.webRootDomain(domain, outPort)); |
shell.rm('-rf', npath.webRootDomain(domain, outPort)); |
||||
|
|
||||
|
removeFromList(domain, outPort); |
||||
nginxReload(); |
nginxReload(); |
||||
} |
} |
||||
|
|
||||
module.exports = killServer; |
module.exports = killServer; |
||||
|
@ -0,0 +1,16 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const { readServers } = require('../utils/listFile'); |
||||
|
const prettyjson = require('prettyjson'); |
||||
|
|
||||
|
const { EOL } = require('os'); |
||||
|
|
||||
|
function listServers() { |
||||
|
const serversList = readServers(); |
||||
|
if(serversList) console.log(EOL + prettyjson.render(serversList) + EOL); |
||||
|
else console.log(EOL + |
||||
|
"No servers were found! Create some using `up`!" + |
||||
|
EOL); |
||||
|
} |
||||
|
|
||||
|
module.exports = listServers; |
File diff suppressed because it is too large
@ -0,0 +1,136 @@ |
|||||
|
#user nobody; |
||||
|
#Defines which Linux system user will own and run the Nginx server |
||||
|
|
||||
|
worker_processes 1; |
||||
|
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores. |
||||
|
|
||||
|
#error_log logs/error.log; #error_log logs/error.log notice; |
||||
|
#Specifies the file where server logs. |
||||
|
|
||||
|
#pid logs/nginx.pid; |
||||
|
#nginx will write its master process ID(PID). |
||||
|
|
||||
|
events { |
||||
|
worker_connections 1024; |
||||
|
# worker_processes and worker_connections allows you to calculate maxclients value: |
||||
|
# max_clients = worker_processes * worker_connections |
||||
|
} |
||||
|
|
||||
|
|
||||
|
http { |
||||
|
include mime.types; |
||||
|
# anything written in /opt/nginx/conf/mime.types is interpreted as if written inside the http { } block |
||||
|
|
||||
|
default_type application/octet-stream; |
||||
|
# |
||||
|
|
||||
|
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
||||
|
# '$status $body_bytes_sent "$http_referer" ' |
||||
|
# '"$http_user_agent" "$http_x_forwarded_for"'; |
||||
|
|
||||
|
#access_log logs/access.log main; |
||||
|
|
||||
|
sendfile on; |
||||
|
# If serving locally stored static files, sendfile is essential to speed up the server, |
||||
|
# But if using as reverse proxy one can deactivate it |
||||
|
|
||||
|
#tcp_nopush on; |
||||
|
# works opposite to tcp_nodelay. Instead of optimizing delays, it optimizes the amount of data sent at once. |
||||
|
|
||||
|
#keepalive_timeout 0; |
||||
|
keepalive_timeout 65; |
||||
|
# timeout during which a keep-alive client connection will stay open. |
||||
|
|
||||
|
#gzip on; |
||||
|
# tells the server to use on-the-fly gzip compression. |
||||
|
|
||||
|
server { |
||||
|
# You would want to make a separate file with its own server block for each virtual domain |
||||
|
# on your server and then include them. |
||||
|
listen 80; |
||||
|
#tells Nginx the hostname and the TCP port where it should listen for HTTP connections. |
||||
|
# listen 80; is equivalent to listen *:80; |
||||
|
|
||||
|
server_name localhost; |
||||
|
# lets you doname-based virtual hosting |
||||
|
|
||||
|
#charset koi8-r; |
||||
|
|
||||
|
#access_log logs/host.access.log main; |
||||
|
|
||||
|
location / { |
||||
|
#The location setting lets you configure how nginx responds to requests for resources within the server. |
||||
|
root html; |
||||
|
index index.html index.htm; |
||||
|
} |
||||
|
|
||||
|
#error_page 404 /404.html; |
||||
|
|
||||
|
# redirect server error pages to the static page /50x.html |
||||
|
# |
||||
|
error_page 500 502 503 504 /50x.html; |
||||
|
location = /50x.html { |
||||
|
root html; |
||||
|
} |
||||
|
|
||||
|
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 |
||||
|
# |
||||
|
#location ~ \.php$ { |
||||
|
# proxy_pass http://127.0.0.1; |
||||
|
#} |
||||
|
|
||||
|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 |
||||
|
# |
||||
|
#location ~ \.php$ { |
||||
|
# root html; |
||||
|
# fastcgi_pass 127.0.0.1:9000; |
||||
|
# fastcgi_index index.php; |
||||
|
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; |
||||
|
# include fastcgi_params; |
||||
|
#} |
||||
|
|
||||
|
# deny access to .htaccess files, if Apache's document root |
||||
|
# concurs with nginx's one |
||||
|
# |
||||
|
#location ~ /\.ht { |
||||
|
# deny all; |
||||
|
#} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
# another virtual host using mix of IP-, name-, and port-based configuration |
||||
|
# |
||||
|
#server { |
||||
|
# listen 8000; |
||||
|
# listen somename:8080; |
||||
|
# server_name somename alias another.alias; |
||||
|
|
||||
|
# location / { |
||||
|
# root html; |
||||
|
# index index.html index.htm; |
||||
|
# } |
||||
|
#} |
||||
|
|
||||
|
|
||||
|
# HTTPS server |
||||
|
# |
||||
|
#server { |
||||
|
# listen 443 ssl; |
||||
|
# server_name localhost; |
||||
|
|
||||
|
# ssl_certificate cert.pem; |
||||
|
# ssl_certificate_key cert.key; |
||||
|
|
||||
|
# ssl_session_cache shared:SSL:1m; |
||||
|
# ssl_session_timeout 5m; |
||||
|
|
||||
|
# ssl_ciphers HIGH:!aNULL:!MD5; |
||||
|
# ssl_prefer_server_ciphers on; |
||||
|
|
||||
|
# location / { |
||||
|
# root html; |
||||
|
# index index.html index.htm; |
||||
|
# } |
||||
|
#} |
||||
|
|
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const https = require('https'); |
||||
|
const fs = require('fs-extra'); |
||||
|
|
||||
|
const file = fs.createWriteStream("./assets/tlds.txt"); |
||||
|
https.get("https://data.iana.org/TLD/tlds-alpha-by-domain.txt",response => |
||||
|
response.pipe(file)); |
File diff suppressed because it is too large
@ -0,0 +1,63 @@ |
|||||
|
// Module courtesy of TRGWII
|
||||
|
// Original: https://github.com/trgwii/isFQDN
|
||||
|
|
||||
|
'use strict'; |
||||
|
|
||||
|
const fs = require('fs-extra'); |
||||
|
const path = require('path'); |
||||
|
|
||||
|
// Official list of TLDs should be fetched from:
|
||||
|
// https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
||||
|
|
||||
|
// You must have received a copy of the list along with `up`
|
||||
|
// Run `npm run build` to update the cached list
|
||||
|
|
||||
|
function isFQDN(domain) { |
||||
|
|
||||
|
// Importing and parsing `tlds.txt` file
|
||||
|
const tldspath = path.join(__dirname, '/../assets/tlds.txt'); |
||||
|
const tlds = fs.readFileSync(tldspath, 'utf8') |
||||
|
.split(/[\r\n]+/) |
||||
|
.filter(x => !x.startsWith('#')); |
||||
|
|
||||
|
if (domain.length > 253) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
const labels = domain.split('.').reverse(); |
||||
|
|
||||
|
if (labels.length < 2) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
const [ tld ] = labels; |
||||
|
|
||||
|
if (!tlds.includes(tld.toUpperCase())) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
for (const label of labels) { |
||||
|
|
||||
|
const len = label.length; |
||||
|
|
||||
|
if (len > 63 || len === 0) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
for (let i = 0; i < len; i++) { |
||||
|
|
||||
|
const char = label[i]; |
||||
|
|
||||
|
if ((i === 0 || i === len - 1) && char === '-') { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
if (!char.match(/^[a-zA-Z0-9-]$/)) { |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
module.exports = isFQDN; |
@ -0,0 +1,56 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const { EOL } = require('os'); |
||||
|
|
||||
|
const fs = require('fs-extra'); |
||||
|
|
||||
|
const removeFromArray = require('./removeFromArray'); |
||||
|
const listFilePath = require('./nginxPath').serversUp; |
||||
|
|
||||
|
function appendToList(domain, outPort, inPort) { |
||||
|
|
||||
|
inPort = inPort || undefined; |
||||
|
let jsonFile = { "domains": [] }; |
||||
|
const domBlock = { |
||||
|
"domain": domain, |
||||
|
"outPort": outPort |
||||
|
}; |
||||
|
|
||||
|
if (!inPort) { |
||||
|
domBlock.type = "static"; |
||||
|
} else { |
||||
|
domBlock.type = "proxy"; |
||||
|
domBlock.inPort = inPort; |
||||
|
} |
||||
|
|
||||
|
if (fs.existsSync(listFilePath())) { |
||||
|
const jsonBuffer = JSON.parse(fs.readFileSync(listFilePath())); |
||||
|
jsonFile.domains = removeFromArray(jsonBuffer.domains, domain, outPort); |
||||
|
} |
||||
|
jsonFile.domains.push(domBlock); |
||||
|
jsonFile = JSON.stringify(jsonFile, null, '\t'); |
||||
|
fs.writeFileSync(listFilePath(), jsonFile); |
||||
|
} |
||||
|
|
||||
|
function removeFromList (domain, outPort) { |
||||
|
if (fs.existsSync(listFilePath())) { |
||||
|
let jsonFile = { "domains": [] }; |
||||
|
const jsonBuffer = JSON.parse(fs.readFileSync(listFilePath())); |
||||
|
jsonFile.domains = removeFromArray(jsonBuffer.domains, domain, outPort); |
||||
|
|
||||
|
jsonFile = JSON.stringify(jsonBuffer, null, '\t'); |
||||
|
fs.writeFileSync(listFilePath(), jsonFile); |
||||
|
} |
||||
|
else console.log(EOL + "No servers were created using `up` yet." + EOL); |
||||
|
} |
||||
|
|
||||
|
function readServers () { |
||||
|
const serversList = JSON.parse(fs.readFileSync(listFilePath())); |
||||
|
|
||||
|
if(!serversList.domains[0]) return undefined; |
||||
|
return serversList; |
||||
|
} |
||||
|
|
||||
|
module.exports.appendToList = appendToList; |
||||
|
module.exports.readServers = readServers; |
||||
|
module.exports.removeFromList = removeFromList; |
@ -1,7 +1,10 @@ |
|||||
// Simple function that takes a path and domain name, concatenates them with ".conf" and returns it.
|
'use strict'; |
||||
|
|
||||
|
// Simple function that takes a path and domain name,
|
||||
|
// concatenates them with ".conf" and returns it.
|
||||
|
|
||||
function conf(path, domain, outPort) { |
function conf(path, domain, outPort) { |
||||
return (path + domain + "." + outPort + ".conf"); |
return (path + domain + "." + outPort + ".conf"); |
||||
} |
} |
||||
|
|
||||
module.exports = conf; |
module.exports = conf; |
||||
|
@ -1,27 +1,50 @@ |
|||||
// These functions just return paths. Later, these should be modified to poll from nginx's config.
|
'use strict'; |
||||
|
|
||||
var available = "/etc/nginx/sites-available/"; |
// These functions just return paths.
|
||||
var enabled = "/etc/nginx/sites-enabled/"; |
// Later, these should be modified to poll from nginx's config.
|
||||
var wwwRoot = "/var/www/"; |
|
||||
|
|
||||
function availableSites() { |
const npath = "/etc/nginx/"; |
||||
return available; |
const enabled = npath + "sites-enabled/"; |
||||
|
const confDpath = npath + "conf.d/"; |
||||
|
const upPath = "/etc/up-serve/"; |
||||
|
const wwwRoot = upPath + "static/"; |
||||
|
const serverListPath = upPath + "servers"; |
||||
|
|
||||
|
function nginxPath() { |
||||
|
return npath; |
||||
} |
} |
||||
|
|
||||
function enabledSites() { |
function enabledSites() { |
||||
return enabled; |
return enabled; |
||||
} |
} |
||||
|
|
||||
|
function confD() { |
||||
|
return confDpath; |
||||
|
} |
||||
|
|
||||
function webRoot() { |
function webRoot() { |
||||
return wwwRoot; |
return wwwRoot; |
||||
} |
} |
||||
|
|
||||
function webRootDomain(domain, outPort) { |
function webRootDomain(domain, outPort) { |
||||
var rootWithDomain = wwwRoot + domain + "." + outPort; |
const path = wwwRoot + domain + "." + outPort; |
||||
return rootWithDomain; |
return path; |
||||
|
} |
||||
|
|
||||
|
function serversUp() { |
||||
|
const path = serverListPath + ".up"; |
||||
|
return path; |
||||
|
} |
||||
|
|
||||
|
function serversBakUp() { |
||||
|
const path = serverListPath + ".bak.up"; |
||||
|
return path; |
||||
} |
} |
||||
|
|
||||
module.exports.availableSites = availableSites; |
module.exports = nginxPath; |
||||
|
module.exports.confD = confD; |
||||
module.exports.enabledSites = enabledSites; |
module.exports.enabledSites = enabledSites; |
||||
module.exports.webRoot = webRoot; |
module.exports.webRoot = webRoot; |
||||
module.exports.webRootDomain = webRootDomain; |
module.exports.webRootDomain = webRootDomain; |
||||
|
module.exports.serversUp = serversUp; |
||||
|
module.exports.serversBakUp = serversBakUp; |
||||
|
@ -1,8 +1,11 @@ |
|||||
// Parse an input string and return a number if it is an integer. If it's a float, string, or array, return undefined.
|
'use strict'; |
||||
|
|
||||
|
// Parse an input string and return a number if it is an integer.
|
||||
|
// If it's a float, string, or array, return undefined.
|
||||
|
|
||||
function parseToInt(inputString) { |
function parseToInt(inputString) { |
||||
var parsing = /^\d+$/.exec(inputString); |
const parsing = /^\d+$/.exec(inputString); |
||||
return (parsing || [])[0]; |
return (parsing || [])[0]; |
||||
} |
} |
||||
|
|
||||
module.exports = parseToInt; |
module.exports = parseToInt; |
||||
|
@ -0,0 +1,16 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
function removeFromArray (arr, dom, port) { |
||||
|
let shouldDelete = []; |
||||
|
|
||||
|
for(let i = 0; i < arr.length; i++) |
||||
|
if((arr[i].domain == dom) && (arr[i].outPort == port)) |
||||
|
shouldDelete = [true, i]; |
||||
|
|
||||
|
if (shouldDelete[0]) { |
||||
|
arr.splice(shouldDelete[1], 1); |
||||
|
} |
||||
|
return arr; |
||||
|
} |
||||
|
|
||||
|
module.exports = removeFromArray; |
@ -1,23 +1,40 @@ |
|||||
var shell = require('shelljs'); |
'use strict'; |
||||
var chalk = require('chalk'); |
|
||||
|
const { EOL } = require('os'); |
||||
|
|
||||
|
const shell = require('shelljs'); |
||||
|
const chalk = require('chalk'); |
||||
|
|
||||
function requirements() { |
function requirements() { |
||||
|
|
||||
// Detect Linux or BSD
|
// Detect Linux or BSD
|
||||
var isLin = /^linux|^bsd/.test(process.platform); |
const isLin = /^linux|^bsd/.test(process.platform); |
||||
|
|
||||
// Throw if OS is not Linux or BSD. This should be changed to throw if not Debian based distro. Eventually, we can add more exceptions as `up` handles more cases.
|
// Throw if OS is not Linux or BSD.
|
||||
|
// This should be changed to throw if not Debian based distro.
|
||||
|
// Eventually, we can add more exceptions as `up` handles more cases.
|
||||
if(!isLin) { |
if(!isLin) { |
||||
shell.echo("\nThis is not a Linux or freeBSD distribution. This tool not written for this distro. Please raise an issue at " + chalk.cyan("https://github.com/codefeathers/up-serve") + " if you want `up` to be ported for your distro"); |
shell.echo(EOL + |
||||
|
"This is not a Linux or freeBSD distribution. " + |
||||
|
"This tool not written for this distro. " + |
||||
|
"Please raise an issue at " + |
||||
|
chalk.cyan("https://github.com/codefeathers/up-serve") + |
||||
|
" if you want `up` to be ported for your distro"); |
||||
|
shell.exit(1); |
||||
|
} |
||||
|
|
||||
|
// Check if sudo
|
||||
|
if (process.getuid() != 0) { |
||||
|
console.log("`up` requires root privileges to work. Please use `sudo up <command>`"); |
||||
shell.exit(1); |
shell.exit(1); |
||||
} |
} |
||||
|
|
||||
// Throw if Nginx is not found
|
// Throw if Nginx is not found
|
||||
if (!shell.which('nginx')) { |
if (!shell.which('nginx')) { |
||||
shell.echo('I need nginx to work. Install nginx first. https://nginx.org/'); |
shell.echo( |
||||
|
'I need nginx to work. Install nginx first. https://nginx.org/'); |
||||
shell.exit(1); |
shell.exit(1); |
||||
} |
} |
||||
|
|
||||
} |
} |
||||
|
|
||||
module.exports = requirements; |
module.exports = requirements; |
||||
|
Loading…
Reference in new issue