1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/etherpad_ynh.git synced 2024-09-03 18:36:10 +02:00

updated package for yunohost, to be tested

updated manifest
updated install and remove script  variable, multi-instance
updated nginx conf
added readme
This commit is contained in:
Bachir Soussi Chiadmi 2016-07-10 13:11:55 +02:00
parent 3dfaa71dba
commit 555ed332e3
7 changed files with 73 additions and 37 deletions

5
README.md Normal file
View file

@ -0,0 +1,5 @@
etherpad-lite app for yunohost
==============================
for yunohost 2.4, untested

View file

@ -1,6 +1,6 @@
location PATHTOCHANGE/ {
rewrite ^PATHTOCHANGE$ PATHTOCHANGE/ permanent;
proxy_pass http://localhost:9001/;
proxy_set_header Host $host;
proxy_buffering off;
location YNH_EXAMPLE_PATH/ {
rewrite ^YNH_EXAMPLE_PATH$ YNH_EXAMPLE_PATH/ permanent;
proxy_pass http://YNH_EXEMPLE_DOMAIN:YNH_EXAMPLE_PORT/;
proxy_set_header Host $host;
proxy_buffering off;
}

View file

@ -1,28 +1,42 @@
{
"name": "Etherpad Lite",
"id": "etherpadlite",
"packaging_format": 1,
"description": {
"en": "online editor providing collaborative editing in really real-time"
"en": "online editor providing collaborative editing in really real-time",
"fr": "editeur multiutilisiteur en temps réel en ligne"
},
"developer": {
"url":"http://etherpad.org/",
"license":"free",
"maintainer": {
"name": "beudbeud",
"email": "beudbeud@beudibox.fr",
"url": "http://etherpad.org/"
},
"requirements": {
"yunohost": ">= 2.4.0"
},
"multi_instance": "true",
"services":[
"nginx",
"mysql"
],
"arguments": {
"install" : [
{
"name": "domain",
"type":"domain",
"ask": {
"en": "Choose a domain for Etherpad"
"en": "Choose a domain for Etherpad",
"fr": "Choisissez un domaine pour Etherpad"
},
"example": "domain.org"
},
{
"name": "path",
"type":"path",
"ask": {
"en": "Choose a path for Etherpad"
"en": "Choose a path for Etherpad",
"fr": "Choisissez un chemin pour Etherpad"
},
"example": "/pad",
"default": "/pad"
@ -30,15 +44,12 @@
{
"name": "public_site",
"ask": {
"en": "Is it a public Etherpad ?"
"en": "Is it a public Etherpad ?",
"fr": "Etherpad est-il public?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}
]
}
}

3
scripts/backup Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
#TODO

View file

@ -1,18 +1,23 @@
#!/bin/bash
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$1
path=$2
is_public=$3
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_PUBLIC_SITE
port=9001
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a etherpadlite
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
exit 1
fi
# Save specific settings
sudo yunohost app setting etherpadlite is_public -v $is_public
# Store config on YunoHost instance
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app domain $path
ynh_app_setting_set $app domain $is_public
# Remove trailing "/" for next commands
path=${path%/}
@ -24,23 +29,28 @@ db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]'
key=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{40\}\).*/\1/p')
# Use 'etherpadlite' as database name and user
db_user=etherpadlite
# TODO change db for mutli-instance
db_user=$app
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd
sudo yunohost app setting etherpadlite mysqlpwd -v $db_pwd
sudo yunohost app setting $app mysqlpwd -v $db_pwd
# Install dependances
sudo apt-get install nodejs-legacy npm -y
if ! ynh_package_is_installed "nodejs-legacy" ; then
sudo apt-get install nodejs-legacy npm -y
fi
# Copy files to the right place
final_path=/var/www/etherpadlite
final_path=/var/www/$app
sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path
sudo cp ../conf/settings.json $final_path
#TODO one service per instance ?
sudo cp ../conf/etherpad-lite /etc/init.d/
sudo chmod +x /etc/init.d/etherpad-lite
sudo update-rc.d etherpad-lite defaults
sudo mkdir /var/log/etherpad-lite/
sudo touch /var/log/etherpad-lite/etherpad-lite.log
sudo chown www-data /var/log/etherpad-lite/etherpad-lite.log
@ -49,25 +59,28 @@ sudo npm cache clear
sudo $final_path/bin/installDeps.sh > /dev/null 2>&1
sudo npm install forever -g > /dev/null 2>&1
# Change variables in Wordpress configuration
# Change variables in etherpad configuration
sudo sed -i "s/yunouser/$db_user/g" $final_path/settings.json
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/settings.json
sudo sed -i "s/yunobase/$db_user/g" $final_path/settings.json
sudo sed -i "s/KEY/$key/g" $final_path/settings.json
# Set permissions to roundcube directory
# Set permissions to etherpad directory
sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_EXAMPLE_PORT@$port@g" ../conf/nginx.conf
sed -i "s@YNH_EXEMPLE_DOMAIN@$domain@g" ../conf/nginx.conf
if [ "$path" = "" ];
then
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/etherpadlite.conf
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app.conf
else
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/etherpadlite.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
if [ "$is_public" = "Yes" ];

View file

@ -3,14 +3,15 @@
db_user=etherpadlite
db_name=etherpadlite
root_pwd=$(sudo cat /etc/yunohost/mysql)
domain=$(sudo yunohost app setting etherpadlite domain)
domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path)
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
sudo rm -rf /var/www/etherpadlite
sudo rm -f /etc/nginx/conf.d/$domain.d/etherpadlite.conf
sudo rm -Rf /var/log/etherpad-lite/
rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo service nginx reloadsudo rm -Rf /var/log/etherpad-lite/
sudo update-rc.d etherpad-lite remove
sudo service etherpad-lite stop
sudo rm /etc/init.d/etherpad-lite

3
scripts/restore Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
#TODO