1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00

Manifest v2

This commit is contained in:
Salamandar 2023-12-11 22:07:31 +01:00
parent ddc791d7e3
commit b8c7724605
14 changed files with 234 additions and 457 deletions

View file

@ -1,22 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=f356f5b8f496f626aba3ec0f9d9c40c4cb54e7f6
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,7 +0,0 @@
SOURCE_URL=http://download.dotclear.org/latest/dotclear-2.24.1.zip
SOURCE_SUM=7d6c75d0b0d5c6f6aefaf663a32a6d0df24f9a915f96327676ba4157329a3390
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/ ;
alias __INSTALL_DIR__/ ;
index index.php;

View file

@ -358,7 +358,7 @@ request_terminate_timeout = 1d
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = __FINALPATH__
chdir = __INSTALL_DIR__
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.

View file

@ -9,7 +9,7 @@ name = "Dotclear2 configuration"
[main.super_user.admin]
ask = "Super Administrator"
type = "user"
bind = "super_user:__FINALPATH__/inc/class.auth.ldap.php"
bind = "super_user:__INSTALL_DIR__/inc/class.auth.ldap.php"
[ynh_users]
name = "Yunohost users"
@ -23,7 +23,7 @@ help = "These permissions apply to the first connection of the user, the super u
type = "boolean"
yes = "true"
no = "false"
bind = "'admin':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'admin':__INSTALL_DIR__/inc/class.auth.ldap.php"
[ynh_users.content]
name = "Content permissions"
@ -34,14 +34,14 @@ help = "These permissions apply to the first connection of the user, the super u
type = "boolean"
yes = "true"
no = "false"
bind = "'contentadmin':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'contentadmin':__INSTALL_DIR__/inc/class.auth.ldap.php"
[ynh_users.content.blog_usage]
ask = "Manage their own entries and comments"
type = "boolean"
yes = "true"
no = "false"
bind = "'usage':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'usage':__INSTALL_DIR__/inc/class.auth.ldap.php"
visible = "blog_contentadmin != 'true'"
[ynh_users.content.blog_publish]
@ -49,7 +49,7 @@ help = "These permissions apply to the first connection of the user, the super u
type = "boolean"
yes = "true"
no = "false"
bind = "'publish':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'publish':__INSTALL_DIR__/inc/class.auth.ldap.php"
visible = "blog_contentadmin != 'true'"
[ynh_users.content.blog_delete]
@ -57,7 +57,7 @@ help = "These permissions apply to the first connection of the user, the super u
type = "boolean"
yes = "true"
no = "false"
bind = "'delete':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'delete':__INSTALL_DIR__/inc/class.auth.ldap.php"
visible = "blog_contentadmin != 'true'"
[ynh_users.media]
@ -69,14 +69,14 @@ help = "These permissions apply to the first connection of the user, the super u
type = "boolean"
yes = "true"
no = "false"
bind = "'media_admin':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'media_admin':__INSTALL_DIR__/inc/class.auth.ldap.php"
[ynh_users.media.blog_media]
ask = "Manage their own media items"
type = "boolean"
yes = "true"
no = "false"
bind = "'media':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'media':__INSTALL_DIR__/inc/class.auth.ldap.php"
visible = "blog_media_admin != 'true'"
[ynh_users.other_permissions]
@ -88,18 +88,18 @@ help = "These permissions apply to the first connection of the user, the super u
type = "boolean"
yes = "true"
no = "false"
bind = "'categories':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'categories':__INSTALL_DIR__/inc/class.auth.ldap.php"
[ynh_users.other_permissions.blog_pages]
ask = "Manage pages"
type = "boolean"
yes = "true"
no = "false"
bind = "'pages':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'pages':__INSTALL_DIR__/inc/class.auth.ldap.php"
[ynh_users.other_permissions.blog_blogroll]
ask = "Manage blogroll"
type = "boolean"
yes = "true"
no = "false"
bind = "'blogroll':__FINALPATH__/inc/class.auth.ldap.php"
bind = "'blogroll':__INSTALL_DIR__/inc/class.auth.ldap.php"

View file

@ -1,55 +0,0 @@
{
"name": "DotClear 2",
"id": "dotclear2",
"packaging_format": 1,
"description": {
"en": "Blog publishing application",
"fr": "Moteur de blog"
},
"version": "2.24.1~ynh1",
"license": "GPL-2.0-or-later",
"url": "https://dotclear.org/",
"upstream": {
"license": "GPL-2.0-or-later",
"website": "https://dotclear.org",
"demo": "https://www.softaculous.com/demos/Dotclear",
"admindoc": "https://dotclear.org/documentation/2.0",
"code": "https://git.dotclear.org/dev/dotclear"
},
"maintainer": {
"name": "kay0u",
"email": "pierre@kayou.io"
},
"requirements": {
"yunohost": ">= 11.0.0"
},
"multi_instance": true,
"services": [
"nginx",
"php7.3-fpm",
"mysql"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/dotclear2",
"default": "/dotclear2"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "admin",
"type": "user"
}
]
}
}

