1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/friendica_ynh.git synced 2024-09-03 18:36:14 +02:00

Merge pull request #39 from YunoHost-Apps/testing

Updated to latest version 2021.01
This commit is contained in:
anmol26s 2021-02-10 10:14:44 +05:30 committed by GitHub
commit 162e91d2df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 166 additions and 165 deletions

View file

@ -1,5 +1,5 @@
Friendica Communications Server
Copyright (c) 2010-2017 the Friendica Project
Copyright (c) 2010-2020 the Friendica Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by

View file

@ -1,48 +1,70 @@
# Friendica for YunoHost
[![Integration level](https://dash.yunohost.org/integration/friendica.svg)](https://dash.yunohost.org/appci/app/friendica) ![](https://ci-apps.yunohost.org/ci/badges/friendica.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/friendica.maintain.svg)
[![Install Friendica with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=friendica)
> *This package allow you to install Friendica quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to learn how to install and enjoy it.*
## Overview
Friendica is a software to create a distributed social network. It is part of the federation of servers that are running with Friendica, Diaspora and Hubzilla which are compatible to each other.
**Version:** 2020.03
**Version:** 2021.01
Current snapshot in *sources*:
* https://github.com/friendica/friendica: 2020.03
* https://github.com/friendica/friendica-addons: 2020.03
* https://github.com/friendica/friendica: 2021.01
* https://github.com/friendica/friendica-addons: 2021.01
## Important Notes
**Warning:** It's advised to use Barracuda as MySQL DB file format for your Friendica database.
Before installing, read the [Friendica installation instructions](https://github.com/friendica/friendica/blob/master/INSTALL.txt) for important information about
- SSL certificate validation requirement (now with support for [Let's Encrypt!](https://letsencrypt.org)). See Installation section below.
- Dedicated domain (must install under web root like **https://hub.example.com/** not **https://example.com/hub/** )
## Friendica
[Friendica](http://friendi.ca/) is a decentralised communications platform that integrates social communication. Our platform links to independent social projects and corporate services.
#### Multi-users support
Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on **Friendica**, **Mastodon**, **Diaspora**, **GnuSocial**, **Pleroma**, or **Hubzilla**, regardless where each user profile is hosted.
LDAP auth supported. There are not yet active SSO.
![](https://raw.githubusercontent.com/friendica/friendica/develop/images/screenshots/friendica-frio-green-profle-1.png)
# To-do
- [ ] Fail2Ban support
## This app claims following features:
- [ ] Ldap integration(Ldap is broken in the latest version.[See this](https://github.com/friendica/friendica/issues/4140#issuecomment-731579013))
- [X] Multi-instance
- [ ] Add 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**).
- [ ] Fail2ban
## Installation
### Register a new domain and add it to YunoHost
Friendica requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Friendica uses the full domain and is installed on the root, you can create a subdomain such as friendica.domain.tld. Don't forget to update your DNS if you manage them manually.
### Install the Friendica application
Use the YunoHost admin panel to install Friendica by entering the GitHub repo address in the custom app URL
Before installing, read the [Friendica installation instructions](https://github.com/friendica/friendica/blob/develop/doc/Install.md) for important information about installation.
- Dedicated domain (must install under web root like **https://friendica.example.com/** not **https://example.com/friendica/** )
- Friendica requires browser-approved SSL certificates.
### Install Friendica
Use the YunoHost admin panel to install Friendica by entering the GitHub repo address in the custom app URL:
https://github.com/YunoHost-Apps/friendica_ynh
Make sure to select your domain from the previous section as the application domain.
After the installation,login with the username provided at the time of the installaion with your SSO password.You can then create your profile and access the admin panel from the button in the center of the top nav bar, just adjecent to the search bar.<b>(The admin panel don't have text,so don't get confuse with it)
Public users can register and use the instance as normal users. SSO users can login with there username and password as normal users too.
## User with ldap admin rights
**For admin rights**: When installation is complete, you will need to visit your domain page and login with the **admin account username and password** which was entered at the time of installation process. You can then create your profile and access the admin panel.
**For normal YunoHost users :** Normal LDAP users can login through Ldap authentication and create there profiles.
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/friendica%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/friendica/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/friendica%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/friendica/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/friendica%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/friendica/)
## Links

View file

@ -10,17 +10,10 @@
setup_private=0
setup_public=1
upgrade=1
upgrade=1 from_commit=3396188976f75170f2217fcc0e6c9b5f61f7b9e9
backup_restore=1
multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0
change_url=0
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options
Email=anmol@datamol.org
Notification=change

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2020.03.tar.gz
SOURCE_SUM=937aa87bbe8a40ef78348387969e77ac0422d2ce8bd00579aaf4ce45ea1362da
SOURCE_URL=https://files.friendi.ca/friendica-addons-2021.01.tar.gz
SOURCE_SUM=13d1a31373ec3e47913386241f5bee7524c18ddb77258cbf7b410450ec2cd601
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -1,6 +1,6 @@
SOURCE_URL=https://friendi.ca/wp-content/uploads/2020/03/friendica-full-2020.03.tar.gz
SOURCE_SUM=dbfb001a90533e57fc453ff8d8d5c017236251aef78e5feb9902744d8b8dc1bd
SOURCE_URL=https://files.friendi.ca/friendica-full-2021.01.tar.gz
SOURCE_SUM=b6f6ac81a0dd8e4bd32848ab2b6a54c35baf104d77abb589751fbd4f26edbcd7
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_IN_SUBDIR=2
SOURCE_FILENAME=

View file

@ -73,7 +73,7 @@ location __PATH__/ {
location ~* \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

View file

@ -1,2 +1,2 @@
# Run poller periodically to update Friendica
*/10 * * * * __USER__ cd __YNH_WWW_PATH__; /usr/bin/php bin/worker.php
*/10 * * * * __USER__ cd __YNH_WWW_PATH__; /usr/bin/php__PHP_VERSION__ bin/worker.php

View file

@ -8,13 +8,13 @@
},
"url": "http://friendi.ca",
"license": "free",
"version": "2020.03~ynh2",
"version": "2021.01~ynh1",
"maintainer": {
"name": "Anmol Sharma",
"email": "anmol@datamol.org"
},
"requirements": {
"yunohost": ">= 3.5"
"yunohost": ">= 4.0.0"
},
"previous_maintainers": {
"name": "aymhce",
@ -23,7 +23,7 @@
"multi_instance": true,
"services": [
"nginx",
"php5-fpm",
"php7.3-fpm",
"mysql"
],
"arguments": {
@ -32,7 +32,7 @@
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for Friendica.Friendica must be installed on the ROOT domain, so be careful",
"en": "Choose a domain for Friendica. Friendica must be installed on the ROOT domain, so be careful!",
"fr": "Choisissez un domaine pour Friendica.Friendica doit etre installe a la racine, soyez prudent"
},
"example": "domain.org"

View file

@ -5,38 +5,7 @@
#=================================================
# dependencies used by the app
pkg_dependencies="php-mbstring php-cli php-imagick php-gd php-xml"
YNH_PHP_VERSION="7.3"
pkg_dependencies=""
# =============================================================================
# COMMON ROUNDCUBE FUNCTIONS
# =============================================================================
# Execute a composer command from a given directory
# usage: composer_exec workdir COMMAND [ARG ...]
exec_composer() {
local workdir=$1
shift 1
COMPOSER_HOME="${workdir}/.composer" \
php "${workdir}/composer.phar" $@ \
-d "${workdir}" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
# usage: init_composer destdir
init_composer() {
local destdir=$1
# install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="${destdir}/.composer" \
php -- --quiet --install-dir="$destdir" \
|| ynh_die "Unable to install Composer"
# install composer.json
cp "${destdir}/composer.json-dist" "${destdir}/composer.json"
# update dependencies to create composer.lock
exec_composer "$destdir" install --no-dev \
|| ynh_die "Unable to update Roundcube core dependencies"
}
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}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"

View file

@ -24,7 +24,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -32,6 +32,7 @@ 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)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# STANDARD BACKUP STEPS
@ -39,28 +40,28 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
ynh_script_progression --message="Backing up the main app directory..."
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
ynh_script_progression --message="Backing up nginx web server configuration..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
ynh_script_progression --message="Backing up php-fpm configuration..."
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
ynh_script_progression --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
@ -71,4 +72,4 @@ ynh_backup --src_path="/etc/cron.d/$app"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -56,8 +56,7 @@ app=$YNH_APP_INSTANCE_NAME
### Use the execution time, given by --time, to estimate the weight of a step.
### A common way to do it is to set a weight equal to the execution time in second +1.
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
ynh_script_progression --message="Validating installation parameters..."
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
@ -69,7 +68,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --time --weight=1
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
@ -81,7 +80,7 @@ ynh_app_setting_set --app=$app --key=database --value=$database
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --time --weight=1
ynh_script_progression --message="Installing dependencies..."
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
### Those deb packages will be installed as dependencies of this package.
@ -96,7 +95,7 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
ynh_script_progression --message="Creating a MySQL database..."
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
@ -115,7 +114,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --time --weight=1
ynh_script_progression --message="Setting up source files..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
@ -128,13 +127,13 @@ ynh_setup_source --dest_dir="$final_path"
cp -f "$final_path/.htaccess-dist" "$final_path/.htaccess"
# 2 - Addons
sudo mkdir $final_path/addon
mkdir $final_path/addon
ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
ynh_script_progression --message="Configuring nginx web server..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
@ -143,25 +142,26 @@ ynh_add_nginx_config
# configure friendica
sudo cp -f "/var/www/$app/config/local-sample.config.php" "/var/www/$app/config/local.config.php"
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$final_path/config/local.config.php"
config="$final_path/config/local.config.php"
cp -f "$final_path/config/local-sample.config.php" $config
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --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="mysqlpassword" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$config"
#ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$config"
# init db
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql"
# addon config
# ldap addon config
cp "../conf/addon.config.php" "$final_path/config/."
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app
@ -169,7 +169,8 @@ ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
ynh_script_progression --message="Configuring php-fpm..."
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
@ -183,17 +184,16 @@ ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
# Create a dedicated php-fpm config
ynh_add_fpm_config
ynh_add_fpm_config --package="$extra_php_dependencies"
chown -R www-data:www-data $final_path
# 3 - some extra folders
sudo mkdir -p "${final_path}/view/smarty3"
sudo chmod -R 775 $final_path/view/smarty3
mkdir -p "${final_path}/view/smarty3"
chmod -R 775 $final_path/view/smarty3
# Set up poller
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
#=================================================
@ -208,10 +208,17 @@ cp ../conf/poller-cron /etc/cron.d/$app
ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
pushd "$final_path"
php$phpversion bin/composer.phar install
bin/console config system addon ldapauth
popd
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO addon (id, name, version, installed, hidden, timestamp, plugin_admin) VALUES (NULL, 'ldapauth', '', '1', '0', UNIX_TIMESTAMP(), '0');"
#=================================================
# Folder rights
#=================================================
chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
@ -224,7 +231,7 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -232,4 +239,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --time --last
ynh_script_progression --message="Installation of $app completed"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -24,7 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
ynh_script_progression --message="Removing the MySQL database..."
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
@ -32,7 +32,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --time --weight=1
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
@ -40,7 +40,7 @@ ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --time --weight=1
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -48,7 +48,7 @@ ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -56,7 +56,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
ynh_script_progression --message="Removing php-fpm configuration..."
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
@ -64,7 +64,7 @@ ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
@ -77,7 +77,7 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app

View file

@ -26,7 +26,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --time --weight=1
ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
@ -34,12 +34,12 @@ 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)
db_name=$(ynh_app_setting_get --app=$app --key=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..." --time --weight=1
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
@ -64,7 +64,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
@ -79,15 +79,19 @@ ynh_system_user_create $app
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring PHP-FPM configuration..."
ynh_restore_file "/etc/php/7.0/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_script_progression --message="Reinstalling dependencies..." --time --weight=1
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
@ -100,12 +104,12 @@ chmod -R 775 $final_path/view/smarty3
#=================================================
ynh_restore_file "/etc/cron.d/$app"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
#=================================================
# Folder rights
#=================================================
chown -R $app: $final_path
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
@ -114,13 +118,13 @@ ynh_app_setting_set $app unprotected_uris "/"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
ynh_systemd_action --service_name=php7.0-fpm --action=reload
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" --time --last
ynh_script_progression --message="Restoration completed for $app"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -23,6 +23,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
admin_mail=$(ynh_app_setting_get --app=$app --key=email)
admin=$(ynh_app_setting_get --app=$app --key=admin)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK VERSION
@ -39,7 +40,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
ynh_script_progression --message="Ensuring downward compatibility..."
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
@ -50,7 +51,7 @@ fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
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
@ -102,22 +103,23 @@ fi
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --time --weight=1
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
# Copy config file for correct place
cp -f "/var/www/$app/config/local-sample.config.php" "/var/www/$app/config/local.config.php"
config="$final_path/config/local.config.php"
cp -f "/var/www/$app/config/local-sample.config.php" $config
# Replace strings in config file
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file= "$final_path/config/local.config.php"
ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --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="mysqlpassword" --replace_string="$db_pwd" --target_file= "$config"
ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$config"
ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$config"
#Copy Addons
@ -131,7 +133,7 @@ chmod -R 775 $final_path/view/smarty3
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
ynh_script_progression --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -139,14 +141,13 @@ ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
@ -154,12 +155,10 @@ ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
ynh_script_progression --message="Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config
ynh_add_fpm_config
ynh_add_fpm_config --package="$extra_php_dependencies"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@ -174,19 +173,26 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Set 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"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
# Run composer
pushd "$final_path"
php$phpversion bin/console dbstructure update
bin/console config system addon ldapauth
popd
# Set app as owner
#=================================================
# Folder rights
#=================================================
chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
ynh_script_progression --message="Upgrading SSOwat configuration..."
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
@ -194,7 +200,7 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -202,5 +208,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --time --last
ynh_script_progression --message="Upgrade of $app completed"