diff --git a/LICENSE b/LICENSE
index 25c4bf1..b3dbff0 100755
--- a/LICENSE
+++ b/LICENSE
@@ -1,20 +1,22 @@
-Copyright (c) 2010-2017 the Hubzilla Community
-All rights reserved.
+This is free and unencumbered software released into the public domain.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index ed46757..a43578c 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,63 @@
-# Osada for Yunohost
+# Osada for YunoHost
-[](https://ci-apps.yunohost.org/jenkins/job/osada%20%28Community%29/lastBuild/consoleFull)
+[](https://dash.yunohost.org/appci/app/osada)  
-[](https://install-app.yunohost.org/?app=osada)
-Shipped version: **2.2**
-
+[](https://install-app.yunohost.org/?app=osada)
+
+> *This package allow you to install Osada 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.*
+
+
+## Overview
+[Osada](http://zotlabs.com/osada/) uses **Zot6 protocol** which is next version of **zot5 protocol**. Osada has native support for the **ActivityPub protocol** (W3C standard) as well as the more advanced features. It can inter-operate with other social networking applications and projects in either of these spaces, including **Mastodon, Pleroma, Pixelfed, PeerTube, Funkwhale, Zap, Friendica, Hubzilla,** and many more.
+
+**Shipped version:** 21.02.11
+
+## Screenshots
+
+
+
+## This app claims following features:
+- [X] LDAP integration
+- [X] Multi-instance
+- [X] Adeed php.log in the root folder for debugging PHP, with logrotate applied on it (can be accesssed by **admin->logs** and entering the **php.log**).
+- [X] Fail2Ban
+- [X] Option to choose between **Mysql** and **PostgreSQL** for the Osada
+
+## Ldap Admin user rights, logs and failed database updates
+
+- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub.
+
+- **For normal YunoHost users**: Normal LDAP users can login through LDAP authentication and create there channels.
+
+- **Failing to get admin rights**: If the admin cannot access the admin settings at `https://osada.example.com/admin` then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMyAdmin**.
+
+- **For logs**: Go to **admin->logs** and enter the file name **php.log**.
+
+- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://osada.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMyAdmin**.
+
+#### Supported architectures
+
+* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/osada/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/osada/)
+
### Interesting links
- [YunoHost project](https://yunohost.org)
-- [Osada/Zap website](http://zotlabs.com/osada/)
-- [Osada/Zap code on Framagit](https://framagit.org/macgirvin/osada)
-- [Osada/Zap addons on Framagit](https://framagit.org/macgirvin/osada-addons)
+- [Osada website](http://zotlabs.com/osada/)
+- [Osada code on Framagit](https://codeberg.org/zot/osada)
+- [Osada addons on Framagit](https://codeberg.org/zot/osada-addons)
-## Osada
-[Osada](http://zotlabs.com/osada/) uses **Zot6 protocol** which is next version of **zot5 protocol** used by [Hubzilla](http://hubzilla.org). Osada has native support for the **ActivityPub protocol** (W3C standard) as well as the more advanced features. It can inter-operate with other social networking applications and projects in either of these spaces, including **Mastodon, Pleroma, Pixelfed, PeerTube, Funkwhale, Zap, Friendica, Hubzilla,** and many more.
+---
-

-
-
-**Osada** is a **social networking** platform specifically designed to be the glue that binds much of the **decentralised** web in a way that has not been **possible before**. It does this not by magic, but by **“speaking the language” of the various decentralised networks** and acting as a translator to pass information between them. Using Osada, you can seamlessly connect and share with your contacts whether they have an account on a Hubzilla server, a Mastodon server, or any of several popular platforms on the open web.
-
-
-## Important points to know before installing Osada
-1. Osada needs a valid **certificate** for your **domain** before installing Osada. For eg. Lets Encrpypt can be installed from Yunohost admin planel.
-1. Osada will require a **root domain**. Eg. osada.domain.tld
-1. Osada is **Ldap** enabled.
-1. Osada is **multi-instance** app. That means the app can be installed multiple times on a server.
-1. **For logs:** Go to **admin-> logs** and enter the file name as **php.log**.
+## Developer info
+Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/osada_ynh/tree/testing).
+To try the testing branch, please proceed like that.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/osada_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade osada -u https://github.com/YunoHost-Apps/osada_ynh/tree/testing --debug
+```
diff --git a/check_process b/check_process
index 2aba56c..3c46ac3 100755
--- a/check_process
+++ b/check_process
@@ -1,34 +1,26 @@
-;; Default test
- auto_remove=1
+# See here for more information
+# https://github.com/YunoHost/package_check#syntax-check_process-file
+
+# Move this file from check_process.default to check_process when you have filled it.
+
+;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
admin="john" (USER)
- ; Checks
- pkg_linter=1
- setup_sub_dir=0
- setup_root=1
- setup_nourl=0
- setup_private=0
- setup_public=1
- upgrade=1
- backup_restore=1
- multi_instance=1
- incorrect_path=1
- port_already_use=0
- change_url=0
- ;;; Levels
- Level 1=auto
- Level 2=auto
- Level 3=auto
- # App supports LDAP
- Level 4=1
- # Level 5:
- Level 5=auto
- Level 6=auto
- Level 7=auto
- Level 8=0
- Level 9=0
- Level 10=0
- ;;; Options
- Email=anmol@datamol.org
- Notification=
+ database="1" (STRING)
+ ; Checks
+ pkg_linter=1
+ setup_sub_dir=0
+ setup_root=1
+ setup_nourl=0
+ setup_private=0
+ setup_public=1
+ upgrade=1
+ #upgrade=1 from_commit=
+ backup_restore=1
+ multi_instance=1
+ port_already_use=0
+ change_url=0
+;;; Options
+Email=
+Notification=
\ No newline at end of file
diff --git a/conf/app.src b/conf/app.src
index 094d929..13b60a4 100755
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://framagit.org/zot/osada/-/archive/2.2/osada-2.2.tar.gz
-SOURCE_SUM=3861e2e48ce532277ed35f00d7e28c7a75ef0e5ea8a52e4db1832d6de2d4a112
+SOURCE_URL=https://codeberg.org/zot/osada/archive/3cc4ea6304ed12a5f373c035482283d11f3d31ee.tar.gz
+SOURCE_SUM=759c8a662ce7e927939f73d5ddde89c03ff4d2cb1749a1e5cbbc0694734e9c01
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=
diff --git a/conf/app_addons.src b/conf/app_addons.src
index 2983cc1..eb7979d 100755
--- a/conf/app_addons.src
+++ b/conf/app_addons.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://framagit.org/zot/osada-addons/-/archive/2.2/osada-addons-2.2.tar.gz
-SOURCE_SUM=e5185d043fa09ea13a3224a9f0bf4746bc76659ffa6346b1a52f8905dcd980dc
+SOURCE_URL=https://codeberg.org/zot/osada-addons/archive/f114c32aa84f80f940815d2158ddeef9734eb996.tar.gz
+SOURCE_SUM=664fdf03a0a77d358f976f5dd9fdf2b1df1bfa2cbfcc31714264d6562b95096c
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=
diff --git a/conf/zap.php b/conf/zap.php
deleted file mode 100644
index df2ff61..0000000
--- a/conf/zap.php
+++ /dev/null
@@ -1 +0,0 @@
-define('NOMADIC',1);
diff --git a/manifest.json b/manifest.json
index c14a87f..aa61889 100755
--- a/manifest.json
+++ b/manifest.json
@@ -7,19 +7,20 @@
"fr": "Osada est une plateforme de publication décentralisée et un réseau social."
},
"url": "http://zotlabs.com/osada/",
- "license": "Free as-is",
- "version": "2.2",
+ "license": "MIT",
+ "version": "21.02.11~ynh1",
"maintainer": {
"name": "Anmol Sharma",
- "email": "anmol@datamol.org"
+ "email": ""
},
"services": [
"nginx",
- "php5-fpm",
- "mysql"
+ "php7.0-fpm",
+ "mysql",
+ "postgresql"
],
"requirements": {
- "yunohost": ">= 3.0.0"
+ "yunohost": ">= 4.0.0"
},
"multi_instance": true,
"arguments": {
@@ -39,6 +40,16 @@
"en": "Choose the Osada administrator (must be an existing YunoHost user)",
"fr": "Choisissez l'administrateur de Osada (doit être un utilisateur YunoHost existant)"
}
+ },
+ {
+ "name": "database",
+ "type": "string",
+ "ask": {
+ "en": "Choose the database to be used for the Osada [mysql:1,postgresql:2]",
+ "fr": "Choisissez la database de Osada [mysql:1,postgresql:2]"
+ },
+ "choices": ["1", "2"],
+ "default": "1"
}
]
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 24bd7ba..206eac8 100755
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,13 +1,25 @@
#!/bin/bash
-# ============= FUTURE YUNOHOST HELPER =============
-# Delete a file checksum from the app settings
-#
-# $app should be defined when calling this helper
-#
-# usage: ynh_remove_file_checksum file
-# | arg: file - The file for which the checksum will be deleted
-ynh_delete_file_checksum () {
- local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
- ynh_app_setting_delete $app $checksum_setting_name
-}
+#=================================================
+# COMMON VARIABLES
+#=================================================
+
+# dependencies used by the app
+YNH_PHP_VERSION="7.3"
+
+extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"
+
+# dependencies used by the app
+pkg_dependencies="postgresql postgresql-contrib"
+
+#=================================================
+# PERSONAL HELPERS
+#=================================================
+
+#=================================================
+# EXPERIMENTAL HELPERS
+#=================================================
+
+#=================================================
+# FUTURE OFFICIAL HELPERS
+#=================================================
diff --git a/scripts/backup b/scripts/backup
index 3cfb4fa..337578d 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -6,65 +6,92 @@
# IMPORT GENERIC HELPERS
#=================================================
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-source _common.sh
+source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
+ynh_clean_setup () {
+ ### Remove this function if there's nothing to clean before calling the remove script.
+ true
+}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-
+ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
-final_path=$(ynh_app_setting_get $app final_path)
-domain=$(ynh_app_setting_get $app domain)
-db_name=$(ynh_app_setting_get $app db_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)
#=================================================
-# STANDARD BACKUP STEPS
+# DECLARE DATA AND CONF FILES TO BACKUP
+#=================================================
+ynh_print_info --message="Declaring files to be backed up..."
+
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
-ynh_backup "$final_path"
+ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
-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
#=================================================
-ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
+ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
-# BACKUP THE MYSQL DATABASE
+# BACKUP OF THE DATABASE
#=================================================
-ynh_mysql_dump_db "$db_name" > db.sql
+if [ $database -eq 1 ]; then
+ # Backup MySQL database
+ ynh_print_info --message="Backup of the MySQL database..."
+ ynh_mysql_dump_db --database="$db_name" > db.sql
+elif [ $database -eq 2 ]; then
+ # Backup PostgreSQL database
+ ynh_print_info --message="Backup of the PostgreSQL database..."
+ ynh_psql_dump_db --database="$db_name" > db.sql
+fi
+#=================================================
+# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
-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
+#=================================================
+
+ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
+ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/install b/scripts/install
index 72a24ac..8841a46 100755
--- a/scripts/install
+++ b/scripts/install
@@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
+ynh_clean_setup () {
+ ### Remove this function if there's nothing to clean before calling the remove script.
+ true
+}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@@ -23,145 +27,210 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
admin=$YNH_APP_ARG_ADMIN
-email=$(sudo yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
+email=$(yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
upload="256M"
-database="1"
+random_string="$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)"
+database=`expr $YNH_APP_ARG_DATABASE`
-# This is 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 instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
-# The app instance name is available as $YNH_APP_INSTANCE_NAME
-# - 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
-# - 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
-# guaranteed to be unique. This is a good unique identifier to define installation path,
-# db names, ...
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
+ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
+test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path $path_url)
-
-# Check web path availability
-ynh_webpath_available $domain $path_url
# Register (book) web path
-ynh_webpath_register $app $domain $path_url
+ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
-# Enregistre les infos dans la config YunoHost
-ynh_app_setting_set $app domain $domain
-ynh_app_setting_set $app path $path_url
-ynh_app_setting_set $app admin $admin
-ynh_app_setting_set $app email $email
-ynh_app_setting_set $app upload $upload
-ynh_app_setting_set $app database $database
+#=================================================
+# STORE SETTINGS FROM MANIFEST
+#=================================================
+ynh_script_progression --message="Storing installation settings..."
+ynh_app_setting_set --app=$app --key=domain --value=$domain
+ynh_app_setting_set --app=$app --key=path --value=$path_url
+ynh_app_setting_set --app=$app --key=admin --value=$admin
+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=database --value=$database
+ynh_app_setting_set --app=$app --key=random_string --value=$random_string
+#=================================================
+# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
-ynh_install_app_dependencies php-mbstring php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
+ynh_script_progression --message="Installing dependencies..."
+
+if [ $database -eq 2 ]; then
+ ynh_install_app_dependencies $pkg_dependencies
+fi
#=================================================
-# CREATE A MYSQL DATABASE
+# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
-# If your app uses a MySQL database, you can use these lines to bootstrap
-# a database, an associated user and save the password in app settings
-db_name=$(ynh_sanitize_dbid $app)
-ynh_app_setting_set $app db_name $db_name
-ynh_mysql_setup_db $db_name $db_name
-
-# We download the sources and check the md5sum
# 1 - Osada
-ynh_app_setting_set $app final_path $final_path
-ynh_setup_source "$final_path"
-sudo mkdir $final_path/addon
-ynh_setup_source "$final_path/addon" "app_addons"
+ynh_script_progression --message="Setting up Osada 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
+# ynh_setup_source --dest_dir="$final_path"
+git clone https://codeberg.org/zot/osada.git "$final_path"
-# 3 - some extra folders
-sudo mkdir -p "${final_path}/store/[data]/smarty3"
-sudo chmod -R 777 $final_path/store
+# 2 - Osada Addons
-# Import database schema
-ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < $final_path/install/schema_mysql.sql
+# Make addon Directory and unpack the Osada addons to this directory
+ynh_script_progression --message="Create addon directory inside Osada root folder..."
+mkdir $final_path/addon
+ynh_script_progression --message="Setting up Osada addons source files..."
+
+# ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
+pushd "$final_path"
+ util/add_addon_repo https://codeberg.org/zot/osada-addons.git zaddons
+popd
+
+# 3 - Some extra folders
+ynh_script_progression --message="Creating smarty3 folder for personal data..."
+
+mkdir -p "${final_path}/store/[data]/smarty3"
+chmod -R 775 $final_path/store
# Copy the template install/htconfig.sample.php to .htconfig.php
-sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php
-sudo touch "$final_path/php.log"
+ynh_script_progression --message="Moving .htconfig.php to root of Osada ..."
+config="$final_path/.htconfig.php"
+cp $final_path/install/htconfig.sample.php $config
-# Use sed to add the database information to .htconfig.php
-sudo sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php
-sudo sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php
-sudo sed -i "s/mysqlusername/$db_name/g" $final_path/.htconfig.php
-sudo sed -i "s/mysqldatabasename/$db_name/g" $final_path/.htconfig.php
-sudo 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
-sudo 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
-sudo 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
-sudo sed -i "s@//ini_set('display_errors', '0');@ini_set('display_errors', '0');@g" $final_path/.htconfig.php
+# Create php.log inside Osada for logs
+ynh_script_progression --message="Create php.log for the Osada debuging..."
+touch "$final_path/php.log"
+
+#=================================================
+# CREATE A DATABASE
+#=================================================
+
+if [ $database -eq 1 ]; then
+ ynh_script_progression --message="Creating a MySQL 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
+ 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..."
+ 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
+ ynh_psql_test_if_first_run
+ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
+ ynh_app_setting_set --app=$app --key=db_name --value=$db_name
+ ynh_script_progression --message="Importing database..."
+ ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
+else
+ ynh_die --message="Some problem occured in creating the database, contact maintainer"
+fi
+
+#=================================================
+# MODIFY A CONFIG FILE
+#=================================================
+
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
+ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$config"
+ynh_replace_string --match_string= "mysqlpassword" --replace_string="$db_pwd" --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= "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"
+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"
+ynh_replace_string --match_string= "//ini_set('log_errors','1');" --replace_string="ini_set('log_errors','1');" --target_file="$config"
+ynh_replace_string --match_string= "//ini_set('display_errors', '0');" --replace_string="ini_set('display_errors', '0');" --target_file="$config"
+sed -i "s/\['php_path'\] = 'php';/\['php_path'\] = 'php$phpversion';/g" "$config"
-
# addon ldap config
-sudo su -c "cat ../conf/ldap_conf.php >> $final_path/.htconfig.php"
+ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
+cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Configuring NGINX web server..."
+### `ynh_add_nginx_config` will use the file conf/nginx.conf
-# Create a dedicated nginx config
+# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_script_progression --message="Configuring system user..."
# Create a system user
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
+ynh_script_progression --message="Configuring PHP-FPM..."
+# Create a dedicated PHP-FPM config
+ynh_add_fpm_config --package="$extra_php_dependencies"
-# Create a dedicated php-fpm config
-ynh_add_fpm_config
-
-# Set right permissions for curl install
+# Set right permissions for Osada
+ynh_script_progression --message="Set right for Osada..."
chown -R $app: $final_path
-# Set up poller
-ynh_replace_string "YNH_WWW_PATH" "$final_path" ../conf/poller-cron
-ynh_replace_string "__USER__" "$app" ../conf/poller-cron
-sudo cp ../conf/poller-cron /etc/cron.d/$app
-
-# Make app public
-ynh_app_setting_set $app skipped_uris "/"
+# Set up cron job
+ynh_script_progression --message="Setting up cron job..."
+ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$final_path" --target_file="../conf/poller-cron"
+ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron"
+ynh_replace_string --match_string="__PHP_VERSION__" --replace_string="$phpversion" --target_file="../conf/poller-cron"
+cp ../conf/poller-cron /etc/cron.d/$app
#=================================================
-# STORE THE CHECKSUM OF THE CONFIG FILE
+# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$final_path/.htconfig.php"
+ynh_store_file_checksum --file="$config"
#=================================================
# SETUP LOGROTATE
#=================================================
+ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log"
-# Reload services
-systemctl reload nginx
-sudo yunohost app ssowatconf
+#=================================================
+# SETUP FAIL2BAN
+#=================================================
+ynh_script_progression --message="Add Fail2Ban..."
+ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5"
+
+#=================================================
+# SETUP SSOWAT
+#=================================================
+# As Osada is social network and have its own permission there is no need to keep Osada behind SSO
+ynh_script_progression --message="Configuring SSOwat..."
+ynh_permission_update --permission="main" --add="visitors"
+
+#=================================================
+# RELOAD NGINX
+#=================================================
+ynh_script_progression --message="Reloading NGINX web server..."
+
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Installation of $app completed"
diff --git a/scripts/remove b/scripts/remove
index a886b31..3232b7c 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,63 +12,98 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading installation settings..."
+
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-db_name=$(ynh_app_setting_get $app db_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 final_path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# STANDARD REMOVE
#=================================================
+# REMOVE THE DATABASE
+#=================================================
+
+if [ $database -eq 1 ]; then
+ # Removing MySQL database
+ ynh_script_progression --message="Removing MySQL database..."
+ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
+elif [ $database -eq 2 ]; then
+ # Removing PostgreSQL database
+ 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 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
#=================================================
+ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
-ynh_secure_remove "$final_path"
+ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Removing NGINX web server configuration..."
-# Remove the dedicated nginx config
+# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
+ynh_script_progression --message="Removing PHP-FPM configuration..."
-# Remove the dedicated php-fpm config
+# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
+#=================================================
+# REMOVE LOGROTATE CONFIGURATION
+#=================================================
+ynh_script_progression --message="Removing logrotate configuration..."
+
# Remove the app-specific logrotate config
-ynh_remove_logrotate "$final_path/php.log"
+ynh_remove_logrotate
+
+#=================================================
+# REMOVE THE CRON FILE
+#=================================================
# Remove a cron file
-ynh_secure_remove "/etc/cron.d/$app"
+ynh_secure_remove --file="/etc/cron.d/$app"
+
+#=================================================
+# REMOVE FAIL2BAN CONFIGURATION
+#=================================================
+ynh_script_progression --message="Removing Fail2Ban configuration..."
+
+ynh_remove_fail2ban_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
+ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
-ynh_system_user_delete $app
+ynh_system_user_delete --username=$app
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Removal of $app completed"
diff --git a/scripts/restore b/scripts/restore
index ee230e0..5f8af87 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,41 +6,46 @@
# IMPORT GENERIC HELPERS
#=================================================
-if [ ! -e _common.sh ]; then
- # Get the _common.sh file if it's not in the current directory
- cp ../settings/scripts/_common.sh ./_common.sh
- chmod a+rx _common.sh
-fi
-source _common.sh
+#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
+source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
+ynh_clean_setup () {
+ #### Remove this function if there's nothing to clean before calling the remove script.
+ true
+}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-admin=$(ynh_app_setting_get $app admin)
-final_path=$(ynh_app_setting_get $app final_path)
-db_name=$(ynh_app_setting_get $app db_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)
+database=$(ynh_app_setting_get --app=$app --key=database)
+db_user=$db_name
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
+ynh_script_progression --message="Validating restoration parameters..."
-ynh_webpath_available $domain $path_url \
- || ynh_die "Path not available: ${domain}${path_url}"
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+ || ynh_die --message="Path not available: ${domain}${path_url}"
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
@@ -48,25 +53,41 @@ test ! -d $final_path \
# 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
#=================================================
+ynh_script_progression --message="Restoring the app main directory..."
-ynh_restore_file "$final_path"
+ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
+ynh_script_progression --message="Restoring the MySQL database..."
-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
+if [ $database -eq 1 ]; 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
+ # Removing postgresql database
+ ynh_script_progression --message="Reinstalling dependencies..."
+ # Define and install dependencies
+ ynh_install_app_dependencies $pkg_dependencies
+ ynh_script_progression --message="Restoring the PostgreSQL database..."
+ 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
+ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
+fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
+ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create $app
@@ -74,27 +95,35 @@ ynh_system_user_create $app
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
+ynh_script_progression --message="Restoring PHP-FPM configuration..."
-ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
+
+# Recreate a dedicated php-fpm config
+ynh_add_fpm_config --package="$extra_php_dependencies"
#=================================================
# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_install_app_dependencies php-mbstring php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
-
#=================================================
# RESTORE THE CRON FILE
#=================================================
-ynh_restore_file "/etc/cron.d/$app"
+ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
-ynh_restore_file "/etc/logrotate.d/$app"
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
+
+#=================================================
+# RESTORE FAIL2BAN CONFIGURATION
+#=================================================
+ynh_script_progression --message="Restoring the Fail2Ban configuration..."
+
+ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
+ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
+ynh_systemd_action --action=restart --service_name=fail2ban
# Make app public
ynh_app_setting_set $app skipped_uris "/"
@@ -104,6 +133,13 @@ ynh_app_setting_set $app skipped_uris "/"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
+ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
-systemctl reload php5-fpm
-systemctl reload nginx
+ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Restoration completed for $app"
diff --git a/scripts/upgrade b/scripts/upgrade
index adbeced..7b87037 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -12,18 +12,32 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
+ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-final_path=$(ynh_app_setting_get $app final_path)
-upload=$(ynh_app_setting_get $app upload)
-db_name=$(ynh_app_setting_get $app db_name)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+upload=$(ynh_app_setting_get --app=$app --key=upload)
+last_update=$(grep update_time: /etc/yunohost/apps/$app/settings.yml | cut -c 14-)
+database=$(ynh_app_setting_get --app=$app --key=database)
+phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
+
+#=================================================
+# ENSURE DOWNWARD COMPATIBILITY
+#=================================================
+
+# If db_name doesn't exist, create it
+if [ -z "$db_name" ]; then
+ db_name=$(ynh_sanitize_dbid --db_name=$app)
+ ynh_app_setting_set --app=$app --key=db_name --value=$db_name
+fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@@ -34,70 +48,65 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
+#=================================================
+# STANDARD UPGRADE STEPS
#=================================================
# REMOVE APP MAIN DIR
#=================================================
-
-# Create a temporary directory
-tmpdir="$(mktemp -d)"
-# 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"
+ynh_print_info "Upgrading source files..."
+# 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"
# Remove the app directory securely
ynh_secure_remove "$final_path"
-# If db_name doesn't exist, create it
-if [ -z $db_name ]; then
- db_name=$(ynh_sanitize_dbid $app)
- ynh_app_setting_set $app db_name $db_name
-fi
-
# If final_path doesn't exist, create it
-if [ -z $final_path ]; then
+if [ -z "$final_path" ]; then
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
-#=================================================
-# CHECK THE PATH
-#=================================================
-
-# Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path $path_url)
-
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
+ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
-sudo cp -a "$tmpdir/store" "${final_path}"
-sudo cp -a "$tmpdir/.htconfig.php" "${final_path}"
-sudo cp -a "$tmpdir/php.log" "${final_path}"
-sudo rm -Rf "$tmpdir"
-sudo chmod -R 777 $final_path/store
-sudo mkdir $final_path/addon
-ynh_setup_source "$final_path/addon" "app_addons"
-
+ynh_setup_source --dest_dir="$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 "$tmpdir"
+# chmod -R 777 $final_path/store
+# mkdir $final_path/addon
+# ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
+pushd "$final_path"
+ util/udall
+popd
+chmod -R 775 $final_path/store
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Upgrading NGINX web server configuration..."
-# Create a dedicated nginx config
+# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_script_progression --message="Making sure dedicated system user exists..."
-# Create a system user
-ynh_system_user_create $app
+# Create a dedicated user (if not existing)
+ynh_system_user_create --username=$app
# Set right permissions for curl install
chown -R $app: $final_path
@@ -105,38 +114,71 @@ chown -R $app: $final_path
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
+ynh_print_info "Upgrading PHP-FPM configuration..."
# Create a dedicated php-fpm config
-ynh_add_fpm_config
+ynh_add_fpm_config --package="$extra_php_dependencies"
-# Verify the checksum and backup the file if it's different
-ynh_backup_if_checksum_is_different "$final_path/.htconfig.php"
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$final_path/.htconfig.php"
+### 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.
+ynh_backup_if_checksum_is_different --file="$final_path/.htconfig.php.back"
+# Recalculate and store the checksum of the file for the next upgrade.
+ynh_store_file_checksum --file="$final_path/.htconfig.php"
#=================================================
# SETUP LOGROTATE
#=================================================
+ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
-ynh_use_logrotate "$final_path/php.log" --non-append
+ynh_use_logrotate --non-append
-# Set up poller
-ynh_replace_string "YNH_WWW_PATH" "$final_path" ../conf/poller-cron
-ynh_replace_string "__USER__" "$app" ../conf/poller-cron
-sudo cp ../conf/poller-cron /etc/cron.d/$app
+# UPGRADE 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"
+
+# Set cron job
+ynh_print_info "Setting up cron job..."
+ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$final_path" --target_file="../conf/poller-cron"
+ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron"
+ynh_replace_string --match_string="__PHP_VERSION__" --replace_string="$phpversion" --target_file="../conf/poller-cron"
+cp -f ../conf/poller-cron /etc/cron.d/$app
#=================================================
-# INSTALL DEPENDENCIES
+# UPGRADE DEPENDENCIES
#=================================================
-ynh_install_app_dependencies php-mbstring php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
+ynh_script_progression --message="Upgrading dependencies..."
+if [ $database -eq 1 ]; then
+ #=================================================
+ # CHECK VERSION FOR SPECIFIC MYSQL UPDATE
+ #=================================================
+ # Check version and if this version was a fresh install push mysql query
+ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-# Make app public
-ynh_app_setting_set $app skipped_uris "/"
+elif [ $database -eq 2 ]; then
+ ynh_install_app_dependencies $pkg_dependencies
+fi
+
+#=================================================
+# SETUP SSOWAT
+#=================================================
+# As Osada is social network and have its own permission there is no need to keep Osada behind SSO
+ynh_script_progression --message="Upgrading SSOwat configuration..."
+ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#=================================================
# RELOAD NGINX
#=================================================
+ynh_script_progression --message="Reloading NGINX web server..."
-systemctl reload nginx
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Upgrade of $app completed"