1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lufi_ynh.git synced 2024-09-03 19:36:28 +02:00

[fix] Bug proxy nginx + correct restore + clean code

This commit is contained in:
magikcypress 2017-04-02 16:06:17 +02:00
parent 5ab10e643b
commit d0c9580320
5 changed files with 31 additions and 12 deletions

View file

@ -15,7 +15,7 @@ location __PATH__ {
add_header Cache-Control "public, max-age=315360000"; add_header Cache-Control "public, max-age=315360000";
} }
proxy_pass http://127.0.0.1:__PORT__/__PATH__; proxy_pass http://127.0.0.1:__PORT____PATH__;
# Really important ! Lufi uses WebSocket, it won't work without this # Really important ! Lufi uses WebSocket, it won't work without this
proxy_set_header Upgrade $http_upgrade ; proxy_set_header Upgrade $http_upgrade ;

View file

@ -19,8 +19,9 @@ ynh_backup "${final_path}" "sources" 1
# Copy the nginx conf files # Copy the nginx conf files
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
# Copy the lufi fonf file # Copy the lufi conf file
ynh_backup "${final_path}/lufi.conf" "lufi.conf" ynh_backup "${final_path}/lufi.conf" "lufi.conf"
ynh_backup "/etc/systemd/system/lufi.service" "systemd_lufi.service" ynh_backup "/etc/systemd/system/lufi.service" "systemd_lufi.service"
ynh_backup "/etc/cron.d/${app}" "cron_lufi" ynh_backup "/etc/cron.d/${app}" "cron_lufi"
ynh_backup "/etc/logrotate.d/${app}" "logrotate_lufi" ynh_backup "/etc/logrotate.d/${app}" "logrotate_lufi"
ynh_backup "/var/log/${app}/production.log" "production.log"

View file

@ -38,7 +38,7 @@ CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilis
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
CHECK_VAR "$domain_regex" "domain_regex empty" CHECK_VAR "$domain_regex" "domain_regex empty"
FIND_PORT 8080 # Cherche un port libre. FIND_PORT 8095 # Cherche un port libre.
# Enregistre les infos dans la config YunoHost # Enregistre les infos dans la config YunoHost
ynh_app_setting_set $app admin $admin ynh_app_setting_set $app admin $admin

View file

@ -40,7 +40,7 @@ SECURE_REMOVE '/var/log/$app/' # Suppression des log
REMOVE_LOGROTATE_CONF # Suppression de la configuration de logrotate REMOVE_LOGROTATE_CONF # Suppression de la configuration de logrotate
ynh_package_remove carton || echo "ShellInABox already uninstalled" ynh_package_remove carton || echo "Carton already uninstalled"
ynh_package_remove perlmagick || echo "perlmagick already uninstalled" ynh_package_remove perlmagick || echo "perlmagick already uninstalled"
# Régénère la configuration de SSOwat # Régénère la configuration de SSOwat

View file

@ -15,6 +15,11 @@ domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path) path=$(ynh_app_setting_get $app path)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get $app is_public)
# Installation de perlmagick, interface perl pour imagemagick et de carton, gestionnaire de dépendances perl
ynh_package_update
ynh_package_install carton
ynh_package_install perlmagick
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "${app}" \ sudo yunohost app checkurl "${domain}${path}" -a "${app}" \
|| ynh_die "Path not available: ${domain}${path}" || ynh_die "Path not available: ${domain}${path}"
@ -32,13 +37,13 @@ if [ -f "${nginx_conf}" ]; then
fi fi
# Check configuration files lufi # Check configuration files lufi
lufi_conf="${final_path}/lufi.conf" lufi_conf="${final_path}/${app}.conf"
if [ -f "${lufi_conf}" ]; then 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." ynh_die "The LUFI CONF configuration already exists at '${lufi_conf}'. You should safely delete it before restoring this app."
fi fi
lufi_systemd="/etc/systemd/system/lufi.service" lufi_systemd="/etc/systemd/system/${app}.service"
if [ -f "${lufi_default}" ]; then if [ -f "${lufi_systemd}" ]; then
ynh_die "The LUFI SYSTEMD configuration already exists at '${lufi_systemd}'. You should safely delete it before restoring this app." ynh_die "The LUFI SYSTEMD configuration already exists at '${lufi_systemd}'. You should safely delete it before restoring this app."
fi fi
@ -52,6 +57,11 @@ 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." ynh_die "The LUFI LOGROTATE configuration already exists at '${lufi_logrotate}'. You should safely delete it before restoring this app."
fi fi
lufi_log="/var/log/${app}/production.log"
if [ -f "${lufi_log}" ]; then
ynh_die "The LUFI LOG configuration already exists at '${lufi_log}'. You should safely delete it before restoring this app."
fi
# Restore sources & data # Restore sources & data
sudo cp -a ./sources "${final_path}" sudo cp -a ./sources "${final_path}"
@ -60,9 +70,6 @@ sudo chown -R www-data: "${final_path}"
# Restore nginx configuration files # Restore nginx configuration files
sudo cp -a ./nginx.conf "${nginx_conf}" 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 # Restore lufi configuration files
sudo cp -a ./lufi.conf "${lufi_conf}" sudo cp -a ./lufi.conf "${lufi_conf}"
@ -73,6 +80,18 @@ sudo cp -a ./systemd_lufi.service "${lufi_systemd}"
sudo cp -a ./cron_lufi "${lufi_cron}" sudo cp -a ./cron_lufi "${lufi_cron}"
sudo cp -a ./logrotate_lufi "${lufi_logrotate}" sudo cp -a ./logrotate_lufi "${lufi_logrotate}"
# Create log production
sudo mkdir "/var/log/${app}/"
sudo cp -a ./production.log "${lufi_log}"
# Delete symbolic link and restore
sudo rm -fr "${final_path}/log/production.log"
sudo ln -s "/var/log/${app}/production.log" "${final_path}/log/production.log"
# Reload lufi service
sudo systemctl daemon-reload
sudo systemctl start lufi.service
sudo systemctl enable lufi.service
# Set ssowat config # Set ssowat config
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
@ -80,6 +99,5 @@ then
fi fi
# Reload services # Reload services
sudo systemctl reload php5-fpm
sudo systemctl reload nginx sudo systemctl reload nginx
sudo yunohost app ssowatconf sudo yunohost app ssowatconf