config.example.js | 6 +++--- kiwi | 7 +------ server/helpers/launcher.js | 9 ++++++++- server_modules/client_file_watcher.js | 4 ++-- server_modules/control.js | 4 ++-- server_modules/dnsbl.js | 2 +- server_modules/example.js | 2 +- server_modules/force_https.js | 2 +- server_modules/proxychecker.js | 2 +- server_modules/stats.js | 2 +- server_modules/web_agent_debugger.js | 2 +- 11 files changed, 21 insertions(+), 19 deletions(-) diff --git a/config.example.js b/config.example.js index 452b13c..57ad499 100644 --- a/config.example.js +++ b/config.example.js @@ -6,7 +6,7 @@ conf.group = ""; // Log file location -conf.log = "kiwi.log"; +conf.log = "/var/log/kiwi/kiwiirc.log"; @@ -53,7 +53,7 @@ conf.identd = { // Where the client files are -conf.public_http = "client/"; +conf.public_http = "/var/lib/kiwiirc/"; // Transports available to the client. // Behind an Apache reverse proxy? Uncomment the below - Apache does not support websockets! @@ -122,7 +122,7 @@ conf.client_plugins = [ // Directory to find the server modules -conf.module_dir = "../server_modules/"; +conf.module_dir = "/usr/lib/kiwiirc/server_modules/"; // Which modules to load conf.modules = [ diff --git a/kiwi b/kiwi index ddcdfdf..dca2dcc 100755 --- a/kiwi +++ b/kiwi @@ -1,11 +1,6 @@ #!/bin/sh -basedir=`dirname "$0"` -case `uname` in - *CYGWIN*) basedir=`cygpath -w "$basedir"`;; -esac - -$(command -v nodejs || command -v node) $basedir/server/helpers/launcher.js "$@" +node /usr/share/kiwiirc/server/helpers/launcher.js "$@" ret=$? exit $ret diff --git a/server/helpers/launcher.js b/server/helpers/launcher.js index d25a3a3..bff8623 100644 --- a/server/helpers/launcher.js +++ b/server/helpers/launcher.js @@ -1,5 +1,5 @@ var kiwi_app = '../kiwi.js'; -var pidfile = '../../kiwiirc.pid'; +var pidfile = '/run/kiwiirc/kiwiirc.pid'; var pidfile_arg; // Check if a pidfile has been set as an argument @@ -16,6 +16,13 @@ if (process.argv.indexOf('-p') > -1) { } } +try { + process.setgid('kiwiirc'); + process.setuid('kiwiirc'); +} catch (e) { + console.error('Cannot switch to user kiwiirc. Try running as root.') + process.exit(); +} var daemon = require('daemonize2').setup({ main: kiwi_app, diff --git a/server_modules/client_file_watcher.js b/server_modules/client_file_watcher.js index 2c3a017..d0601ae 100644 --- a/server_modules/client_file_watcher.js +++ b/server_modules/client_file_watcher.js @@ -6,7 +6,7 @@ var fs = require('fs'); var path = require('path'); -var kiwiModules = require('../server/modules'); +var kiwiModules = require('/usr/share/kiwiirc/server/modules'); var module = new kiwiModules.Module('client_file_watcher'); // Watch the common stylesheets -fs.watch('client/assets/css', alertClients); +fs.watch('/var/lib/kiwiirc/assets/css', alertClients); // Watch the theme stylesheets diff --git a/server_modules/control.js b/server_modules/control.js index d1c9cbf..1e187ec 100644 --- a/server_modules/control.js +++ b/server_modules/control.js @@ -5,8 +5,8 @@ */ var net = require('net'), - kiwiModules = require('../server/modules'), - ControlInterface = require('../server/controlinterface.js'), + kiwiModules = require('/usr/share/kiwiirc/server/modules'), + ControlInterface = require('/usr/share/kiwiirc/server/controlinterface.js'), _ = require('lodash'), winston = require('winston'); diff --git a/server_modules/dnsbl.js b/server_modules/dnsbl.js index 1a2c718..54a4300 100644 --- a/server_modules/dnsbl.js +++ b/server_modules/dnsbl.js @@ -5,7 +5,7 @@ */ var dns = require('dns'), - kiwiModules = require('../server/modules'); + kiwiModules = require('/usr/share/kiwiirc/server/modules'); // The available DNS zones to check against diff --git a/server_modules/example.js b/server_modules/example.js index d880c19..575dc5f 100644 --- a/server_modules/example.js +++ b/server_modules/example.js @@ -1,4 +1,4 @@ -var kiwiModules = require('../server/modules'); +var kiwiModules = require('/usr/share/kiwiirc/server/modules'); var module = new kiwiModules.Module('Example Module'); diff --git a/server_modules/force_https.js b/server_modules/force_https.js index 9ca8362..512ffed 100644 --- a/server_modules/force_https.js +++ b/server_modules/force_https.js @@ -4,7 +4,7 @@ * Keep users secure by redirecting them to HTTPS if not already */ -var kiwiModules = require('../server/modules'); +var kiwiModules = require('/usr/share/kiwiirc/server/modules'); var module = new kiwiModules.Module('force_https'); diff --git a/server_modules/proxychecker.js b/server_modules/proxychecker.js index 660defc..7fb96e6 100644 --- a/server_modules/proxychecker.js +++ b/server_modules/proxychecker.js @@ -5,7 +5,7 @@ */ var util = require('util'), - kiwiModules = require('../server/modules'); + kiwiModules = require('/usr/share/kiwiirc/server/modules'); var module = new kiwiModules.Module('proxychecker'); diff --git a/server_modules/stats.js b/server_modules/stats.js index 736ba17..a9de440 100644 --- a/server_modules/stats.js +++ b/server_modules/stats.js @@ -4,7 +4,7 @@ * Retreive stats for internal kiwi events. Handy for graphing */ -var kiwiModules = require('../server/modules'), +var kiwiModules = require('/usr/share/kiwiirc/server/modules'), fs = require('fs'); diff --git a/server_modules/web_agent_debugger.js b/server_modules/web_agent_debugger.js index 2358508..ef85e9f 100644 --- a/server_modules/web_agent_debugger.js +++ b/server_modules/web_agent_debugger.js @@ -6,7 +6,7 @@ */ -var kiwiModules = require('../server/modules'), +var kiwiModules = require('/usr/share/kiwiirc/server/modules'), agent = require('webkit-devtools-agent');