From 84d082da1b4960e0c4fdd5ba0e1d9616c8781e72 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 27 Jan 2016 18:01:08 +0000 Subject: [PATCH 1/3] Added kiwiirc and dependencies --- modules/rhizo_base/files/etc/sv/kiwi/log/run | 4 + modules/rhizo_base/files/etc/sv/kiwi/run | 2 + modules/rhizo_base/manifests/apt.pp | 9 +- modules/rhizo_base/manifests/init.pp | 1 + modules/rhizo_base/manifests/kiwi.pp | 48 ++++ modules/rhizo_base/manifests/runit.pp | 6 + modules/rhizo_base/templates/config.js.erb | 258 +++++++++++++++++++ 7 files changed, 326 insertions(+), 2 deletions(-) create mode 100755 modules/rhizo_base/files/etc/sv/kiwi/log/run create mode 100755 modules/rhizo_base/files/etc/sv/kiwi/run create mode 100644 modules/rhizo_base/manifests/kiwi.pp create mode 100644 modules/rhizo_base/templates/config.js.erb diff --git a/modules/rhizo_base/files/etc/sv/kiwi/log/run b/modules/rhizo_base/files/etc/sv/kiwi/log/run new file mode 100755 index 0000000..6956062 --- /dev/null +++ b/modules/rhizo_base/files/etc/sv/kiwi/log/run @@ -0,0 +1,4 @@ +#!/bin/sh +LOG_FOLDER=/var/log/kiwi +mkdir -p $LOG_FOLDER +exec svlogd -tt $LOG_FOLDER diff --git a/modules/rhizo_base/files/etc/sv/kiwi/run b/modules/rhizo_base/files/etc/sv/kiwi/run new file mode 100755 index 0000000..dd0943b --- /dev/null +++ b/modules/rhizo_base/files/etc/sv/kiwi/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/share/kiwiirc/kiwi start diff --git a/modules/rhizo_base/manifests/apt.pp b/modules/rhizo_base/manifests/apt.pp index 70b32cf..f22cbc3 100644 --- a/modules/rhizo_base/manifests/apt.pp +++ b/modules/rhizo_base/manifests/apt.pp @@ -33,5 +33,10 @@ class rhizo_base::apt { key_server => 'subkeys.pgp.net', include_src => false, } - - } \ No newline at end of file + apt::source { 'nodesource': + location => 'https://deb.nodesource.com/node_0.10', + release => 'precise', + repos => 'main', + key_source => 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key' + } + } diff --git a/modules/rhizo_base/manifests/init.pp b/modules/rhizo_base/manifests/init.pp index 53e5f99..795a9f6 100644 --- a/modules/rhizo_base/manifests/init.pp +++ b/modules/rhizo_base/manifests/init.pp @@ -150,6 +150,7 @@ class rhizo_base { include rhizo_base::sudo include rhizo_base::users include rhizo_base::icinga + include rhizo_base::kiwi #Rizhomatica scripts diff --git a/modules/rhizo_base/manifests/kiwi.pp b/modules/rhizo_base/manifests/kiwi.pp new file mode 100644 index 0000000..58af84d --- /dev/null +++ b/modules/rhizo_base/manifests/kiwi.pp @@ -0,0 +1,48 @@ +# Class: rhizo_base::ircd +# +# This module manages Irc Chat Support +# +# Parameters: none +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +class rhizo_base::kiwi { + + $site_name = $rhizo_base::site_name + + file { '/usr/share/kiwiirc': + ensure => directory, + } + + file { '/usr/share/kiwiirc/config.js': + content => template('rhizo_base/config.js.erb'), + require => VcsRepo['/usr/share/kiwiirc'] + } + + exec { 'npm-install': + cwd => '/usr/share/kiwiirc', + command => '/usr/bin/npm install', + creates => '/usr/local/share/kiwiirc/node_modules', + require => VcsRepo['/usr/share/kiwiirc'] + } + + exec { 'build-script': + cwd => '/usr/share/kiwiirc', + command => '/usr/share/kiwiirc/kiwi build', + creates => '/usr/share/kiwiirc/client/assets/kiwi.js', + require => [ Exec['npm-install'], File['/usr/share/kiwiirc/config.js'] ] + } + + vcsrepo { '/usr/share/kiwiirc': + ensure => present, + provider => git, + source => 'https://github.com/prawnsalad/KiwiIRC.git', + #revision => '0.9.3', + require => [ File['/usr/share/kiwiirc'], Package['git'] ], + notify => [ Exec['build-script'], ] + } +} \ No newline at end of file diff --git a/modules/rhizo_base/manifests/runit.pp b/modules/rhizo_base/manifests/runit.pp index 2750113..cf1a185 100644 --- a/modules/rhizo_base/manifests/runit.pp +++ b/modules/rhizo_base/manifests/runit.pp @@ -44,4 +44,10 @@ class rhizo_base::runit { require => [ File['/etc/sv'], Class['rhizo_base::lcr'] ], } + file { '/etc/service/kiwi': + ensure => link, + target => '/etc/sv/kiwi', + require => [ File['/etc/sv'], Class['rhizo_base::kiwi'] ], + } + } \ No newline at end of file diff --git a/modules/rhizo_base/templates/config.js.erb b/modules/rhizo_base/templates/config.js.erb new file mode 100644 index 0000000..aa44ab9 --- /dev/null +++ b/modules/rhizo_base/templates/config.js.erb @@ -0,0 +1,258 @@ +var conf = {}; + +// Run the Kiwi server under a different user/group +conf.user = ""; +conf.group = ""; + + +// Log file location +conf.log = "kiwi.log"; + + + +/* + * Server listen blocks + */ + +// Do not edit this line! +conf.servers = []; + +// Example server block +conf.servers.push({ + port: 7778, + address: "0.0.0.0" +}); + +// Example SSL server block +//conf.servers.push({ +// port: 7777, +// address: "0.0.0.0", +// +// ssl: true, +// ssl_key: "server.key", +// ssl_cert: "cert.pem" +//}); + +// Network interface for outgoing connections +conf.outgoing_address = { + IPv4: '0.0.0.0' + //IPv6: '::' +}; + + +// Do we want to enable the built in Identd server? +conf.identd = { + enabled: false, + port: 113, + address: "0.0.0.0" +}; + + + + + + +// Where the client files are +conf.public_http = "client/"; + +// Transports available to the client. +// Behind an Apache reverse proxy? Uncomment the below - Apache does not support websockets! +//conf.client_transports = ['polling']; + +// Max connections per connection. 0 to disable +conf.max_client_conns = 5; + +// Max connections per server. 0 to disable. +// Setting is ignored if: +// - There is a WEBIRC password configured for the server, +// - Kiwi is configured to send the client's ip as a username for the server, or +// - Kiwi is running in restricted server mode. +conf.max_server_conns = 0; + +/* +* Default encoding to be used by the server +* As specified and limited to iconv-lite library support. +*/ +conf.default_encoding = 'utf8'; + + +/* +* Default GECOS (real name) for IRC connections +* %n will be replaced with the users nick +* %h will be replaced with the users hostname +*/ +conf.default_gecos = '%n is using a Web IRC client'; + + +/* +* Default ident / username for IRC connections +* %n will be replaced with the users nick +* %h will be replaced with the users hostname +* %i will be replaced with a hexed value of the users IP +*/ +conf.default_ident = '%i'; + + +/* +* Default quit message +* If a browser gets disconnected without sending a QUIT command, this +* message will be used instead. +*/ +conf.quit_message = 'http://www.kiwiirc.com/ - A hand-crafted IRC client'; + + +/* +* Auto reconnect if the IRC server disconnects a kiwi user +* Hundreds of connected users getting disconnected then reconnecting at once may see +* high CPU usage causing further dropouts. Set to false if under high usage. +*/ +conf.ircd_reconnect = true; + + +/* + * Client side plugins + * Array of URLs that will be loaded into the browser when the client first loads up + * See http://github.com/prawnsalad/KiwiIRC/wiki/Client-plugins + */ +conf.client_plugins = [ + // "http://server.com/kiwi/plugins/myplugin.html" +]; + + + + +// Directory to find the server modules +conf.module_dir = "../server_modules/"; + +// Which modules to load +conf.modules = [ + // Open a TCP port to control the Kiwi server (default port 8888) + // "control", + + // Automatically reload CSS files when a theme changes + // "client_file_watcher", +]; + + + + +// WebIRC password enabled for this server +conf.webirc_pass = ""; + +// Use the above *OR* the below webirc_pass option + +// Multiple WebIRC passwords may be used for multiple servers +//conf.webirc_pass = { +// "irc.network.com": "configured_webirc_password", +// "127.0.0.1": "foobar" +//}; + + +// Whether to verify IRC servers' SSL certificates against built-in well-known certificate authorities +conf.reject_unauthorised_certificates = false; + + + +/* + * Reverse proxy settings + * Reverse proxies that have been reported to work can be found at: + * https://kiwiirc.com/docs/installing/proxies + */ + +// Whitelisted HTTP proxies in CIDR format +conf.http_proxies = ["127.0.0.1/32"]; + +// Header that contains the real-ip from the HTTP proxy +conf.http_proxy_ip_header = "x-forwarded-for"; + +// Base HTTP path to the KIWI IRC client (eg. /kiwi) +conf.http_base_path = "/kiwi"; + + +/* + * SOCKS (version 5) proxy settings + * This feature is only available on node 0.10.0 and above. + * Do not enable it if you're running 0.8 or below or Bad Things will happen. + */ +conf.socks_proxy = {}; + +// Enable proxying outbound connections through a SOCKS proxy +conf.socks_proxy.enabled = false; + +// Proxy *all* outbound connections through a SOCKS proxy +conf.socks_proxy.all = false; + +// Use SOCKS proxy for these hosts only (if conf.sock_proxy.all === false) +conf.socks_proxy.proxy_hosts = [ + "irc.example.com" +]; + +// Host and port for the SOCKS proxy +conf.socks_proxy.address = '127.0.0.1'; +conf.socks_proxy.port = 1080; + +// Username and password for the SOCKS proxy +// Set user to null to disable password authentication +conf.socks_proxy.user = null; +conf.socks_proxy.pass = null; + + +// Default settings for the client. These may be changed in the browser +conf.client = { + server: '10.23.0.11', + port: 6667, + ssl: false, + channel: '#soporte', + channel_key: '', + nick: '<%= @site_name %>', + settings: { + theme: 'relaxed', + text_theme: 'default', + channel_list_style: 'tabs', + scrollback: 250, + show_joins_parts: true, + show_timestamps: false, + use_24_hour_timestamps: true, + mute_sounds: false, + show_emoticons: true, + ignore_new_queries: false, + count_all_activity: false, + locale: null // null = use the browser locale settings + }, + window_title: 'Kiwi IRC' +}; + +// List of themes available for the user to choose from +conf.client_themes = [ + 'relaxed', + 'mini', + 'cli', + 'basic' +]; + + +// If set, the client may only connect to this 1 IRC server +conf.restrict_server = "10.23.0.11"; +//conf.restrict_server_port = 6667; +//conf.restrict_server_ssl = false; +//conf.restrict_server_password = ""; + + +/* + * If running multiple kiwi servers you may specify them here. + * Note: All kiwi servers must have the same conf.http_base_path config option. + * + * To force the client to connect to one other kiwi server, use: + * conf.client.kiwi_server = 'https://kiwi-server2.com'; + * + * To force the client to connect to a random kiwi server from a list, use: + * conf.client.kiwi_server = ['https://kiwi-server1.com', 'https://kiwi-server2.com']; + */ +//conf.client.kiwi_server = ''; + + + +/* + * Do not amend the below lines unless you understand the changes! + */ +module.exports.production = conf; From 6bbb86acccc63bd6c0a557c701cd16bb8fe1d716 Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 28 Jan 2016 16:28:34 +0000 Subject: [PATCH 2/3] Run Kiwi in foreground --- modules/rhizo_base/files/etc/sv/kiwi/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rhizo_base/files/etc/sv/kiwi/run b/modules/rhizo_base/files/etc/sv/kiwi/run index dd0943b..2f816f3 100755 --- a/modules/rhizo_base/files/etc/sv/kiwi/run +++ b/modules/rhizo_base/files/etc/sv/kiwi/run @@ -1,2 +1,2 @@ #!/bin/sh -exec /usr/share/kiwiirc/kiwi start +exec /usr/share/kiwiirc/kiwi -f From 4e3041305448813812a1dd3943de89c519a810e1 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 3 Feb 2016 17:00:23 +0000 Subject: [PATCH 3/3] run kiwi.js directly and not as root --- modules/rhizo_base/files/etc/sv/kiwi/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rhizo_base/files/etc/sv/kiwi/run b/modules/rhizo_base/files/etc/sv/kiwi/run index 2f816f3..6e4d7a6 100755 --- a/modules/rhizo_base/files/etc/sv/kiwi/run +++ b/modules/rhizo_base/files/etc/sv/kiwi/run @@ -1,2 +1,2 @@ #!/bin/sh -exec /usr/share/kiwiirc/kiwi -f +exec /usr/bin/chpst -urhizomatica /usr/bin/nodejs /usr/share/kiwiirc/server/kiwi.js -f