1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00
This commit is contained in:
Éric Gaspar 2023-06-04 10:58:53 +02:00
parent 7c4bcff615
commit cc75f15cf9
11 changed files with 231 additions and 180 deletions

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz
SOURCE_SUM=93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz
SOURCE_SUM=67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
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__/;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1;

View file

@ -1,2 +1,2 @@
# Run poller periodically to update Hubzilla
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINALPATH__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1

65
manifest.toml Normal file
View file

@ -0,0 +1,65 @@
packaging_format = 2
id = "hubzilla"
name = "Hubzilla"
description.en = "Decentralized publication platform and social network."
description.fr = "Plateforme de publication décentralisée et un réseau social."
version = "8.4.1~ynh1"
maintainers = ["Anmol Sharma"]
[upstream]
license = "MIT"
website = "https://zotlabs.org/page/hubzilla/hubzilla-project"
code = "https://framagit.org/hubzilla/core"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 11.0.9"
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 = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
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]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
full_domain = true
[install.admin]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "user"
[install.database]
ask.en = "Choose the database to be used for the Hubzilla]"
ask.fr = "Choisissez la database de Hubzilla"
type = "string"
choices = ["mysql", "postgresql"]
default = "mysql"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://framagit.org/hubzilla/core/-/archive/8.4.1/core-8.4.1.tar.gz"
sha256 = "93dd8fc4d30da8a79a77303381b1451f8215c62f8b913e215664a9396cf47d61"
[resources.sources.app_addons]
url = "https://framagit.org/hubzilla/addons/-/archive/8.4.1/addons-8.4.1.tar.gz"
sha256 = "67f7b881f195b258c3d61922a6ce0f92832b907cafd5feb11b8abea4b2b055a0"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.database]
type = "mysql"

View file

@ -6,14 +6,14 @@
# PHP APP SPECIFIC
#=================================================
YNH_PHP_VERSION="8.2"
#REMOVEME? YNH_PHP_VERSION="8.2"
php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json"
#REMOVEME? php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-json"
# dependencies used by the app (must be on a single line)
pkg_dependencies="$php_dependencies"
#REMOVEME? pkg_dependencies="$php_dependencies"
pg_pkg_dependencies="postgresql postgresql-contrib"
#REMOVEME? pg_pkg_dependencies="postgresql postgresql-contrib"
#=================================================
# PERSONAL HELPERS

View file

@ -14,24 +14,24 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? 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)
database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -42,7 +42,7 @@ 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,23 +13,23 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
admin=$YNH_APP_ARG_ADMIN
database=$YNH_APP_ARG_DATABASE
phpversion=$YNH_PHP_VERSION
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path="/"
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
#REMOVEME? database=$YNH_APP_ARG_DATABASE
#REMOVEME? phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
email=$(ynh_user_get_info --username=$admin --key=mail)
upload="256M"
@ -41,22 +41,22 @@ fpm_usage="low"
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
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
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=upload --value=$upload
@ -70,41 +70,41 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# CREATE A DATABASE
#=================================================
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? db_user=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
if [ $database = "mysql" ]; then
ynh_script_progression --message="Creating a MySQL database..." --weight=1
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=1
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
db_type=0
elif [ $database = "postgresql" ]; then
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
#REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_type=1
fi
@ -113,18 +113,18 @@ fi
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
touch "$final_path/php.log"
mkdir -p "$final_path/store"
mkdir -p "$final_path/cache/smarty3"
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons"
touch "$install_dir/php.log"
mkdir -p "$install_dir/store"
mkdir -p "$install_dir/cache/smarty3"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R 775 $final_path/store $final_path/cache
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 775 $install_dir/store $install_dir/cache
#=================================================
# PHP-FPM CONFIGURATION
@ -133,7 +133,7 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
@ -151,9 +151,9 @@ ynh_add_nginx_config
ynh_script_progression --message="Provisionning database..." --weight=1
if [ $database = "mysql" ]; then
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql
elif [ $database = "postgresql" ]; then
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_postgres.sql
fi
#=================================================
@ -161,16 +161,16 @@ fi
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
ynh_store_file_checksum --file=$final_path/.htconfig.php
cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php
ynh_store_file_checksum --file=$install_dir/.htconfig.php
chmod 600 "$final_path/.htconfig.php"
chown $app:$app "$final_path/.htconfig.php"
chmod 600 "$install_dir/.htconfig.php"
chown $app:$app "$install_dir/.htconfig.php"
#=================================================
# SET CRON JOB
@ -190,7 +190,7 @@ chmod 644 "/etc/cron.d/$app"
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log"
ynh_use_logrotate "$install_dir/php.log"
#=================================================
# SETUP FAIL2BAN
@ -198,23 +198,23 @@ ynh_use_logrotate "$final_path/php.log"
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