74
manifest.toml Normal file
View file

@ -0,0 +1,74 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "dotclear2"
name = "DotClear 2"
description.en = "Blog publishing application"
description.fr = "Moteur de blog"
version = "2.24.1~ynh1"
maintainers = ["kay0u"]
[upstream]
license = "GPL-2.0-or-later"
website = "https://dotclear.org"
demo = "https://www.softaculous.com/demos/Dotclear"
admindoc = "https://dotclear.org/documentation/2.0"
code = "https://git.dotclear.org/dev/dotclear"
cpe = "cpe:2.3:a:dotclear:dotclear"
fund = "https://dotclear.org/donate"
[integration]
yunohost = ">= 11.0.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = true
ldap = true
sso = "?"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/dotclear2"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
type = "user"
[resources]
[resources.sources.main]
url = "https://download.dotclear.org/latest/dotclear-2.24.1.zip"
sha256 = "7d6c75d0b0d5c6f6aefaf663a32a6d0df24f9a915f96327676ba4157329a3390"
prefetch = false
[resources.sources.main_attic]
# In case of a new version, the zip is moved from latest to attic...
url = "https://download.dotclear.org/attic/dotclear-2.24.1.zip"
sha256 = "7d6c75d0b0d5c6f6aefaf663a32a6d0df24f9a915f96327676ba4157329a3390"
prefetch = false
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = [
"mariadb-server",
"php8.2"
]
[resources.database]
type = "mysql"

View file

@ -10,35 +10,11 @@
source ../settings/scripts/_common.sh
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
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -13,56 +13,56 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
#REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
#REMOVEME? new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
# Add settings here as needed by your application
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
#REMOVEME? change_domain=0
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
#REMOVEME? change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
#REMOVEME? change_path=0
#REMOVEME? if [ "$old_path" != "$new_path" ]
then
change_path=1
#REMOVEME? change_path=1
fi
#=================================================
@ -72,28 +72,30 @@ fi
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
ynh_change_url_nginx_config
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
#REMOVEME? domain="$old_domain"
#REMOVEME? path="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
#REMOVEME? ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -116,7 +118,7 @@ ynh_mysql_execute_as_root --sql="UPDATE dc_setting SET setting_value='$new_theme
#=================================================
ynh_script_progression --message="Updating configuration file..."
php_config=$final_path/inc/config.php
php_config=$install_dir/inc/config.php
ynh_backup_if_checksum_is_different --file="$php_config"
@ -134,9 +136,9 @@ chown $app:$app "$php_config"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

View file

@ -9,103 +9,32 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# 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_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# In case of a new version, the url change from http://download.dotclear.org/latest/dotclear-X.X.X.tar.gz to http://download.dotclear.org/attic/dotclear-X.X.X.tar.gz
src_url=$(grep 'SOURCE_URL=' "../conf/app.src" | cut -d= -f2-)
if ! curl --output /dev/null --silent --head --fail "$src_url"; then
ynh_replace_string --match_string="latest" --replace_string="attic" --target_file="../conf/app.src"
fi
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$install_dir" -s main \
|| ynh_setup_source --dest_dir="$install_dir" -s main_attic
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
# https://dotclear.org/documentation/2.0/admin/install
mkdir -p "$final_path/"{cache,public}
setfacl -m d:u:www-data:rwx "$final_path/"{cache,public}
mkdir -p "$install_dir/"{cache,public}
setfacl -m d:u:www-data:rwx "$install_dir/"{cache,public}
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# SYSTEM CONFIGURATION
#=================================================ç
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
@ -113,14 +42,14 @@ ynh_add_fpm_config
#=================================================
ynh_script_progression --message="Adding a configuration file..."
php_config=$final_path/inc/config.php
php_config=$install_dir/inc/config.php
master_key=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=master_key --value=$master_key
cp $php_config.in $php_config
admin_url="${path_url%/}/admin/"
admin_url="${path%/}/admin/"
email=$(ynh_user_get_info --username=$admin --key=mail)
@ -156,7 +85,7 @@ ynh_app_setting_set --app=$app --key=blog_media --value=$blog_media
ynh_app_setting_set --app=$app --key=blog_pages --value=$blog_pages
ynh_app_setting_set --app=$app --key=blog_blogroll --value=$blog_blogroll
ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$final_path/inc/class.auth.ldap.php"
ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$install_dir/inc/class.auth.ldap.php"
cat << EOF >> $php_config
@ -174,16 +103,6 @@ chown $app:$app "$php_config"
#=================================================
ynh_script_progression --message="Setuping application with CURL..."
# Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..."
# Making the app public for curl
ynh_permission_update --permission="main" --add="visitors"
# Reload Nginx
ynh_systemd_action --service_name=nginx --action=reload
ynh_script_progression --message="Finalizing installation..." --weight=14
firstname=$(ynh_user_get_info --username=$admin --key=firstname)
lastname=$(ynh_user_get_info --username=$admin --key=lastname)
email=$(ynh_user_get_info --username=$admin --key=mail)
@ -195,9 +114,6 @@ installUrl="/admin/install/index.php"
ynh_local_curl $installUrl "u_email=$email" "u_firstname=$firstname" "u_name=$lastname" "u_login=$admin" "u_pwd=$password" "u_pwd2=$password"
# Remove the public access
ynh_permission_update --permission="main" --remove="visitors"
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -206,30 +122,9 @@ ynh_permission_update --permission="main" --remove="visitors"
ynh_script_progression --message="Configuring Fail2Ban..."
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Invalid credentials in $final_path/inc/class.auth.ldap.php .* client: <HOST>, .*https://$domain${path_url%/}/admin/auth.php"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
# Only the admin can access the admin panel of the app (if the app has an admin panel)
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
ynh_add_fail2ban_config \
--logpath="/var/log/nginx/${domain}-error.log" \
--failregex="Invalid credentials in $install_dir/inc/class.auth.ldap.php .* client: <HOST>, .*https://$domain${path%/}/admin/auth.php"
#=================================================
# END OF SCRIPT

