1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pelican_ynh.git synced 2024-09-03 19:46:35 +02:00

[fix] patch bugs

This commit is contained in:
YliesC 2017-10-20 19:06:13 +02:00
parent aeba5e1511
commit a2f37b8e27
7 changed files with 253 additions and 70 deletions

View file

@ -7,6 +7,7 @@
admin="john" (USER)
language="fr"
is_public=1 (PUBLIC|public=1|private=0)
author="john"
password="pass"
port="666" (PORT)
; Checks
@ -20,7 +21,7 @@
backup_restore=1
multi_instance=1
incorrect_path=1
port_already_use=1
port_already_use=0
change_url=0
;;; Levels
Level 1=auto

View file

@ -6,16 +6,16 @@
"en": "Pelican Static Site Generator",
"fr": "Pelican, un générateur de blog statique"
},
"version": "3.7.1",
"version": "1.0",
"url": "https://thegoldenkoala.com",
"license": "GPLv3",
"license": "free",
"maintainer": {
"name": "Ylies Chahi",
"email": "ylieschahi@gmail.com",
"url": "http://thegoldenkoala.com"
},
"requirements": {
"yunohost": ">= 2.4"
"yunohost": ">= 2.7.2"
},
"multi_instance": true,
"services": [
@ -49,7 +49,8 @@
"en": "Choose an author",
"fr": "Choisissez l'auteur"
},
"example": "johndoe"
"example": "johndoe",
"default": "John Doe"
},
{
"name": "title",

View file

@ -1,20 +1,56 @@
#!/bin/bash
# Exit on command errors and treat access to unset variables as an error
set -eu
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Source YNH helpers
. /usr/share/yunohost/helpers
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
is_public=$(ynh_app_setting_get "$app" is_public)
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
# Copy the app source files
ynh_backup "/var/www/$app" "www"
---------
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$final_path"
# Copy the conf files
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"

View file

@ -1,19 +1,33 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source app helpers and functions
source _common.sh
source /usr/share/yunohost/helpers
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
author=$YNH_APP_ARG_AUTHOR
title=$YNH_APP_ARG_TITLE
app=$YNH_APP_INSTANCE_NAME
#force location to be / or /foo
location=${path:-/}

View file

@ -1,17 +1,77 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -u
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source app helpers
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if yunohost service status | grep -q $app
then
echo "Remove $app service"
yunohost service remove $app
fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
yunohost firewall disallow TCP $port 2>&1
fi
# Delete app directory and configurations
sudo rm -rf "/var/www/"${app:-preventunsetvariable}
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
#sudo rm -rf "/var/www/"${app:-preventunsetvariable}
#[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Reload services
sudo service nginx reload || true
#sudo service nginx reload || true

View file

@ -1,45 +1,72 @@
#!/bin/bash
# Exit on command errors and treat access to unset variables as an error
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source app helpers and functions
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
is_public=$(ynh_app_setting_get "$app" is_public)
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
# is_public is now a boolean field
# is_public is now a boolean field
if [ "$is_public" = "Yes" ];
then
is_public=1
fi
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app \
|| ynh_die "The path ${domain}${path} is not available for app installation."
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
# Check destination directory
DESTDIR="/var/www/$app"
[[ -d $DESTDIR ]] && ynh_die \
"The destination directory '$DESTDIR' already exists.\
You should safely delete it before restoring this app."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
# Check configuration files
NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
[[ -f $NGINX_CONF ]] && ynh_die \
"The NGINX configuration already exists at '${NGINX_CONF}'.
You should safely delete it before restoring this app."
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
# Restore the app files
sudo cp -a ./www "$DESTDIR"
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_restore_file "$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R root: $final_path
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "/var/log/$app/APP.log"
# Restore configuration files
sudo cp -a ./conf/nginx.conf "$NGINX_CONF"
# Make app public if necessary
[[ $is_public -eq 1 ]] \
@ -47,5 +74,10 @@ sudo cp -a ./conf/nginx.conf "$NGINX_CONF"
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
systemctl reload nginx

View file

@ -1,25 +1,64 @@
#!/bin/bash
# Source app helpers and functions
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# LOAD SETTINGS
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
is_public=$(ynh_app_setting_get "$app" is_public)
author=$(ynh_app_setting_get "$app" author)
title=$(ynh_app_setting_get "$app" title)
# is_public is now a boolean field
if [ "$is_public" = "Yes" ];
then
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port)
author=$(ynh_app_setting_get $app author)
title=$(ynh_app_setting_get $app title)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0
is_public=0
fi
# If final_path doesn't exist, create it
if [ -z $final_path ]; then
final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
#force location to be / or /foo
location=${path:-/}