mirror of
https://github.com/YunoHost-Apps/kiwiirc_ynh.git
synced 2024-09-03 19:35:59 +02:00
first working version
This commit is contained in:
commit
2f3083d9c4
8 changed files with 555 additions and 0 deletions
215
conf/config.js
Normal file
215
conf/config.js
Normal file
|
@ -0,0 +1,215 @@
|
|||
var conf = {};
|
||||
|
||||
// Run the Kiwi server under a different user/group
|
||||
conf.user = "kiwiirc";
|
||||
conf.group = "kiwiirc";
|
||||
|
||||
|
||||
// Log file location
|
||||
conf.log = "/var/log/ynh-kiwiirc.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/";
|
||||
|
||||
// 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 = 'Web IRC Client';
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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 = [];
|
||||
|
||||
|
||||
|
||||
|
||||
// WebIRC passwords enabled for this server
|
||||
conf.webirc_pass = {
|
||||
//"irc.network.com": "configured_webirc_password",
|
||||
//"127.0.0.1": "foobar"
|
||||
};
|
||||
|
||||
// Some IRCDs require the clients IP via the username/ident
|
||||
conf.ip_as_username = [
|
||||
//"irc.network.com",
|
||||
//"127.0.0.1"
|
||||
];
|
||||
|
||||
// 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 = "YNH_BASE_PATH";
|
||||
|
||||
|
||||
/*
|
||||
* 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 quit message
|
||||
conf.quit_message = "http://www.kiwiirc.com/ - A hand-crafted IRC client";
|
||||
|
||||
|
||||
// Default settings for the client. These may be changed in the browser
|
||||
conf.client = {
|
||||
server: 'irc.kiwiirc.com',
|
||||
port: 6697,
|
||||
ssl: true,
|
||||
channel: '#kiwiirc',
|
||||
channel_key: '',
|
||||
nick: 'kiwi_?',
|
||||
settings: {
|
||||
theme: 'relaxed',
|
||||
channel_list_style: 'tabs',
|
||||
scrollback: 250,
|
||||
show_joins_parts: true,
|
||||
show_timestamps: false,
|
||||
use_24_hour_timestamps: true,
|
||||
mute_sounds: false,
|
||||
show_emoticons: true,
|
||||
count_all_activity: true
|
||||
},
|
||||
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 = "irc.kiwiirc.com";
|
||||
//conf.restrict_server_port = 6667;
|
||||
//conf.restrict_server_ssl = false;
|
||||
//conf.restrict_server_channel = "#kiwiirc";
|
||||
//conf.restrict_server_channel_key = "";
|
||||
//conf.restrict_server_password = "";
|
||||
//conf.restrict_server_nick = "kiwi_";
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Do not amend the below lines unless you understand the changes!
|
||||
*/
|
||||
module.exports.production = conf;
|
174
conf/init-script
Normal file
174
conf/init-script
Normal file
|
@ -0,0 +1,174 @@
|
|||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kiwiirc
|
||||
# Required-Start: $network $syslog
|
||||
# Required-Stop: $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: KiwiIRC Blogging Platform
|
||||
# Description: KiwiIRC: Just a blogging platform
|
||||
### END INIT INFO
|
||||
|
||||
# Kindly stolen from http://docs.kiwiirc.org/pl/installation/deploy/
|
||||
|
||||
# Do NOT "set -e"
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="KiwiIRC"
|
||||
NAME=ynh-kiwiirc
|
||||
GHOST_ROOT=/var/www/kiwiirc
|
||||
GHOST_GROUP=kiwiirc
|
||||
GHOST_USER=kiwiirc
|
||||
DAEMON=/usr/bin/node
|
||||
DAEMON_ARGS="$GHOST_ROOT/server/server.js -f"
|
||||
PIDFILEDIR=/var/run/yunohost/kiwiirc
|
||||
PIDFILE=$PIDFILEDIR/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
LOGFILE="/var/log/ynh-kiwiirc.log"
|
||||
export NODE_ENV=production
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
# I like to know what is going on
|
||||
VERBOSE=yes
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
# Set up folder structure
|
||||
mkdir -p $PIDFILEDIR
|
||||
chown -R $GHOST_USER:$GHOST_GROUP $PIDFILEDIR
|
||||
# Return
|
||||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
start-stop-daemon --start --quiet \
|
||||
--chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --background \
|
||||
--pidfile $PIDFILE --make-pidfile --exec $DAEMON --test > /dev/null \
|
||||
|| return 1
|
||||
|
||||
start-stop-daemon --start --quiet \
|
||||
--chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --background \
|
||||
--pidfile $PIDFILE --make-pidfile --exec /bin/bash -- -c "exec $DAEMON $DAEMON_ARGS >> $LOGFILE 2>&1" \
|
||||
|| return 2
|
||||
# Add code here, if necessary, that waits for the process to be ready
|
||||
# to handle requests from services started subsequently which depend
|
||||
# on this one. As a last resort, sleep for some dime.
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been stopped
|
||||
# 1 if daemon was already stopped
|
||||
# 2 if daemon could not be stopped
|
||||
# other if a failure occurred
|
||||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
|
||||
--pidfile $PIDFILE --name $NAME
|
||||
RETVAL="$?"
|
||||
[ "$RETVAL" = 2 ] && return 2
|
||||
# Wait for children to finish too if this is a daemon that forks
|
||||
# and if the daemon is only ever run from this initscript.
|
||||
# If the above conditions are not satisfied then add some other code
|
||||
# that waits for the process to drop all resources that could be
|
||||
# needed by services started subsequently. A last resort is to
|
||||
# sleep for some time.
|
||||
start-stop-daemon --stop --quiet --oknodo --retry=0/3/KILL/5 \
|
||||
--exec $DAEMON
|
||||
[ "$?" = 2 ] && return 2
|
||||
# Many daemons don't delete their pidfiles when they exit.
|
||||
rm -f $PIDFILE
|
||||
return "$RETVAL"
|
||||
}
|
||||
|
||||
# #
|
||||
# # Function that sends a SIGHUP to the daemon/service
|
||||
# #
|
||||
# do_reload() {
|
||||
# #
|
||||
# # If the daemon can reload its configuration without
|
||||
# # restarting (for example, when it is sent a SIGHUP),
|
||||
# # then implement that here.
|
||||
# #
|
||||
# start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE \
|
||||
# --name $NAME
|
||||
# return 0
|
||||
# }
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
#reload|force-reload)
|
||||
#
|
||||
# If do_reload() is not implemented then leave this commented out
|
||||
# and leave 'force-reload' as an alias for 'restart'.
|
||||
#
|
||||
#log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
#do_reload
|
||||
#log_end_msg $?
|
||||
#;;
|
||||
restart|force-reload)
|
||||
#
|
||||
# If the "reload" option is implemented then remove the
|
||||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
10
conf/logrotate
Normal file
10
conf/logrotate
Normal file
|
@ -0,0 +1,10 @@
|
|||
YNH_LOGFILE
|
||||
{
|
||||
weekly
|
||||
missingok
|
||||
rotate 12
|
||||
notifempty
|
||||
compress
|
||||
delaycompress
|
||||
copytruncate
|
||||
}
|
14
conf/nginx.conf
Normal file
14
conf/nginx.conf
Normal file
|
@ -0,0 +1,14 @@
|
|||
location YNH_LOCATION {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
|
||||
proxy_pass http://127.0.0.1:7778YNH_LOCATION;
|
||||
proxy_redirect default;
|
||||
|
||||
# Websocket support (from version 1.4)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
46
manifest.json
Normal file
46
manifest.json
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "KiwiIRC",
|
||||
"id": "kiwiirc",
|
||||
"description": {
|
||||
"en": "Web IRC client",
|
||||
"fr": "Client Web pour IRC"
|
||||
},
|
||||
"developer": {
|
||||
"name": "Julien Malik",
|
||||
"email": "julien.malik@paraiso.me",
|
||||
"url": "https://kiwiirc.com/"
|
||||
},
|
||||
"multi_instance": "false",
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for KiwiIRC",
|
||||
"fr": "Choisissez un domaine pour KiwiIRC"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for KiwiIRC",
|
||||
"fr": "Choisissez un path pour KiwiIRC"
|
||||
},
|
||||
"example": "/irc",
|
||||
"default": "/irc"
|
||||
},
|
||||
{
|
||||
"name": "public_site",
|
||||
"ask": {
|
||||
"en": "Is it a public KiwiIRC site ?",
|
||||
"fr": "Est-ce un site public ?"
|
||||
},
|
||||
"choices": ["Yes", "No"],
|
||||
"default": "Yes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
77
scripts/install
Normal file
77
scripts/install
Normal file
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
is_public=$3
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a kiwiirc
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Install dependencies..."
|
||||
sudo apt-get update
|
||||
sudo apt-get install nodejs-legacy npm -y
|
||||
|
||||
version=de1607bf1e9ba4429a10f895a6ec45c54daa3161
|
||||
echo "Downloading KiwiIRC $version..."
|
||||
mkdir ../tmp
|
||||
sudo wget -O ../tmp/kiwiirc-$version.tar.gz "https://github.com/prawnsalad/KiwiIRC/archive/de1607bf1e9ba4429a10f895a6ec45c54daa3161.tar.gz"
|
||||
|
||||
echo "Deploying source files..."
|
||||
cd ../tmp && tar xvzf ../tmp/kiwiirc-$version.tar.gz && cd ../scripts
|
||||
final_path=/var/www/kiwiirc
|
||||
sudo mkdir -p $final_path
|
||||
sudo useradd -d $final_path kiwiirc
|
||||
|
||||
sudo cp -r ../tmp/KiwiIRC-$version/* $final_path
|
||||
#sudo cp ../conf/npm-shrinkwrap.json $final_path
|
||||
sudo chown -R kiwiirc: $final_path
|
||||
|
||||
echo "Installing KiwiIRC with NPM..."
|
||||
sudo su --shell /bin/bash --command "cd $final_path && npm install --production --registry http://registry.npmjs.org" kiwiirc
|
||||
|
||||
echo "Cleaning up install tree..."
|
||||
sudo rm -rf $final_path/.npm
|
||||
|
||||
echo "Deploying configuration..."
|
||||
sed -i "s@YNH_BASE_PATH@${path}@g" ../conf/config.js
|
||||
sudo cp ../conf/config.js $final_path/config.js
|
||||
sudo chown kiwiirc: $final_path/config.js
|
||||
sudo chmod 644 $final_path/config.js
|
||||
|
||||
echo "Post install step... building client side"
|
||||
sudo su --shell /bin/bash --command "cd $final_path && node $final_path/server/server.js build" kiwiirc
|
||||
|
||||
echo "Setting up init script..."
|
||||
logfile=/var/log/ynh-kiwiirc.log
|
||||
sudo touch $logfile
|
||||
sudo chown kiwiirc: $logfile
|
||||
sed -i "s@YNH_FINALPATH@$final_path@g" ../conf/init-script
|
||||
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/init-script
|
||||
sudo cp ../conf/init-script /etc/init.d/ynh-kiwiirc
|
||||
sudo chmod +x /etc/init.d/ynh-kiwiirc
|
||||
sudo update-rc.d ynh-kiwiirc defaults
|
||||
sudo service ynh-kiwiirc start
|
||||
sudo yunohost service add ynh-kiwiirc -l $logfile
|
||||
|
||||
echo "Setting up logrotate configuration..."
|
||||
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate
|
||||
sudo cp ../conf/logrotate /etc/logrotate.d/ynh-kiwiirc
|
||||
|
||||
echo "Nginx configuration..."
|
||||
sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/kiwiirc.conf
|
||||
|
||||
if [ $is_public = "Yes" ]; then
|
||||
sudo yunohost app setting kiwiirc skipped_uris -v "/"
|
||||
fi
|
||||
sudo yunohost app setting kiwiirc is_public -v $is_public
|
||||
|
||||
echo "Reloading Nginx (sso enabled)..."
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
echo "Success !"
|
15
scripts/remove
Normal file
15
scripts/remove
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
domain=$(sudo yunohost app setting kiwiirc domain)
|
||||
|
||||
sudo service ynh-kiwiirc stop
|
||||
sudo update-rc.d ynh-kiwiirc remove
|
||||
sudo rm /etc/init.d/ynh-kiwiirc
|
||||
sudo yunohost service remove ynh-kiwiirc
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/kiwiirc.conf
|
||||
sudo rm -f /var/log/ynh-kiwiirc.log
|
||||
sudo rm -rf /var/run/yunohost/kiwiirc
|
||||
sudo rm -f /etc/logrotate.d/ynh-kiwiirc
|
||||
|
||||
# remove user so that it does not hold resource
|
||||
sudo userdel --remove kiwiirc
|
4
scripts/upgrade
Normal file
4
scripts/upgrade
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "TODO"
|
||||
exit 1
|
Loading…
Reference in a new issue