View file

@ -10,69 +10,16 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
app=$YNH_APP_INSTANCE_NAME
ynh_remove_logrotate
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..."
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..."
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,102 +10,54 @@
source ../settings/scripts/_common.sh
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
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
# https://dotclear.org/documentation/2.0/admin/install
mkdir -p "$final_path/"{cache,public}
setfacl -m d:u:www-data:rwx "$final_path/"{cache,public}
mkdir -p "$install_dir/"{cache,public}
setfacl -m d:u:www-data:rwx "$install_dir/"{cache,public}
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# This should be a symetric version of what happens in the install script
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=3
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -12,30 +12,30 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
password=$(ynh_app_setting_get --app=$app --key=password)
master_key=$(ynh_app_setting_get --app=$app --key=master_key)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password)
#REMOVEME? master_key=$(ynh_app_setting_get --app=$app --key=master_key)
blog_admin=$(ynh_app_setting_get --app=$app --key=blog_admin)
blog_contentadmin=$(ynh_app_setting_get --app=$app --key=blog_contentadmin)
blog_usage=$(ynh_app_setting_get --app=$app --key=blog_usage)
blog_publish=$(ynh_app_setting_get --app=$app --key=blog_publish)
blog_delete=$(ynh_app_setting_get --app=$app --key=blog_delete)
blog_categories=$(ynh_app_setting_get --app=$app --key=blog_categories)
blog_media_admin=$(ynh_app_setting_get --app=$app --key=blog_media_admin)
blog_media=$(ynh_app_setting_get --app=$app --key=blog_media)
blog_pages=$(ynh_app_setting_get --app=$app --key=blog_pages)
blog_blogroll=$(ynh_app_setting_get --app=$app --key=blog_blogroll)
#REMOVEME? blog_admin=$(ynh_app_setting_get --app=$app --key=blog_admin)
#REMOVEME? blog_contentadmin=$(ynh_app_setting_get --app=$app --key=blog_contentadmin)
#REMOVEME? blog_usage=$(ynh_app_setting_get --app=$app --key=blog_usage)
#REMOVEME? blog_publish=$(ynh_app_setting_get --app=$app --key=blog_publish)
#REMOVEME? blog_delete=$(ynh_app_setting_get --app=$app --key=blog_delete)
#REMOVEME? blog_categories=$(ynh_app_setting_get --app=$app --key=blog_categories)
#REMOVEME? blog_media_admin=$(ynh_app_setting_get --app=$app --key=blog_media_admin)
#REMOVEME? blog_media=$(ynh_app_setting_get --app=$app --key=blog_media)
#REMOVEME? blog_pages=$(ynh_app_setting_get --app=$app --key=blog_pages)
#REMOVEME? blog_blogroll=$(ynh_app_setting_get --app=$app --key=blog_blogroll)
#=================================================
# CHECK VERSION
@ -47,16 +47,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
@ -68,16 +68,16 @@ ynh_script_progression --message="Ensuring downward compatibility..."
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# If install_dir doesn't exist, create it
if [ -z "$install_dir" ]; then
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
fi
if [ -n "$(ynh_app_setting_get --app=$app --key=is_public)" ]; then
#REMOVEME? if [ -n "$(ynh_app_setting_get --app=$app --key=is_public)" ]; then
ynh_app_setting_delete --app=$app --key=protected_uris
# Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7
@ -85,16 +85,16 @@ if [ -n "$(ynh_app_setting_get --app=$app --key=is_public)" ]; then
if ynh_permission_has_user --permission=main --user=visitors
then
ynh_app_setting_delete --app=$app --key=unprotected_uris
ynh_permission_update --permission "main" --add "visitors"
#REMOVEME? ynh_permission_update --permission "main" --add "visitors"
else
ynh_app_setting_delete --app=$app --key=unprotected_uris
fi
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
#REMOVEME? if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
#REMOVEME? ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
fi
if [ -z "$blog_admin" ] ||
@ -117,13 +117,13 @@ if [ -z "$blog_admin" ] ||
blog_media="false"
blog_pages="false"
blog_blogroll="false"
ynh_app_setting_set --app=$app --key=blog_admin --value=$blog_admin
ynh_app_setting_set --app=$app --key=blog_contentadmin --value=$blog_contentadmin
#REMOVEME? ynh_app_setting_set --app=$app --key=blog_admin --value=$blog_admin
#REMOVEME? ynh_app_setting_set --app=$app --key=blog_contentadmin --value=$blog_contentadmin
ynh_app_setting_set --app=$app --key=blog_usage --value=$blog_usage
ynh_app_setting_set --app=$app --key=blog_publish --value=$blog_publish
ynh_app_setting_set --app=$app --key=blog_delete --value=$blog_delete
ynh_app_setting_set --app=$app --key=blog_categories --value=$blog_categories
ynh_app_setting_set --app=$app --key=blog_media_admin --value=$blog_media_admin
#REMOVEME? ynh_app_setting_set --app=$app --key=blog_media_admin --value=$blog_media_admin
ynh_app_setting_set --app=$app --key=blog_media --value=$blog_media
ynh_app_setting_set --app=$app --key=blog_pages --value=$blog_pages
ynh_app_setting_set --app=$app --key=blog_blogroll --value=$blog_blogroll
@ -132,10 +132,10 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -152,16 +152,16 @@ then
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$install_dir"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
# https://dotclear.org/documentation/2.0/admin/install
mkdir -p "$final_path/"{cache,public}
setfacl -m d:u:www-data:rwx "$final_path/"{cache,public}
mkdir -p "$install_dir/"{cache,public}
setfacl -m d:u:www-data:rwx "$install_dir/"{cache,public}
#=================================================
# NGINX CONFIGURATION
@ -186,13 +186,13 @@ ynh_add_fpm_config
#=================================================
ynh_script_progression --message="Updating a configuration file..."
php_config=$final_path/inc/config.php
php_config=$install_dir/inc/config.php
ynh_backup_if_checksum_is_different --file=$php_config
cp $php_config.in $php_config
admin_url="${path_url%/}/admin/"
admin_url="${path%/}/admin/"
email=$(ynh_user_get_info --username=$admin --key=mail)
@ -207,7 +207,7 @@ ynh_replace_string --match_string="'DC_ADMIN_URL', ''" --replace_string="'DC_ADM
ynh_replace_string --match_string="'DC_ADMIN_MAILFROM', ''" --replace_string="'DC_ADMIN_MAILFROM', '$email'" --target_file=$php_config
# Adding LDAP login
ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$final_path/inc/class.auth.ldap.php"
ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$install_dir/inc/class.auth.ldap.php"
cat << EOF >> $php_config
@ -237,14 +237,14 @@ ynh_local_curl $adminUrl
ynh_script_progression --message="Reconfiguring Fail2Ban..."
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Invalid credentials in $final_path/inc/class.auth.ldap.php .* client: <HOST>, .*https://$domain${path_url%/}/admin/auth.php"
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Invalid credentials in $install_dir/inc/class.auth.ldap.php .* client: <HOST>, .*https://$domain${path%/}/admin/auth.php"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FRM..."
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server and PHP-FRM..."
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name=php$YNH_PHP_VERSION-fpm --action=reload
#=================================================

15
tests.toml Normal file
View file

@ -0,0 +1,15 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
preinstall = """
sudo apt update >/dev/null
"""
args.admin = "john"
test_upgrade_from.384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b.name = "10.8.0_ynh1"
test_upgrade_from.384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b.args.domain = "domain.tld"
test_upgrade_from.384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b.args.admin = "john"