From ea849877c3505183acc863f007a88e3b4342848a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 15 Feb 2021 17:37:01 +0100 Subject: [PATCH] small fixes --- README.md | 13 ++----------- manifest.json | 25 ++++++++++++++++--------- pull_request_template.md | 5 +---- scripts/install | 39 +++++++++++++-------------------------- scripts/remove | 17 +++++------------ scripts/restore | 4 ++-- scripts/upgrade | 23 +++++++++++------------ 7 files changed, 50 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 43aca5c..7554f3c 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,8 @@ > *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.* - 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 [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 -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/Zap%20%28Official%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/) +* 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%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/zap/) ## Links diff --git a/manifest.json b/manifest.json index 99d0374..4572c0f 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,8 @@ "id": "zap", "packaging_format": 1, "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", "url": "https://zotlabs.com/zap/", @@ -27,9 +28,14 @@ "name": "domain", "type": "domain", "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", - "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." - } + "en": "Choose a domain for your ZAP.", + "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", @@ -37,17 +43,18 @@ "ask": { "en": "Choose the ZAP administrator", "fr": "Choisissez l'administrateur de ZAP" - } + }, + "example": "johndoe" }, { "name": "database", "type": "string", "ask": { - "en": "Choose the database to be used for the Zap [mysql:1,postgresql:2]", - "fr": "Choisissez la database de l'Zap [mysql:1,postgresql:2]" + "en": "Choose the database to be used for Zap", + "fr": "Choisissez la database de Zap" }, - "choices": ["1", "2"], - "default": "1" + "choices": ["mysql", "postgresql"], + "default": "mysql" } ] } diff --git a/pull_request_template.md b/pull_request_template.md index c6bb784..4bd83df 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,4 +1,3 @@ - ## Problem - *Description of why you made this PR* @@ -14,6 +13,4 @@ ## 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* - -[![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)/) +* 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!"* \ No newline at end of file diff --git a/scripts/install b/scripts/install index ca9af46..171a837 100755 --- a/scripts/install +++ b/scripts/install @@ -28,10 +28,8 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" admin=$YNH_APP_ARG_ADMIN email=$(ynh_user_get_info --username=$admin --key=mail) -upload="256M" -database="1" -random_string="$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)" -database=`expr $YNH_APP_ARG_DATABASE` +#upload="256M" +database=$YNH_APP_ARG_DATABASE 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=admin --value=$admin 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=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 @@ -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 # 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 @@ -120,13 +106,13 @@ popd # 3 - Some extra folders ynh_script_progression --message="Creating smarty3 folder for personal data..." -mkdir -p "${final_path}/store" -mkdir -p "${final_path}/cache/smarty3" +mkdir -p "$final_path/store" +mkdir -p "$final_path/cache/smarty3" chmod -R 777 $final_path/store $final_path/cache # Copy the template install/htconfig.sample.php to .htconfig.php config="$final_path/.htconfig.php" -ynh_script_progression --message="Moving .htconfig.php to root of Zap ..." +ynh_script_progression --message="Moving .htconfig.php to root of Zap..." cp $final_path/install/htconfig.sample.php $config config="$final_path/.htconfig.php" # Create php.log inside for logs @@ -137,7 +123,7 @@ touch "$final_path/php.log" # CREATE A DATABASE #================================================= -if [ $database -eq 1 ]; then +if [ $database -eq mysql ]; then ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) 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_script_progression --message="Importing database..." ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql -elif [ $database -eq 2 ]; then - # Create postgresql database - ynh_script_progression --message="Creating a postgresql database..." +elif [ $database -eq postgresql ]; then + # Create 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" db_name=$(ynh_sanitize_dbid --db_name=$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= "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= "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" 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" diff --git a/scripts/remove b/scripts/remove index 68fb57f..5367247 100755 --- a/scripts/remove +++ b/scripts/remove @@ -26,30 +26,23 @@ database=$(ynh_app_setting_get --app=$app --key=database) # REMOVE THE DATABASE #================================================= -if [ $database -eq 1 ]; then +if [ $database -eq mysql ]; then ynh_script_progression --message="Removing MySQL database..." 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 - 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 fi -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies" - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove --file="$final_path" +ynh_secure_remove --file=$final_path #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 49c0376..b79b6b9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -67,12 +67,12 @@ ynh_restore_file --origin_path="$final_path" #================================================= 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..." 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_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 ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies diff --git a/scripts/upgrade b/scripts/upgrade index e036dbb..1707c67 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -111,10 +111,10 @@ else # Create a temporary directory tmpdir="$(ynh_smart_mktemp 6000)" # Backup the config file in the temp dir - cp -a "$final_path/.htconfig.php" "$tmpdir/.htconfig.php" - cp -a "$final_path/store" "$tmpdir/store" - cp -a "$final_path/php.log" "$tmpdir/php.log" - cp -a "$final_path/cache" "$tmpdir/cache" + cp -a $final_path/.htconfig.php $tmpdir/.htconfig.php + cp -a $final_path/store $tmpdir/store + cp -a $final_path/php.log $tmpdir/php.log + cp -a $final_path/cache $tmpdir/cache # Remove the app directory securely ynh_secure_remove "$final_path" @@ -122,15 +122,14 @@ else # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" - cp -a "$tmpdir/cache" "${final_path}" - cp -a "$tmpdir/store" "${final_path}" - cp -a "$tmpdir/.htconfig.php" "${final_path}" - cp -a "$tmpdir/php.log" "${final_path}" - ynh_secure_remove --file="$tmpdir" + cp -a $tmpdir/cache $final_path + cp -a $tmpdir/store $final_path + cp -a $tmpdir/.htconfig.php $final_path + cp -a $tmpdir/php.log $final_path + ynh_secure_remove --file=$tmpdir chmod -R 777 $final_path/store mkdir $final_path/addon ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons" - fi #================================================= @@ -176,7 +175,7 @@ ynh_use_logrotate --non-append # 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 .*$" --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..." -if [ $database -eq 2 ]; then +if [ $database -eq postgresql ]; then ynh_install_app_dependencies $pkg_dependencies fi