update some templates and fix some bugs
This commit is contained in:
parent
83f824a08b
commit
b3b44cdd33
|
@ -125,6 +125,12 @@ function serveControlsHelper() {
|
|||
});
|
||||
}
|
||||
|
||||
if (/\b(config)\b/.test(opts.pathname) && /get/i.test(req.method)) {
|
||||
res.setHeader('Content-Type', 'appliCation/json');
|
||||
res.end(JSON.stringify(state.config));
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// without proper config
|
||||
//
|
||||
|
@ -133,7 +139,7 @@ function serveControlsHelper() {
|
|||
var fresh;
|
||||
if (!opts.body) {
|
||||
res.statusCode = 422;
|
||||
res.end('{"error":{"message":"needs more arguments"}}');
|
||||
res.end('{"error":{"message":"module \'init\' needs more arguments"}}');
|
||||
return;
|
||||
}
|
||||
// relay, email, agree_tos, servernames, ports
|
||||
|
@ -263,7 +269,7 @@ function serveControlsHelper() {
|
|||
if (/http/.test(opts.pathname)) {
|
||||
if (!opts.body) {
|
||||
res.statusCode = 422;
|
||||
res.end('{"error":{"message":"needs more arguments"}}');
|
||||
res.end('{"error":{"message":"module \'http\' needs more arguments"}}');
|
||||
return;
|
||||
}
|
||||
if (opts.body[1]) {
|
||||
|
@ -285,7 +291,7 @@ function serveControlsHelper() {
|
|||
if (/tcp/.test(opts.pathname)) {
|
||||
if (!opts.body) {
|
||||
res.statusCode = 422;
|
||||
res.end('{"error":{"message":"needs more arguments"}}');
|
||||
res.end('{"error":{"message":"module \'tcp\' needs more arguments"}}');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -325,7 +331,7 @@ function serveControlsHelper() {
|
|||
var sshAuto;
|
||||
if (!opts.body) {
|
||||
res.statusCode = 422;
|
||||
res.end('{"error":{"message":"needs more arguments"}}');
|
||||
res.end('{"error":{"message":"module \'ssh\' needs more arguments"}}');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
<string>{TELEBIT_PATH}</string>
|
||||
|
||||
<key>StandardErrorPath</key>
|
||||
<string>{TELEBIT_PATH}/var/log/error.log</string>
|
||||
<string>{TELEBIT_LOG_DIR}/error.log</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>{TELEBIT_PATH}/var/log/info.log</string>
|
||||
<string>{TELEBIT_LOG_DIR}/info.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
<string>{TELEBIT_PATH}</string>
|
||||
|
||||
<key>StandardErrorPath</key>
|
||||
<string>{TELEBIT_PATH}/var/log/error.log</string>
|
||||
<string>{TELEBIT_LOG_DIR}/error.log</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>{TELEBIT_PATH}/var/log/info.log</string>
|
||||
<string>{TELEBIT_LOG_DIR}/info.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -39,6 +39,7 @@ Launcher.install = function (things, fn) {
|
|||
, telebitdJs: path.join(telebitRoot, 'bin/telebitd.js')
|
||||
, telebitConfig: path.join(os.homedir(), '.config/telebit/telebit.yml')
|
||||
, telebitdConfig: path.join(os.homedir(), '.config/telebit/telebitd.yml')
|
||||
, TELEBIT_LOG_DIR: path.join(os.homedir(), '.local/share/telebit/var/log')
|
||||
};
|
||||
vars.telebitBinTpl = path.join(telebitRoot, 'usr/share/dist/bin/telebit.tpl');
|
||||
vars.telebitNpm = path.resolve(vars.telebitNode, '../npm');
|
||||
|
@ -104,6 +105,7 @@ Launcher.install = function (things, fn) {
|
|||
try {
|
||||
mkdirp.sync(path.join(os.homedir(), 'Library/LaunchAgents'));
|
||||
mkdirp.sync(path.join(vars.telebitPath, 'bin'));
|
||||
mkdirp.sync(vars.TELEBIT_LOG_DIR);
|
||||
installLauncher.sync({
|
||||
file: {
|
||||
tpl: vars.telebitBinTpl
|
||||
|
@ -119,12 +121,15 @@ Launcher.install = function (things, fn) {
|
|||
, vars: vars
|
||||
});
|
||||
var launcherstr = (vars.userspace ? "" : "sudo ") + "launchctl ";
|
||||
exec(launcherstr + "unload -w " + launcher, things._execOpts, function (err, stdout, stderr) {
|
||||
err = getError(err, stderr);
|
||||
if (err) { fn(err); return; }
|
||||
var execstr = launcherstr + "unload -w " + launcher;
|
||||
exec(execstr, things._execOpts, function (/*err, stdout, stderr*/) {
|
||||
// we probably only need to skip the stderr (saying that it can't stop something that isn't started)
|
||||
//err = getError(err, stderr);
|
||||
//if (err) { fn(err); return; }
|
||||
//console.log((stdout||'').trim());
|
||||
//console.log('unload worked?');
|
||||
exec(launcherstr + "load -w " + launcher, things._execOpts, function (err, stdout, stderr) {
|
||||
execstr = launcherstr + "load -w " + launcher;
|
||||
exec(execstr, things._execOpts, function (err, stdout, stderr) {
|
||||
err = getError(err, stderr);
|
||||
if (err) { fn(err); return; }
|
||||
//console.log((stdout||'').trim());
|
||||
|
|
|
@ -282,17 +282,18 @@ set -e
|
|||
export TELEBIT_USER
|
||||
export TELEBIT_GROUP
|
||||
export TELEBIT_PATH
|
||||
TELEBIT_CONFIG=$HOME/.config/$my_app/$my_app.yml
|
||||
export TELEBIT_CONFIG=$HOME/.config/$my_app/$my_app.yml
|
||||
# TODO check both expected sock paths in client by default
|
||||
if [ "yes" == "$TELEBIT_USERSPACE" ]; then
|
||||
TELEBIT_TMP_CONFIGD=$HOME/.config/$my_app/$my_daemon.yml
|
||||
TELEBITD_CONFIG=$HOME/.config/$my_app/$my_daemon.yml
|
||||
TELEBIT_SOCK=$HOME/.local/share/$my_app/var/run/$my_app.sock
|
||||
TELEBIT_SOCK=${TELEBIT_SOCK:-$HOME/.local/share/$my_app/var/run/$my_app.sock}
|
||||
else
|
||||
TELEBIT_TMP_CONFIGD=$TELEBIT_TMP/etc/$my_daemon.yml
|
||||
TELEBITD_CONFIG=$TELEBIT_REAL_PATH/etc/$my_daemon.yml
|
||||
TELEBIT_SOCK=$TELEBIT_REAL_PATH/var/run/$my_app.sock
|
||||
TELEBIT_SOCK=${TELEBIT_SOCK:-$TELEBIT_REAL_PATH/var/run/$my_app.sock}
|
||||
fi
|
||||
export TELEBITD_CONFIG
|
||||
export TELEBIT_SOCK
|
||||
export TELEBIT_NODE=$TELEBIT_REAL_PATH/bin/node
|
||||
export TELEBIT_NPM=$TELEBIT_REAL_PATH/bin/npm
|
||||
|
@ -300,6 +301,7 @@ export TELEBIT_BIN=$TELEBIT_REAL_PATH/bin/telebit
|
|||
export TELEBITD_BIN=$TELEBIT_REAL_PATH/bin/telebitd
|
||||
export TELEBIT_JS=$TELEBIT_REAL_PATH/bin/telebit.js
|
||||
export TELEBITD_JS=$TELEBIT_REAL_PATH/bin/telebitd.js
|
||||
export TELEBIT_LOG_DIR=${TELEBIT_LOG_DIR:-$TELEBIT_REAL_PATH/var/log}
|
||||
export NODE_PATH="$TELEBIT_REAL_PATH/lib/node_modules"
|
||||
export NPM_CONFIG_PREFIX="$TELEBIT_REAL_PATH"
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ module.exports.sync = function (opts) {
|
|||
.replace(/{TELEBIT_RW_DIRS}/g, vars.telebitRwDirs || '{TELEBIT_RW_DIRS}')
|
||||
.replace(/{TELEBIT_CONFIG}/g, vars.telebitConfig || '{TELEBIT_CONFIG}')
|
||||
.replace(/{TELEBITD_CONFIG}/g, vars.telebitdConfig || '{TELEBITD_CONFIG}')
|
||||
.replace(/{TELEBIT_LOG_DIR}/g, vars.TELEBIT_LOG_DIR || '{TELEBIT_LOG_DIR}')
|
||||
;
|
||||
fs.writeFileSync(f.launcher, text, 'utf8');
|
||||
};
|
||||
|
@ -70,6 +71,7 @@ function run() {
|
|||
, telebitGroup: process.env.TELEBIT_GROUP || ('darwin' === os.platform() ? 'staff' : os.userInfo().username)
|
||||
, telebitConfig: process.env.TELEBIT_CONFIG || path.join(os.homedir(), '.config/telebit/telebit.yml')
|
||||
, telebitdConfig: process.env.TELEBITD_CONFIG || path.join(os.homedir(), '.config/telebit/telebitd.yml')
|
||||
, TELEBIT_LOG_DIR: process.env.TELEBIT_LOG_DIR || path.join(os.homedir(), '.local/share/telebit/var/log')
|
||||
};
|
||||
vars.telebitNpm = process.env.TELEBIT_NPM || path.resolve(vars.telebitNode, '../npm');
|
||||
vars.nodePath = process.env.NODE_PATH || path.resolve(vars.telebitNode, '../lib/node_modules');
|
||||
|
|
Loading…
Reference in New Issue