1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/zap_ynh.git synced 2024-09-03 20:36:07 +02:00

small fixes

This commit is contained in:
ericgaspar 2021-02-15 17:37:01 +01:00
parent d48f951085
commit ea849877c3
No known key found for this signature in database
GPG key ID: 574F281483054D44
7 changed files with 50 additions and 76 deletions

View file

@ -6,17 +6,8 @@
> *This package allow you to install ZAP quickly and simply on a YunoHost server. > *This package allow you to install ZAP quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
Version: 21.02.11 Version: 21.02.11
### Interesting links
- [YunoHost project](https://yunohost.org)
- [Zap website](https://zotlabs.com/zap/)
- [Zap code on codeberg](https://codeberg.org/zot/zap)
- [Zap addons on codeberg](https://codeberg.org/zot/zap-addons)
## Overview ## Overview
[Zap](https://zotlabs.com/zap/) is an an ethical alternative to Fediverse that provides powerful features for creating interconnected websites featuring a decentralized identity, communications, and permissions framework built using common webserver technology. [Zap](https://zotlabs.com/zap/) is an an ethical alternative to Fediverse that provides powerful features for creating interconnected websites featuring a decentralized identity, communications, and permissions framework built using common webserver technology.
@ -64,8 +55,8 @@ Before installing, read the [Zap installation instructions](https://codeberg.org
#### Supported architectures #### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/Zap%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/zap/) * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/zap%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/zap/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/Zap%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/zap/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/zap%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/zap/)
## Links ## Links

View file

@ -3,7 +3,8 @@
"id": "zap", "id": "zap",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "A fediverse server." "en": "Social network based on fediverse server",
"fr": "Réseau social basé sur le serveur fediverse"
}, },
"version": "21.02.11~ynh1", "version": "21.02.11~ynh1",
"url": "https://zotlabs.com/zap/", "url": "https://zotlabs.com/zap/",
@ -27,9 +28,14 @@
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": { "ask": {
"en": "Choose a domain for your ZAP hub. ZAP must run in the root of this domain. It means no other app can be accessed/run from this domain. We advise to use a dedicated subdomain such as zap.domain.tld", "en": "Choose a domain for your ZAP.",
"fr": "Indiquez un domain pour ZAP. ZAP doit être installé à la racine du domaine. Cela implique qu'aucune autre app ne pourra être installée ou accessible sur ce domain. Nous conseillons un sous-domaine dédié par exemple zap.domain.tld." "fr": "Indiquez un domain pour ZAP."
} },
"help": {
"en": "ZAP must run in the root of this domain. It means no other app can be accessed/run from this domain.",
"fr": "ZAP doit être installé à la racine du domaine. Cela implique qu'aucune autre application ne pourra être installée ou accessible sur ce domain."
},
"example": "zap.domain.tld."
}, },
{ {
"name": "admin", "name": "admin",
@ -37,17 +43,18 @@
"ask": { "ask": {
"en": "Choose the ZAP administrator", "en": "Choose the ZAP administrator",
"fr": "Choisissez l'administrateur de ZAP" "fr": "Choisissez l'administrateur de ZAP"
} },
"example": "johndoe"
}, },
{ {
"name": "database", "name": "database",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose the database to be used for the Zap [mysql:1,postgresql:2]", "en": "Choose the database to be used for Zap",
"fr": "Choisissez la database de l'Zap [mysql:1,postgresql:2]" "fr": "Choisissez la database de Zap"
}, },
"choices": ["1", "2"], "choices": ["mysql", "postgresql"],
"default": "1" "default": "mysql"
} }
] ]
} }

View file

