diff --git a/conf/lufi.conf.template b/conf/lufi.conf.template index 2f84989..7052d31 100644 --- a/conf/lufi.conf.template +++ b/conf/lufi.conf.template @@ -9,12 +9,7 @@ listen => ['http://127.0.0.1:__PORT__'], # if you use Lufi behind a reverse proxy like Nginx, you want ro set proxy to 1 # if you use Lufi directly, let it commented - proxy => 1, - - # Please read http://mojolicious.org/perldoc/Mojo/Server/Hypnotoad#workers - # to adjust this to your server - workers => 30, - clients => 1, + proxy => 1, }, # put a way to contact you here and uncomment it @@ -83,7 +78,7 @@ # example: you want to have Lufi under https://example.org/lufi/ # => set prefix to '/lufi' or to '/lufi/', it doesn't matter # optional, defaut is / - prefix => '__PATH__/', + prefix => '__PATH__', # array of authorized domains for API calls. # if you want to authorize everyone to use the API: ['*'] diff --git a/conf/nginx.conf b/conf/nginx.conf index 96f43a4..468fdca 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,7 +5,7 @@ location __PATH__ { # This is important for user's privacy ! access_log off; - error_log /var/log/nginx/lutim.error.log; + error_log /var/log/nginx/lufi.error.log; # This is important ! Make it OK with your Lutim configuration client_max_body_size 40M; @@ -15,7 +15,7 @@ location __PATH__ { add_header Cache-Control "public, max-age=315360000"; } - proxy_pass http://127.0.0.1:__PORT__/; + proxy_pass http://127.0.0.1:__PORT__/__PATH__; # Really important ! Lufi uses WebSocket, it won't work without this proxy_set_header Upgrade $http_upgrade ; diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..7d5f8ef --- /dev/null +++ b/scripts/backup @@ -0,0 +1,30 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +# Source app helpers +source /usr/share/yunohost/helpers + +# Get multi-instances specific variables +app=$YNH_APP_INSTANCE_NAME + +# Retrieve app settings +domain=$(ynh_app_setting_get "$app" domain) + +# Copy the app files +final_path="/var/www/${app}" +ynh_backup "${final_path}" "sources" 1 + +# Copy the nginx conf files +ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +# Copy the php-fpm conf files +ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" +ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "php-fpm.ini" + +# Copy the lufi fonf file +ynh_backup "${final_path}/lufi.conf" "lufi.conf" +ynh_backup "/etc/default/lufi" "default_lufi" +ynh_backup "/etc/systemd/system/lufi.service" "systemd_lufi.service" +ynh_backup "/etc/cron.d/${app}" "cron_lufi" +ynh_backup "/etc/logrotate.d/${app}" "logrotate_lufi" \ No newline at end of file diff --git a/scripts/install b/scripts/install index 4940057..965ac92 100644 --- a/scripts/install +++ b/scripts/install @@ -124,10 +124,6 @@ then fi CHECK_VAR "$arch_dir" "arch_dir empty" sudo sed -i "s@__ARCHDIR__@$arch_dir@g" "$final_path/script/lufi" -# TODO: fix a bug service restart -# Add contact -sudo sed -i "/thumbnail_size => 100,/a contact => 'webmaster@$domain'\," "${final_path}/lib/Lutim.pm" - # Change variables in nginx configuration sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..35bc3df --- /dev/null +++ b/scripts/restore @@ -0,0 +1,103 @@ +#!/bin/bash +# This restore script is adapted to Yunohost >=2.4 + +# Exit on command errors and treat unset variables as an error +set -eu + +# Source app helpers +source /usr/share/yunohost/helpers + +# The parameter $app is the id of the app instance ex: ynhexample__2 +app=$YNH_APP_INSTANCE_NAME + +# Get old parameter of the app +domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) + +# Check domain/path availability +sudo yunohost app checkurl "${domain}${path}" -a "${app}" \ + || ynh_die "Path not available: ${domain}${path}" + +# Check $final_path +final_path="/var/www/${app}" +if [ -d "${final_path}" ]; then + ynh_die "There is already a directory: ${final_path}" +fi + +# Check configuration files nginx +nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" +if [ -f "${nginx_conf}" ]; then + ynh_die "The NGINX configuration already exists at '${nginx_conf}'. You should safely delete it before restoring this app." +fi + +# Check configuration files lufi +lufi_conf="${final_path}/lufi.conf" +if [ -f "${lufi_conf}" ]; then + ynh_die "The LUFI CONF configuration already exists at '${lufi_conf}'. You should safely delete it before restoring this app." +fi + +codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2) +CHECK_VAR "$codename" "codename empty" +ynh_app_setting_set $app codename $codename +if [ "$codename" = "wheezy" ] +then # On utilise le script init pour wheezy. + lufi_default="/etc/default/lufi" + if [ -f "${lufi_default}" ]; then + ynh_die "The LUFI DEFAULT configuration already exists at '${lufi_default}'. You should safely delete it before restoring this app." + fi +else # Et le script systemd à partir de jessie + lufi_systemd="/etc/systemd/system/lufi.service" + if [ -f "${lufi_default}" ]; then + ynh_die "The LUFI SYSTEMD configuration already exists at '${lufi_systemd}'. You should safely delete it before restoring this app." + fi +fi + +lufi_cron="/etc/cron.d/${app}" +if [ -f "${lufi_cron}" ]; then + ynh_die "The LUFI CRONTAB configuration already exists at '${lufi_cron}'. You should safely delete it before restoring this app." +fi + +lufi_logrotate="/etc/logrotate.d/${app}" +if [ -f "${lufi_logrotate}" ]; then + ynh_die "The LUFI LOGROTATE configuration already exists at '${lufi_logrotate}'. You should safely delete it before restoring this app." +fi + + # Restore sources & data +sudo cp -a ./sources "${final_path}" + +# Set permissions +sudo chown -R www-data: "${final_path}" + +# Restore nginx configuration files +sudo cp -a ./nginx.conf "${nginx_conf}" +# Restore php-fpm configuration files +sudo cp -a ./php-fpm.conf "${phpfpm_conf}" +sudo cp -a ./php-fpm.ini "${phpfpm_ini}" + +# Restore lufi configuration files +sudo cp -a ./lufi.conf "${lufi_conf}" + +codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2) +CHECK_VAR "$codename" "codename empty" +ynh_app_setting_set $app codename $codename +if [ "$codename" = "wheezy" ] +then # On utilise le script init pour wheezy. + sudo cp -a ./default_lufi "${lufi_default}" +else + sudo cp -a ./systemd_lufi.service "${lufi_systemd}" +fi + +sudo cp -a ./cron_lufi "${lufi_cron}" +sudo cp -a ./logrotate_lufi "${lufi_logrotate}" + +# Set ssowat config +if [ "$is_public" = "No" ]; +then + ynh_app_setting_delete $app skipped_uris +fi + +# Reload services +sudo systemctl reload php5-fpm +sudo systemctl reload nginx +sudo yunohost app ssowatconf \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..e245413 --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,47 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +source .fonctions # Loads the generic functions usually used in the script +source /usr/share/yunohost/helpers # Source YunoHost helpers + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +# Retrieve app settings +domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) + +CHECK_PATH # Checks and corrects the syntax of the path. + +final_path=/var/www/$app + +# Get source +SETUP_SOURCE + +# Modify Nginx configuration file and copy it to Nginx conf directory +sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf +sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf +sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf + +if [ "$is_public" = "Yes" ]; +then + sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf +fi + +# Create the php-fpm pool config +POOL_FPM + +# Setup SSOwat +ynh_app_setting_set "$app" is_public "$is_public" +if [ "$is_public" = "Yes" ]; +then + ynh_app_setting_set "$app" unprotected_uris "/" +fi + +# Reload Nginx +sudo systemctl reload php5-fpm +sudo systemctl reload nginx +sudo yunohost app ssowatconf \ No newline at end of file diff --git a/sources/source_dir b/sources/source_dir new file mode 100644 index 0000000..d03fe76 --- /dev/null +++ b/sources/source_dir @@ -0,0 +1 @@ +lufi-master-7db7688bc1e8bbe206f6717c98ece78d6e6a05fe \ No newline at end of file diff --git a/sources/source_md5 b/sources/source_md5 new file mode 100644 index 0000000..1e39d80 --- /dev/null +++ b/sources/source_md5 @@ -0,0 +1 @@ +97091eb255f4b3389fd52e36b7860c1e lufi.zip \ No newline at end of file diff --git a/sources/source_url b/sources/source_url index 9fb3a18..a7e8be1 100644 --- a/sources/source_url +++ b/sources/source_url @@ -1 +1 @@ -https://git.framasoft.org/luc/lufi/repository/archive.zip?ref=master +https://git.framasoft.org/luc/lufi/repository/archive.zip?ref=master \ No newline at end of file