1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/osada_ynh.git synced 2024-09-03 19:46:30 +02:00

Updated the app

This commit is contained in:
anmol26s 2021-02-12 17:34:45 +05:30
parent ee38215384
commit e71d8937b0
13 changed files with 544 additions and 288 deletions

36
LICENSE
View file

@ -1,20 +1,22 @@
Copyright (c) 2010-2017 the Hubzilla Community This is free and unencumbered software released into the public domain.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy Anyone is free to copy, modify, publish, use, compile, sell, or
of this software and associated documentation files (the "Software"), to deal distribute this software, either in source code form or as a compiled
in the Software without restriction, including without limitation the rights binary, for any purpose, commercial or non-commercial, and by any
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell means.
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in In jurisdictions that recognize copyright laws, the author or authors
all copies or substantial portions of the Software. 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 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
THE SOFTWARE. OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,32 +1,63 @@
# Osada for Yunohost # Osada for YunoHost
[![Integration level](https://dash.yunohost.org/integration/osada.svg)](https://ci-apps.yunohost.org/jenkins/job/osada%20%28Community%29/lastBuild/consoleFull) [![Integration level](https://dash.yunohost.org/integration/osada.svg)](https://dash.yunohost.org/appci/app/osada) ![](https://ci-apps.yunohost.org/ci/badges/osada.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/osada.maintain.svg)
[![Install osada with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=osada) <br><br>
Shipped version: **2.2** [![Install Osada with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=osada)
<br>
> *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
![](http://zotlabs.com/osada/img/comment_on_posts.gif)
## 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 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/osada%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/osada/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/osada%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/osada/)
### Interesting links ### Interesting links
- [YunoHost project](https://yunohost.org) - [YunoHost project](https://yunohost.org)
- [Osada/Zap website](http://zotlabs.com/osada/) - [Osada website](http://zotlabs.com/osada/)
- [Osada/Zap code on Framagit](https://framagit.org/macgirvin/osada) - [Osada code on Framagit](https://codeberg.org/zot/osada)
- [Osada/Zap addons on Framagit](https://framagit.org/macgirvin/osada-addons) - [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. <br>
<p align="center"><img src="http://zotlabs.com/osada/img/comment_on_posts.gif"></p> ## Developer info
<br>
**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.
<br><br>
## 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**.
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
```

View file

@ -1,34 +1,26 @@
;; Default test # See here for more information
auto_remove=1 # 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 ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
admin="john" (USER) admin="john" (USER)
; Checks database="1" (STRING)
pkg_linter=1 ; Checks
setup_sub_dir=0 pkg_linter=1
setup_root=1 setup_sub_dir=0
setup_nourl=0 setup_root=1
setup_private=0 setup_nourl=0
setup_public=1 setup_private=0
upgrade=1 setup_public=1
backup_restore=1 upgrade=1
multi_instance=1 #upgrade=1 from_commit=
incorrect_path=1 backup_restore=1
port_already_use=0 multi_instance=1
change_url=0 port_already_use=0
;;; Levels change_url=0
Level 1=auto ;;; Options
Level 2=auto Email=
Level 3=auto Notification=
# 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=

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://framagit.org/zot/osada/-/archive/2.2/osada-2.2.tar.gz SOURCE_URL=https://codeberg.org/zot/osada/archive/3cc4ea6304ed12a5f373c035482283d11f3d31ee.tar.gz
SOURCE_SUM=3861e2e48ce532277ed35f00d7e28c7a75ef0e5ea8a52e4db1832d6de2d4a112 SOURCE_SUM=759c8a662ce7e927939f73d5ddde89c03ff4d2cb1749a1e5cbbc0694734e9c01
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/osada-addons/-/archive/2.2/osada-addons-2.2.tar.gz SOURCE_URL=https://codeberg.org/zot/osada-addons/archive/f114c32aa84f80f940815d2158ddeef9734eb996.tar.gz
SOURCE_SUM=e5185d043fa09ea13a3224a9f0bf4746bc76659ffa6346b1a52f8905dcd980dc SOURCE_SUM=664fdf03a0a77d358f976f5dd9fdf2b1df1bfa2cbfcc31714264d6562b95096c
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 +0,0 @@
define('NOMADIC',1);

View file

@ -7,19 +7,20 @@
"fr": "Osada est une plateforme de publication décentralisée et un réseau social." "fr": "Osada est une plateforme de publication décentralisée et un réseau social."
}, },
"url": "http://zotlabs.com/osada/", "url": "http://zotlabs.com/osada/",
"license": "Free as-is", "license": "MIT",
"version": "2.2", "version": "21.02.11~ynh1",
"maintainer": { "maintainer": {
"name": "Anmol Sharma", "name": "Anmol Sharma",
"email": "anmol@datamol.org" "email": ""
}, },
"services": [ "services": [
"nginx", "nginx",
"php5-fpm", "php7.0-fpm",
"mysql" "mysql",
"postgresql"
], ],
"requirements": { "requirements": {
"yunohost": ">= 3.0.0" "yunohost": ">= 4.0.0"
}, },
"multi_instance": true, "multi_instance": true,
"arguments": { "arguments": {
@ -39,6 +40,16 @@
"en": "Choose the Osada administrator (must be an existing YunoHost user)", "en": "Choose the Osada administrator (must be an existing YunoHost user)",
"fr": "Choisissez l'administrateur de Osada (doit être un utilisateur YunoHost existant)" "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"
} }
] ]
} }

View file

@ -1,13 +1,25 @@
#!/bin/bash #!/bin/bash
# ============= FUTURE YUNOHOST HELPER ============= #=================================================
# Delete a file checksum from the app settings # COMMON VARIABLES
# #=================================================
# $app should be defined when calling this helper
# # dependencies used by the app
# usage: ynh_remove_file_checksum file YNH_PHP_VERSION="7.3"
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () { 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"
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name # dependencies used by the app
} pkg_dependencies="postgresql postgresql-contrib"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -6,65 +6,92 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# 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 /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..."
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)
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 # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # 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 # 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 # 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)."

View file

@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -23,145 +27,210 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN 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" 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 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_script_progression --message="Validating installation parameters..."
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"
# 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 # 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 # STORE SETTINGS FROM MANIFEST
ynh_app_setting_set $app path $path_url #=================================================
ynh_app_setting_set $app admin $admin ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set $app email $email
ynh_app_setting_set $app upload $upload
ynh_app_setting_set $app database $database
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 # 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 # 1 - Osada
ynh_app_setting_set $app final_path $final_path ynh_script_progression --message="Setting up Osada source files..."
ynh_setup_source "$final_path"
sudo mkdir $final_path/addon
ynh_setup_source "$final_path/addon" "app_addons"
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 # 2 - Osada Addons
sudo mkdir -p "${final_path}/store/[data]/smarty3"
sudo chmod -R 777 $final_path/store
# Import database schema # Make addon Directory and unpack the Osada addons to this directory
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < $final_path/install/schema_mysql.sql 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 # Copy the template install/htconfig.sample.php to .htconfig.php
sudo cp $final_path/install/htconfig.sample.php $final_path/.htconfig.php ynh_script_progression --message="Moving .htconfig.php to root of Osada ..."
sudo touch "$final_path/php.log" config="$final_path/.htconfig.php"
cp $final_path/install/htconfig.sample.php $config
# Use sed to add the database information to .htconfig.php # Create php.log inside Osada for logs
sudo sed -i "s/your.mysqlhost.com/localhost/g" $final_path/.htconfig.php ynh_script_progression --message="Create php.log for the Osada debuging..."
sudo sed -i "s/mysqlpassword/$db_pwd/g" $final_path/.htconfig.php touch "$final_path/php.log"
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 # CREATE A DATABASE
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 if [ $database -eq 1 ]; then
sudo sed -i "s@//ini_set('error_log','php.out');@ini_set('error_log','php.log');@g" $final_path/.htconfig.php ynh_script_progression --message="Creating a MySQL database..."
sudo sed -i "s@//ini_set('log_errors','1');@ini_set('log_errors','1');@g" $final_path/.htconfig.php db_name=$(ynh_sanitize_dbid --db_name=$app)
sudo sed -i "s@//ini_set('display_errors', '0');@ini_set('display_errors', '0');@g" $final_path/.htconfig.php 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 # 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 # 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 ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..."
# 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_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 # Set right permissions for Osada
ynh_add_fpm_config ynh_script_progression --message="Set right for Osada..."
# Set right permissions for curl install
chown -R $app: $final_path chown -R $app: $final_path
# Set up poller # Set up cron job
ynh_replace_string "YNH_WWW_PATH" "$final_path" ../conf/poller-cron ynh_script_progression --message="Setting up cron job..."
ynh_replace_string "__USER__" "$app" ../conf/poller-cron ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$final_path" --target_file="../conf/poller-cron"
sudo cp ../conf/poller-cron /etc/cron.d/$app 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"
# Make app public cp ../conf/poller-cron /etc/cron.d/$app
ynh_app_setting_set $app skipped_uris "/"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
# 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="$config"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log" ynh_use_logrotate "$final_path/php.log"
# Reload services #=================================================
systemctl reload nginx # SETUP FAIL2BAN
sudo yunohost app ssowatconf #=================================================
ynh_script_progression --message="Add Fail2Ban..."
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --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"

View file

@ -12,63 +12,98 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..."
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)
database=$(ynh_app_setting_get --app=$app --key=database)
#================================================= #=================================================
# STANDARD REMOVE # 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 # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_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 # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..."
# 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_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated nginx config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # 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 ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate "$final_path/php.log" ynh_remove_logrotate
#=================================================
# REMOVE THE CRON FILE
#=================================================
# 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
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..."
ynh_remove_fail2ban_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a 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"

View file

@ -6,41 +6,46 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..."
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)
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 # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..."
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
@ -48,25 +53,41 @@ 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_script_progression --message="Restoring the app main directory..."
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..."
db_pwd=$(ynh_app_setting_get $app mysqlpwd) if [ $database -eq 1 ]; then
ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_script_progression --message="Restoring MySQL database..."
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql 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 # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
@ -74,27 +95,35 @@ ynh_system_user_create $app
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # 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 # 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 # 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
#=================================================
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 # Make app public
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set $app skipped_uris "/"
@ -104,6 +133,13 @@ ynh_app_setting_set $app skipped_uris "/"
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
systemctl reload php5-fpm ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"

View file

@ -12,18 +12,32 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..."
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) 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 # 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 # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -34,70 +48,65 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Upgrading source files..."
# 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"
# 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 # Remove the app directory securely
ynh_secure_remove "$final_path" 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 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
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..."
# 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"
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"
# 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 # 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 ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a system user # 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
@ -105,38 +114,71 @@ chown -R $app: $final_path
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading PHP-FPM configuration..."
# Create a dedicated php-fpm config # 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 ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "$final_path/.htconfig.php" ### 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.
# Recalculate and store the config file checksum into the app settings ynh_backup_if_checksum_is_different --file="$final_path/.htconfig.php.back"
ynh_store_file_checksum "$final_path/.htconfig.php" # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/.htconfig.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s) # 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 # UPGRADE FAIL2BAN
ynh_replace_string "YNH_WWW_PATH" "$final_path" ../conf/poller-cron #=================================================
ynh_replace_string "__USER__" "$app" ../conf/poller-cron ynh_script_progression --message="Re-configure Fail2Ban..."
sudo cp ../conf/poller-cron /etc/cron.d/$app
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --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 elif [ $database -eq 2 ]; then
ynh_app_setting_set $app skipped_uris "/" 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 # 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"