@ -1,4 +1,3 @@
## Problem ## Problem
- *Description of why you made this PR* - *Description of why you made this PR*
@ -14,6 +13,4 @@
## Package_check results ## Package_check results
--- ---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* * An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/zap_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/zap_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -28,10 +28,8 @@ domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
email=$(ynh_user_get_info --username=$admin --key=mail) email=$(ynh_user_get_info --username=$admin --key=mail)
upload="256M" #upload="256M"
database="1" database=$YNH_APP_ARG_DATABASE
random_string="$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)"
database=`expr $YNH_APP_ARG_DATABASE`
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -55,20 +53,8 @@ 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=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=upload --value=$upload #ynh_app_setting_set --app=$app --key=upload --value=$upload
ynh_app_setting_set --app=$app --key=database --value=$database ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_set --app=$app --key=random_string --value=$random_string
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
if [ $database -eq 2 ]; then
ynh_install_app_dependencies $pkg_dependencies
fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -79,7 +65,7 @@ ynh_script_progression --message="Setting up Zap source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
git clone https://codeberg.org/zot/zap.git "$final_path" git clone https://codeberg.org/zot/zap.git $final_path
# 2 - Zap Addons # 2 - Zap Addons
@ -120,8 +106,8 @@ popd
# 3 - Some extra folders # 3 - Some extra folders
ynh_script_progression --message="Creating smarty3 folder for personal data..." ynh_script_progression --message="Creating smarty3 folder for personal data..."
mkdir -p "${final_path}/store" mkdir -p "$final_path/store"
mkdir -p "${final_path}/cache/smarty3" mkdir -p "$final_path/cache/smarty3"
chmod -R 777 $final_path/store $final_path/cache chmod -R 777 $final_path/store $final_path/cache
# Copy the template install/htconfig.sample.php to .htconfig.php # Copy the template install/htconfig.sample.php to .htconfig.php
@ -137,7 +123,7 @@ touch "$final_path/php.log"
# CREATE A DATABASE # CREATE A DATABASE
#================================================= #=================================================
if [ $database -eq 1 ]; then if [ $database -eq mysql ]; then
ynh_script_progression --message="Creating a MySQL database..." ynh_script_progression --message="Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name db_user=$db_name
@ -145,9 +131,10 @@ if [ $database -eq 1 ]; then
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_script_progression --message="Importing database..." ynh_script_progression --message="Importing database..."
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" < $final_path/install/schema_mysql.sql
elif [ $database -eq 2 ]; then elif [ $database -eq postgresql ]; then
# Create postgresql database # Create PostgreSQL database
ynh_script_progression --message="Creating a postgresql database..." ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Creating a PostgreSQL database..."
ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config" ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config"
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$app db_user=$app
@ -170,7 +157,7 @@ ynh_replace_string --match_string= "mysqlpassword" --replace_string="$db_pwd" --
ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$config" ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string= "mysqldatabasename" --replace_string="$db_name" --target_file="$config" ynh_replace_string --match_string= "mysqldatabasename" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string= "mysite.example" --replace_string="$domain" --target_file="$config" ynh_replace_string --match_string= "mysite.example" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string= "if the auto install failed, put a unique random string here" --replace_string="$random_string" --target_file="$config" ynh_replace_string --match_string= "if the auto install failed, put a unique random string here" --replace_string="$(ynh_string_random --length=24)" --target_file="$config"
sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" "$config" sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" "$config"
ynh_replace_string --match_string= "//error_reporting(E_ERROR | E_WARNING | E_PARSE );" --replace_string="error_reporting(E_ERROR | E_WARNING | E_PARSE );" --target_file="$config" ynh_replace_string --match_string= "//error_reporting(E_ERROR | E_WARNING | E_PARSE );" --replace_string="error_reporting(E_ERROR | E_WARNING | E_PARSE );" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('error_log','php.out');" --replace_string="ini_set('error_log','php.log');" --target_file="$config" ynh_replace_string --match_string= "//ini_set('error_log','php.out');" --replace_string="ini_set('error_log','php.log');" --target_file="$config"

View file

@ -26,30 +26,23 @@ database=$(ynh_app_setting_get --app=$app --key=database)
# REMOVE THE DATABASE # REMOVE THE DATABASE
#================================================= #=================================================
if [ $database -eq 1 ]; then if [ $database -eq mysql ]; then
ynh_script_progression --message="Removing MySQL database..." ynh_script_progression --message="Removing MySQL database..."
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database -eq 2 ]; then elif [ $database -eq postgresql ]; then
# Removing postgresql database # Removing postgresql database
ynh_script_progression --message="Removing postgreSQL database..." ynh_remove_app_dependencies
ynh_script_progression --message="Removing PostgreSQL database..."
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies"
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file=$final_path
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION

View file

@ -67,12 +67,12 @@ ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." ynh_script_progression --message="Restoring the MySQL database..."
if [ $database -eq 1 ]; then if [ $database -eq mysql ]; then
ynh_script_progression --message="Restoring MySQL database..." ynh_script_progression --message="Restoring MySQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
elif [ $database -eq 2 ]; then elif [ $database -eq postgresql ]; then
# Removing postgresql database # Removing postgresql database
ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies

View file

@ -111,10 +111,10 @@ else
# Create a temporary directory # Create a temporary directory
tmpdir="$(ynh_smart_mktemp 6000)" tmpdir="$(ynh_smart_mktemp 6000)"
# Backup the config file in the temp dir # Backup the config file in the temp dir
cp -a "$final_path/.htconfig.php" "$tmpdir/.htconfig.php" cp -a $final_path/.htconfig.php $tmpdir/.htconfig.php
cp -a "$final_path/store" "$tmpdir/store" cp -a $final_path/store $tmpdir/store
cp -a "$final_path/php.log" "$tmpdir/php.log" cp -a $final_path/php.log $tmpdir/php.log
cp -a "$final_path/cache" "$tmpdir/cache" cp -a $final_path/cache $tmpdir/cache
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
@ -122,15 +122,14 @@ else
# Download, check integrity, uncompress and patch the source from app.src # 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"
cp -a "$tmpdir/cache" "${final_path}" cp -a $tmpdir/cache $final_path
cp -a "$tmpdir/store" "${final_path}" cp -a $tmpdir/store $final_path
cp -a "$tmpdir/.htconfig.php" "${final_path}" cp -a $tmpdir/.htconfig.php $final_path
cp -a "$tmpdir/php.log" "${final_path}" cp -a $tmpdir/php.log $final_path
ynh_secure_remove --file="$tmpdir" ynh_secure_remove --file=$tmpdir
chmod -R 777 $final_path/store chmod -R 777 $final_path/store
mkdir $final_path/addon mkdir $final_path/addon
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons" ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
fi fi
#================================================= #=================================================
@ -176,7 +175,7 @@ ynh_use_logrotate --non-append
# UPGRADE FAIL2BAN # UPGRADE FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Re-configure fail2ban..." ynh_script_progression --message="Re-configure Fail2Ban..."
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="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
@ -189,7 +188,7 @@ ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
if [ $database -eq 2 ]; then if [ $database -eq postgresql ]; then
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
fi fi