diff --git a/conf/settings.json b/conf/settings.json deleted file mode 100644 index 03cc785..0000000 --- a/conf/settings.json +++ /dev/null @@ -1,149 +0,0 @@ -/* - This file must be valid JSON. But comments are allowed - - Please edit settings.json, not settings.json.template -*/ -{ - // Name your instance! - "title": "Etherpad", - - // favicon default name - // alternatively, set up a fully specified Url to your own favicon - "favicon": "favicon.ico", - - //IP and port which etherpad should bind at - "ip": "0.0.0.0", - "port" : 9001, - - // Session Key, used for reconnecting user sessions - // Set this to a secure string at least 10 characters long. Do not share this value. - "sessionKey" : "KEY", - - /* - // Node native SSL support - // this is disabled by default - // - // make sure to have the minimum and correct file access permissions set - // so that the Etherpad server can access them - - "ssl" : { - "key" : "/path-to-your/epl-server.key", - "cert" : "/path-to-your/epl-server.crt" - }, - - */ - - /*The Type of the database. You can choose between dirty, postgres, sqlite and mysql - //You shouldn't use "dirty" for for anything else than testing or development - "dbType" : "dirty", - //the database specific settings - "dbSettings" : { - "filename" : "var/dirty.db" - }, - */ - - // An Example of MySQL Configuration - "dbType" : "mysql", - "dbSettings" : { - "user" : "yunouser", - "host" : "localhost", - "password": "yunopass", - "database": "yunobase" - }, - - //the default text of a pad - "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n", - - /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */ - "requireSession" : false, - - /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */ - "editOnly" : false, - - /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, - but makes it impossible to debug the javascript/css */ - "minify" : true, - - /* How long may clients use served javascript code (in seconds)? Without versioning this - may cause problems during deployment. Set to 0 to disable caching */ - "maxAge" : 21600, // 60 * 60 * 6 = 6 hours - - /* This is the path to the Abiword executable. Setting it to null, disables abiword. - Abiword is needed to advanced import/export features of pads*/ - "abiword" : null, - - /* This setting is used if you require authentication of all users. - Note: /admin always requires authentication. */ - "requireAuthentication": false, - - /* Require authorization by a module, or a user with is_admin set, see below. */ - "requireAuthorization": false, - - /*when you use NginX or another proxy/ load-balancer set this to true*/ - "trustProxy": true, - - /* Privacy: disable IP logging */ - "disableIPlogging": false, - - /* Users for basic authentication. is_admin = true gives access to /admin. - If you do not uncomment this, /admin will not be available! */ - /* - "users": { - "admin": { - "password": "changeme1", - "is_admin": true - }, - "user": { - "password": "changeme1", - "is_admin": false - } - }, - */ - - // restrict socket.io transport methods - "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], - - /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ - "loglevel": "INFO", - - //Logging configuration. See log4js documentation for further information - // https://github.com/nomiddlename/log4js-node - // You can add as many appenders as you want here: - "logconfig" : - { "appenders": [ - { "type": "console" - //, "category": "access"// only logs pad access - } - /* - , { "type": "file" - , "filename": "your-log-file-here.log" - , "maxLogSize": 1024 - , "backups": 3 // how many log files there're gonna be at max - //, "category": "test" // only log a specific category - }*/ - /* - , { "type": "logLevelFilter" - , "level": "warn" // filters out all log messages that have a lower level than "error" - , "appender": - { Use whatever appender you want here } - }*/ - /* - , { "type": "logLevelFilter" - , "level": "error" // filters out all log messages that have a lower level than "error" - , "appender": - { "type": "smtp" - , "subject": "An error occured in your EPL instance!" - , "recipients": "bar@blurdybloop.com, baz@blurdybloop.com" - , "sendInterval": 60*5 // in secs -- will buffer log messages; set to 0 to send a mail for every message - , "transport": "SMTP", "SMTP": { // see https://github.com/andris9/Nodemailer#possible-transport-methods - "host": "smtp.example.com", "port": 465, - "secureConnection": true, - "auth": { - "user": "foo@example.com", - "pass": "bar_foo" - } - } - } - }*/ - ] } -} diff --git a/manifest.json b/manifest.json index 7fda41a..0af8faf 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "license":"free", "maintainer": { "name": "beudbeud", - "email": "beudbeud@beudibox.fr", + "email": "beudbeud@beudibox.fr" }, "requirements": { "yunohost": ">= 2.4.0" diff --git a/scripts/install b/scripts/install index d0364ad..8be90c2 100644 --- a/scripts/install +++ b/scripts/install @@ -2,6 +2,9 @@ app=$YNH_APP_INSTANCE_NAME +# Source YunoHost helpers +source /usr/share/yunohost/helpers + # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH @@ -15,26 +18,23 @@ if [[ ! $? -eq 0 ]]; then fi # 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 +ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path "$path" +ynh_app_setting_set "$app" is_public "$is_public" # Remove trailing "/" for next commands path=${path%/} -# Generate random password -db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') - # Generate random key -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') +# 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') +key=$(ynh_string_random 12) -# Use 'etherpadlite' as database name and user -# 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 $app mysqlpwd -v $db_pwd +# Generate MySQL password and create database +dbuser=$app +dbname=$app +dbpass=$(ynh_string_random 12) +ynh_app_setting_set "$app" mysqlpwd "$dbpass" +ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" # Install dependances if ! ynh_package_is_installed "nodejs-legacy" ; then @@ -46,14 +46,15 @@ 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 +#TODO one service per instance ? +sudo cp ../conf/etherpad-lite /etc/init.d/$app +sudo chmod +x /etc/init.d/$app +sudo update-rc.d $app defaults + +sudo mkdir /var/log/$app +sudo touch /var/log/$app/$app.log +sudo chown www-data /var/log/$app/$app.log sudo npm cache clear sudo $final_path/bin/installDeps.sh > /dev/null 2>&1 @@ -80,12 +81,12 @@ else 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" ]; -then - sudo yunohost app setting etherpadlite unprotected_uris -v "/" +# If app is public, add url to SSOWat conf as skipped_uris +if [[ $is_public -eq 1 ]]; then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set "$app" unprotected_uris "/" fi sudo yunohost app ssowatconf sudo service etherpad-lite start diff --git a/scripts/remove b/scripts/remove index 2b38851..b119bcf 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,17 +1,28 @@ #!/bin/bash -db_user=etherpadlite -db_name=etherpadlite + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Retrieve app settings +domain=$(ynh_app_setting_get "$app" domain) +path=$(ynh_app_setting_get "$app" path) +db_user=$(ynh_app_setting_get "$app" db_user) +db_name=$(ynh_app_setting_get "$app" db_name) +db_pwd=$(ynh_app_setting_get "$app" db_pwd) + root_pwd=$(sudo cat /etc/yunohost/mysql) -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 -rf /var/www/$app rm -f /etc/nginx/conf.d/$domain.d/$app.conf -sudo service nginx reloadsudo rm -Rf /var/log/etherpad-lite/ +sudo service nginx reload +sudo rm -Rf /var/log/$app -sudo update-rc.d etherpad-lite remove -sudo service etherpad-lite stop -sudo rm /etc/init.d/etherpad-lite +sudo update-rc.d $app remove +sudo service $app stop +sudo rm /etc/init.d/$app