====== Installer Etherpad-Lite sur CentOS 6 ======
Il faut en prérequis une CentOS 6 de base et le dépôt EPEL configuré
===== Installer les dépendances =====
yum groupinstall "Development Tools"
yum install gzip git-core curl python openssl-devel npm nodejs mysql-server
===== Créer un compte utilisateur =====
useradd etherpad
===== Cloner le dépôt GIT =====
cd /opt
git clone git@github.com:ether/etherpad-lite.git
chown -R etherpad:etherpad ./etherpad-lite
cp -a etherpad-lite/settings.json.template etherpad-lite/settings.json
===== Créer la base de données =====
mysql -uroot
create database etherpad;
grant all privileges on etherpad.* to 'etherpad'@'localhost' identified by 'ThisIsMySQLPassw0rd';
flush privileges;
===== Adaptez la configuration =====
Éditez le fichier /opt/etherpad-lite/settings.json selon vos besoins, notamment la partie base de données pour utiliser MySQL
// [...]
"dbType" : "mysql",
"dbSettings" : {
"user" : "etherpad",
"port" : "/var/lib/mysql/mysql.sock",
"password": "ThisIsMySQLPassw0rd",
"database": "etherpad"
},
// [...]
===== Créer le script d'init =====
cat <<'EOF' > /etc/init.d/etherpad
#!/bin/bash
# chkconfig: 2345 90 90
# description: etherpad
### BEGIN INIT INFO
# Provides: etherpad
# Required-Start: network
# Required-Stop: network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start the etherpad-lite daemon
### END INIT INFO
START_CMD="/opt/etherpad-lite/bin/safeRun.sh"
LOG="/var/log/etherpad.log"
NAME="etherpad"
PGREP_STRING="/opt/etherpad-lite/bin/safeRun.sh"
PGREP_NODE_STRING="node /opt/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js"
PID_FILE="/var/run/etherpad/etherpad-dev.pid"
USER="etherpad"
### No further muckin' about needed!
CUR_USER=`whoami`
killproc() {
pkill -u $USER -f $PGREP_STRING
pkill -u $USER -f $PGREP_NODE_STRING
}
killproc_node(){
pkill -u $USER -f "$PGREP_NODE_STRING"
}
log_success_msg() {
echo "$*"
logger "$_"
}
log_failure_msg() {
echo "$*"
logger "$_"
}
check_proc() {
pgrep -u $USER -f $PGREP_STRING >/dev/null
}
check_proc_node(){
pgrep -u $USER -f $PGREP_NODE_STRING >/dev/null
}
start_script() {
if [ "${CUR_USER}" != "root" ] ; then
log_failure_msg "$NAME can only be started as 'root'."
exit -1
fi
check_proc
if [ $? -eq 0 ]; then
log_success_msg "$NAME is already running."
exit 0
fi
[ -d /var/run/$NAME ] || (mkdir /var/run/$NAME )
# make go now
/bin/su $USER -c "$START_CMD $LOG &"
# Sleep for a while to see if anything cries
sleep 5
check_proc
if [ $? -eq 0 ]; then
log_success_msg "Started $NAME."
else
log_failure_msg "Error starting $NAME."
exit -1
fi
}
stop_script() {
if [ "${CUR_USER}" != "root" ] ; then
log_failure_msg "You do not have permission to stop $NAME."
exit -1
fi
check_proc
if [ $? -eq 0 ]; then
killproc -p $PID_FILE >/dev/null
# Make sure it's dead before we return
until [ $? -ne 0 ]; do
sleep 1
check_proc
done
check_proc
if [ $? -eq 0 ]; then
log_failure_msg "Error stopping $NAME."
exit -1
else
log_success_msg "Stopped $NAME."
fi
else
log_failure_msg "$NAME is not running or you don't have permission to stop it"
fi
check_proc_node
if [ $? -eq 0 ]; then
killproc_node -p $PID_FILE >/dev/null
else
log_failure_msg "$NAME is not running or you don't have permission to stop it"
fi
}
check_status() {
check_proc
if [ $? -eq 0 ]; then
log_success_msg "$NAME is running."
else
log_failure_msg "$NAME is stopped."
exit -1
fi
}
case "$1" in
start)
start_script
;;
stop)
stop_script
;;
restart)
stop_script
start_script
;;
status)
check_status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
EOF
chmod +x /etc/init.d/etherpad
chkconfig etherpad on
===== Démarrer Etherpad-Lite =====
Si tout se passe bien, le démon devrait se lancer
/etc/init.d/etherpad start
===== Convertir la base en UTF-8 =====
mysql -uroot
ALTER DATABASE `etherpad` CHARACTER SET utf8 COLLATE utf8_bin;
USE etherpad;
ALTER TABLE `store` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
/etc/init.d/etherpad restart
Voilà, etherpad devrait être accessible (port 9001 par défaut)