View file

@ -14,13 +14,13 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
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)
database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# STANDARD REMOVE
@ -38,21 +38,21 @@ ynh_remove_logrotate
if [ $database = "mysql" ]; then
# Removing MySQL database
ynh_script_progression --message="Removing MySQL database..." --weight=1
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#REMOVEME? ynh_script_progression --message="Removing MySQL database..." --weight=1
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database = "postgresql" ]; then
# Removing PostgreSQL database
ynh_script_progression --message="Removing PostgreSQL database..." --weight=1
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#REMOVEME? ynh_script_progression --message="Removing PostgreSQL database..." --weight=1
#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#REMOVEME? ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE NGINX CONFIGURATION
@ -73,10 +73,10 @@ ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#REMOVEME? ynh_remove_app_dependencies
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
@ -101,10 +101,10 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#REMOVEME? ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT

View file

@ -14,59 +14,59 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
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
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
#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? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the 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"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
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"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
@ -82,12 +82,12 @@ ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -111,15 +111,15 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
if [ $database = "mysql" ]; then
ynh_script_progression --message="Restoring MySQL database..." --weight=1
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
#REMOVEME? ynh_script_progression --message="Restoring MySQL database..." --weight=1
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? 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
elif [ $database = "postgresql" ]; then
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#REMOVEME? ynh_psql_test_if_first_run
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
fi

View file

@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
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
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
upload=$(ynh_app_setting_get --app=$app --key=upload)
random_string=$(ynh_app_setting_get --app=$app --key=random_string)
#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? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database)
#REMOVEME? upload=$(ynh_app_setting_get --app=$app --key=upload)
#REMOVEME? random_string=$(ynh_app_setting_get --app=$app --key=random_string)
email=$(ynh_user_get_info --username=$admin --key=mail)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
#REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# CHECK VERSION
@ -42,16 +42,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=1
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# 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
@ -60,16 +60,16 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# 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 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 fpm_footprint doesn't exist, create it
@ -91,8 +91,8 @@ if [ -z "$fpm_usage" ]; then
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
#REMOVEME? if ynh_legacy_permissions_exists; then
#REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
@ -109,10 +109,10 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# 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
@ -123,26 +123,26 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="store/ .htconfig.php php.log"
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
ynh_setup_source --dest_dir="$install_dir" --keep="store/ .htconfig.php php.log"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons"
fi
mkdir -p "$final_path/store"
mkdir -p "$final_path/cache/smarty3"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R 775 $final_path/store $final_path/cache
mkdir -p "$install_dir/store"
mkdir -p "$install_dir/cache/smarty3"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 775 $install_dir/store $install_dir/cache
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
#REMOVEME? pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
@ -151,7 +151,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
@ -170,25 +170,25 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
if [ $database = "mysql" ]; then
db_type=0
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
# Change your databases character set and collation
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
elif [ $database = "postgresql" ]; then
db_type=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
fi
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
ynh_store_file_checksum --file=$final_path/.htconfig.php
cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php
ynh_store_file_checksum --file=$install_dir/.htconfig.php
chmod 600 "$final_path/.htconfig.php"
chown $app:$app "$final_path/.htconfig.php"
chmod 600 "$install_dir/.htconfig.php"
chown $app:$app "$install_dir/.htconfig.php"
#=================================================
# UPGRADE CRON JOB
@ -216,14 +216,14 @@ ynh_use_logrotate --non-append
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT