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

updated sources and fixes

This commit is contained in:
anmol26s 2020-04-27 12:07:45 +05:30
parent 8793cc4925
commit aeb90c0f7e
11 changed files with 210 additions and 194 deletions

View file

@ -1,13 +1,13 @@
# ZAP for YunoHost # ZAP for YunoHost
[![Integration level](https://dash.yunohost.org/integration/zap.svg)](https://dash.yunohost.org/appci/app/zap) [![Integration level](https://dash.yunohost.org/integration/zap.svg)](https://dash.yunohost.org/appci/app/zap)
[![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zap) [![Install Zap with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zap)
> *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: 20.04.18 Version: 20.04.27
### Interesting links ### Interesting links

View file

@ -19,25 +19,16 @@
#upgrade=1 from_commit=CommitHash #upgrade=1 from_commit=CommitHash
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
incorrect_path=1 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=0
;;; Levels ;;; Levels
Level 1=auto # If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 2=auto
Level 3=auto
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
Level 4=1
Level 5=auto Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options ;;; Options
Email=anmol@datamol.org Email=anmol@datamol.org
Notification= Notification=change
;;; Upgrade options ;;; Upgrade options
; commit=CommitHash ; commit=CommitHash
name=Name and date of the commit. name=Name and date of the commit.

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://framagit.org/zot/zap/-/archive/1ad923369ef5b62090e6d85445479140be039ca9.tar.gz SOURCE_URL=https://framagit.org/zot/zap/-/archive/16d06332a35f55d1bfdc89455f968f2b8079fc77/zap-16d06332a35f55d1bfdc89455f968f2b8079fc77.tar.gz
SOURCE_SUM=578bd1f85111dbdad9e4182ed4bee49ca889b605 SOURCE_SUM=3b463218ff871d6891a6884f34f74e01a3b47a63bf511baeb6bc5e8d496b773d
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR= SOURCE_IN_SUBDIR=

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://framagit.org/zot/zap-addons/-/archive/b4e8f161edad43583584a5dbb2ef04ccdf3717de/zap-addons-b4e8f161edad43583584a5dbb2ef04ccdf3717de.tar.gz SOURCE_URL=https://framagit.org/zot/zap-addons/-/archive/074dbfd024e4e6675393955b13555796e0edbf3c/zap-addons-074dbfd024e4e6675393955b13555796e0edbf3c.tar.gz
SOURCE_SUM=dc0155638e62773940b30c80f6994114c17ab6a829b73e9fc870171e25af9179 SOURCE_SUM=aba32d7e0c5d1297bd2c7199f5f21a611b7591bb0033a2af8d83eaa00c7b8c42
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR= SOURCE_IN_SUBDIR=

View file

@ -26,7 +26,7 @@
location ~* \.php$ location ~* \.php$
{ {
try_files $uri =404; try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

View file

@ -5,7 +5,7 @@
"description": { "description": {
"en": "Zap is a full featured social network application with identity/content mirroring across multiple servers (nomadic identity) federating over ActivityPub and Zot6 protocols." "en": "Zap is a full featured social network application with identity/content mirroring across multiple servers (nomadic identity) federating over ActivityPub and Zot6 protocols."
}, },
"version": "20.04.18~ynh1", "version": "20.04.27~ynh1",
"url": "https://zotlabs.com/zap/", "url": "https://zotlabs.com/zap/",
"license": "MIT", "license": "MIT",
"maintainer": { "maintainer": {
@ -14,7 +14,7 @@
"url": "https://datamol.org" "url": "https://datamol.org"
}, },
"requirements": { "requirements": {
"yunohost": ">= 2.7.2" "yunohost": ">= 3.5"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [

View file

@ -24,68 +24,70 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Backing up the main app directory..." ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..." ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up php-fpm configuration..." ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the MySQL database..." ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
ynh_mysql_dump_db "$db_name" > db.sql ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Backing up logrotate configuration..." ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1
ynh_backup "/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP THE CRON FILE # BACKUP A CRON FILE
#================================================= #=================================================
ynh_backup "/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# BACKUP FAIL2BAN CONFIGURATION # BACKUP FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last

View file

@ -31,42 +31,50 @@ email=$(sudo yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
upload="256M" upload="256M"
database="1" database="1"
# This is a multi-instance app, meaning it can be installed several times independently ### If it's a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID ### The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) ### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME ### The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample ### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 ### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ... ### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is ### The app instance name is probably what interests you most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path, ### guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ... ### db names, ...
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info "Validating installation parameters..." ### About --weight and --time
### ynh_script_progression will show to your final users the progression of each scripts.
### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
### --time is a packager option, it will show you the execution time since the previous call.
### This option should be removed before releasing your app.
### Use the execution time, given by --time, to estimate the weight of a step.
### A common way to do it is to set a weight equal to the execution time in second +1.
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..." ynh_script_progression --message="Storing installation settings..." --time --weight=1
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set $app admin $admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set $app email $email ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set $app upload $upload ynh_app_setting_set --app=$app --key=upload --value=$upload
ynh_app_setting_set $app database $database ynh_app_setting_set --app=$app --key=database --value=$database
#================================================= #=================================================
@ -74,7 +82,7 @@ ynh_app_setting_set $app database $database
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_script_progression --message="Installing dependencies..." --time --weight=1
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. ### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
### Those deb packages will be installed as dependencies of this package. ### Those deb packages will be installed as dependencies of this package.
@ -89,7 +97,7 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Creating a MySQL database..." ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
### Use these lines if you need a database for the application. ### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. ### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
@ -100,42 +108,43 @@ ynh_print_info "Creating a MySQL database..."
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script ### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script ### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set $app db_name $db_name db_user=$db_name
ynh_mysql_setup_db $db_name $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
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
# 1 - Zap # 1 - Zap
ynh_print_info "Setting up source files..." ynh_script_progression --message="Setting up source files..." --time --weight=1
### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository. ### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src ### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set $app final_path $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
ynh_setup_source "$final_path" ynh_setup_source --dest_dir="$final_path"
# 2 - Zap Addons # 2 - Zap Addons
# Make addon Directory and unpack the addons to this directory # Make addon Directory and unpack the addons to this directory
ynh_print_info "Create addon directory inside root folder..." ynh_print_info "Create addon directory inside root folder..."
sudo mkdir $final_path/addon mkdir $final_path/addon
ynh_print_info "Setting up addons source files..." ynh_print_info "Setting up addons source files..."
ynh_setup_source "$final_path/addon" "app_addons" ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
# 3 - Some extra folders # 3 - Some extra folders
ynh_print_info "Creating smarty3 folder for personal data..." ynh_print_info "Creating smarty3 folder for personal data..."
sudo mkdir -p "${final_path}/store/[data]/smarty3" mkdir -p "${final_path}/store/[data]/smarty3"
sudo chmod -R 777 $final_path/store $final_path/cache chmod -R 777 $final_path/store
# Import database schema # Import database schema
ynh_print_info "Importing database..." ynh_print_info "Importing database..."
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < $final_path/install/schema_mysql.sql ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
# Copy the template install/htconfig.sample.php to .htconfig.php # Copy the template install/htconfig.sample.php to .htconfig.php
ynh_print_info "Moving .htconfig.php to root folder ..." ynh_print_info "Moving .htconfig.php to root folder ..."
@ -153,17 +162,17 @@ sudo touch "$final_path/php.log"
### (It's compatible with sed regular expressions syntax) ### (It's compatible with sed regular expressions syntax)
ynh_print_info "Replace the .htconfig.php values...." ynh_print_info "Replace the .htconfig.php values...."
sudo sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php
sudo sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php
sudo sed -i "s/mysqlusername/$db_name/g" $final_path/.htconfig.php sed -i "s/mysqlusername/$db_name/g" $final_path/.htconfig.php
sudo sed -i "s/mysqldatabasename/$db_name/g" $final_path/.htconfig.php sed -i "s/mysqldatabasename/$db_name/g" $final_path/.htconfig.php
sudo sed -i "s/mysite.example/$domain/g" $final_path/.htconfig.php sed -i "s/mysite.example/$domain/g" $final_path/.htconfig.php
sudo sed -i "s/if the auto install failed, put a unique random string here/$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)/g" $final_path/.htconfig.php sed -i "s/if the auto install failed, put a unique random string here/$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)/g" $final_path/.htconfig.php
sudo sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" $final_path/.htconfig.php sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" $final_path/.htconfig.php
sudo sed -i "s@//error_reporting(E_ERROR | E_WARNING | E_PARSE );@error_reporting(E_ERROR | E_WARNING | E_PARSE );@g" $final_path/.htconfig.php sed -i "s@//error_reporting(E_ERROR | E_WARNING | E_PARSE );@error_reporting(E_ERROR | E_WARNING | E_PARSE );@g" $final_path/.htconfig.php
sudo sed -i "s@//ini_set('error_log','php.out');@ini_set('error_log','php.log');@g" $final_path/.htconfig.php sed -i "s@//ini_set('error_log','php.out');@ini_set('error_log','php.log');@g" $final_path/.htconfig.php
sudo sed -i "s@//ini_set('log_errors','1');@ini_set('log_errors','1');@g" $final_path/.htconfig.php sed -i "s@//ini_set('log_errors','1');@ini_set('log_errors','1');@g" $final_path/.htconfig.php
sudo sed -i "s@//ini_set('display_errors', '0');@ini_set('display_errors', '0');@g" $final_path/.htconfig.php sed -i "s@//ini_set('display_errors', '0');@ini_set('display_errors', '0');@g" $final_path/.htconfig.php
# Addon ldap config # Addon ldap config
ynh_print_info "Push Ldap configuration to .htconfig.php..." ynh_print_info "Push Ldap configuration to .htconfig.php..."
@ -175,7 +184,7 @@ sudo su -c "cat ../conf/zap.php >> $final_path/.htconfig.php"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring nginx web server..." ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
### `ynh_add_nginx_config` will use the file conf/nginx.conf ### `ynh_add_nginx_config` will use the file conf/nginx.conf
@ -185,19 +194,19 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..." ynh_script_progression --message="Configuring system user..." --time --weight=1
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring php-fpm..." ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
### `ynh_add_fpm_config` is used to set up a PHP config. ### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP. ### You can remove it if your app doesn't use PHP.
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini ### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
### If you're not using these lines: ### If you're not using these lines:
### - You can remove these files in conf/. ### - You can remove these files in conf/.
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script ### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
@ -215,9 +224,9 @@ chown -R $app: $final_path
# Set up cron job # Set up cron job
ynh_print_info "Setting up cron job..." ynh_print_info "Setting up cron job..."
ynh_replace_string "YNH_WWW_PATH" "$final_path" ../conf/poller-cron ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$final_path" ..--target_file="/conf/poller-cron"
ynh_replace_string "__USER__" "$app" ../conf/poller-cron ynh_replace_string --match_string="__USER__" --replace_string="$app" ..--target_file="/conf/poller-cron"
sudo cp ../conf/poller-cron /etc/cron.d/$app cp ../conf/poller-cron /etc/cron.d/$app
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
@ -228,12 +237,12 @@ sudo cp ../conf/poller-cron /etc/cron.d/$app
### you can make a backup of this file before modifying it again if the admin had modified it. ### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/.htconfig.php" ynh_store_file_checksum --file="$final_path/.htconfig.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Configuring log rotation..." ynh_script_progression --message="Configuring log rotation..." --time --weight=1
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. ### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app. ### Use this helper only if there is effectively a log file for this app.
@ -244,30 +253,32 @@ ynh_print_info "Configuring log rotation..."
### - And the section "SETUP LOGROTATE" in the upgrade script ### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log" ynh_use_logrotate --logfile="$final_path/php.log"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
ynh_print_info "Add Fail2Ban..." ynh_script_progression --message="Configuring fail2ban..." --time --weight=1
ynh_add_fail2ban_config "$final_path/php.log" "^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" 5
# 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
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
# As Zap is social network and have its own permission there is no need to keep Zap behind SSO # As Zap is social network and have its own permission there is no need to keep Zap behind SSO
ynh_print_info "Configuring SSOwat..." ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Installation of $app completed" ynh_script_progression --message="Installation of $app completed" --time --last

View file

@ -12,47 +12,47 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user="$db_name" db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies" ynh_script_progression --message="Removing dependencies..." --time --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_print_info "Removing the MySQL database"
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_user $db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory" ynh_script_progression --message="Removing app main directory..." --time --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration" ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -60,7 +60,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing php-fpm configuration" ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -68,7 +68,7 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing logrotate configuration" ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -78,12 +78,14 @@ ynh_remove_logrotate
#================================================= #=================================================
# Remove a cron file # Remove a cron file
ynh_secure_remove "/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
# Remove the dedicated fail2ban config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
#================================================= #=================================================
@ -91,13 +93,13 @@ ynh_remove_fail2ban_config
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user" ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Removal of $app completed" ynh_script_progression --message="Removal of $app completed" --time --last

View file

@ -24,25 +24,26 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..." ynh_script_progression --message="Loading settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get $app admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info "Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
ynh_webpath_available $domain $path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -50,45 +51,46 @@ test ! -d $final_path \
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
sudo chmod -R 777 $final_path/cache
#================================================= =================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Restoring the MySQL database..." ynh_script_progression --message="Restoring the MySQL database..." --time --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
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -97,37 +99,38 @@ ynh_install_app_dependencies $pkg_dependencies
# RESTORE THE CRON FILE # RESTORE THE CRON FILE
#================================================= #=================================================
ynh_restore_file "/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=1
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
systemctl restart fail2ban ynh_systemd_action --action=restart --service_name=fail2ban
# Make app public # Make app public
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_print_info "Reloading nginx web server and php-fpm..." ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
systemctl reload php7.0-fpm ynh_systemd_action --service_name=php7.0-fpm --action=reload
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Restoration completed for $app" ynh_script_progression --message="Restoration completed for $app" --time --last

View file

@ -12,32 +12,32 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
upload=$(ynh_app_setting_get $app upload) upload=$(ynh_app_setting_get --app=$app --key=upload)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get $app mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z $db_name ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..." ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -62,14 +62,19 @@ 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"
if [ -z $final_path/cache ]; then
mkdir $final_path/cache
chmod -R 777 $final_path/cache
fi
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"
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z $final_path ]; then if [ -z "$final_path" ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
#================================================= #=================================================
@ -80,19 +85,21 @@ fi
# 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 "$final_path" ynh_setup_source "$final_path"
sudo cp -a "$tmpdir/store" "${final_path}" cp -a "$tmpdir/store" "${final_path}"
sudo cp -a "$tmpdir/.htconfig.php" "${final_path}" cp -a "$tmpdir/.htconfig.php" "${final_path}"
sudo cp -a "$tmpdir/php.log" "${final_path}" cp -a "$tmpdir/php.log" "${final_path}"
sudo rm -Rf "$tmpdir" cp -a "$tmpdir/cache" "${final_path}"
sudo chmod -R 777 $final_path/store rm -Rf "$tmpdir"
sudo mkdir $final_path/addon chmod -R 777 $final_path/store
ynh_setup_source "$final_path/addon" "app_addons" chmod -R 777 $final_path/cache
mkdir $final_path/addon
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading nginx web server configuration..." ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -100,10 +107,10 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create --username=$app
# Set right permissions for curl install # Set right permissions for curl install
chown -R $app: $final_path chown -R $app: $final_path
@ -111,7 +118,7 @@ chown -R $app: $final_path
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading php-fpm configuration..." ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
@ -119,23 +126,24 @@ ynh_add_fpm_config
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different "$final_path/.htconfig.php" ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
# Recalculate and store the config file checksum into the app settings # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$final_path/.htconfig.php" ynh_store_file_checksum --file="$final_path/.htconfig.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_print_info "Upgrading logrotate configuration..." ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
# UPGRADE FAIL2BAN
#================================================= #=================================================
# SETUP FAIL2BAN ynh_script_progression --message="Reconfiguring fail2ban..." --time --weight=1
#=================================================
ynh_print_info "Add Fail2Ban..." # Create a dedicated fail2ban config
ynh_add_fail2ban_config "$final_path/php.log" "^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" 5 ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" max_retry=5
# Set cron job # Set cron job
ynh_print_info "Setting up cron job..." ynh_print_info "Setting up cron job..."
@ -149,8 +157,7 @@ sudo cp ../conf/poller-cron /etc/cron.d/$app
ynh_print_info "Upgrading dependencies..." ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
sudo mkdir $final_path/cache
sudo chmod -R 777 $final_path/cache
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -162,12 +169,12 @@ ynh_app_setting_set $app skipped_uris "/"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info "Upgrade of $app completed" ynh_script_progression --message="Upgrade of $app completed" --time --last