mirror of
https://github.com/YunoHost-Apps/friendica_ynh.git
synced 2024-09-03 18:36:14 +02:00
Merge pull request #26 from YunoHost-Apps/fix-buster
Apply example_ynh + fix Buster
This commit is contained in:
commit
2b7e80e7d4
12 changed files with 251 additions and 239 deletions
26
README.md
26
README.md
|
@ -1,20 +1,19 @@
|
|||
# Friendica social network for YunoHost
|
||||
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/friendica)
|
||||
[](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.*
|
||||
|
||||
## Overview
|
||||
Friendica (formerly Friendika, originally Mistpark) is an open, free, distributed social network. It forms one part of the Fediverse, an interconnected and decentralized network of independently operated servers.
|
||||
|
||||
[Friendica](http://friendi.ca/) integration for YunoHost<br>
|
||||
**Version:2020.03**<br><br>
|
||||
|
||||
Current snapshot in *sources*:
|
||||
## Screenshots
|
||||
|
||||
* https://github.com/friendica/friendica: 2020.03
|
||||
* https://github.com/friendica/friendica-addons: 2020.03
|
||||

|
||||
|
||||
## Important Notes
|
||||
|
||||
|
@ -30,7 +29,6 @@ LDAP auth supported. There are not yet active SSO.
|
|||
# To-do
|
||||
- [ ] Fail2Ban support
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### Register a new domain and add it to YunoHost
|
||||
|
@ -46,6 +44,19 @@ Make sure to select your domain from the previous section as the application dom
|
|||
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) </b>
|
||||
Public users can register and use the instance as normal users. SSO users can login with there username and password as normal users too.
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/friendica/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/friendica/)
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/friendica_ynh/issues
|
||||
* App website: https://friendi.ca/
|
||||
* Upstream app repository: https://github.com/friendica/friendica
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
Developers info
|
||||
----------------
|
||||
|
||||
|
@ -56,6 +67,5 @@ To try the testing branch, please proceed like that.
|
|||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug
|
||||
sudo yunohost app upgrade friendica -u https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://friendi.ca/wp-content/uploads/2020/03/friendica-full-2020.03.tar.gz
|
||||
SOURCE_SUM=dbfb001a90533e57fc453ff8d8d5c017236251aef78e5feb9902744d8b8dc1bd
|
||||
SOURCE_URL=https://github.com/friendica/friendica/archive/2020.03.tar.gz
|
||||
SOURCE_SUM=24aa577b6ef4d98aa3681df07ddd709ea201df9d8b8ded357fa03db3198ccfc5
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
location __PATH__ {
|
||||
alias __FINALPATH__/;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
@ -39,17 +40,13 @@ location __PATH__ {
|
|||
rewrite ^(.*)$ /index.php?pagename=$1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#allow uploads up to 20MB in size
|
||||
client_max_body_size 20m;
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
|
||||
#Default indexes and catch-all
|
||||
index index.php;
|
||||
|
||||
|
||||
# make sure webfinger and other well known services aren't blocked
|
||||
# by denying dot files and rewrite request to the front controller
|
||||
location ^~ /.well-known/ {
|
||||
|
@ -66,22 +63,22 @@ location __PATH__ {
|
|||
deny all;
|
||||
}
|
||||
|
||||
|
||||
#Execute and serve PHP files
|
||||
location ~* \.php$ {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
try_files $uri =404;
|
||||
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
|
||||
|
||||
# deny access to all dot files
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
#Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
|
@ -376,6 +376,15 @@ chdir = __FINALPATH__
|
|||
; Default Value: yes
|
||||
;clear_env = no
|
||||
|
||||
; Clear environment in FPM workers
|
||||
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||
; by clearing the environment in workers before env vars specified in this
|
||||
; pool configuration are added.
|
||||
; Setting to "no" will make all environment variables available to PHP code
|
||||
; via getenv(), $_ENV and $_SERVER.
|
||||
; Default Value: yes
|
||||
;clear_env = no
|
||||
|
||||
; Limits the extensions of the main script FPM will allow to parse. This can
|
||||
; prevent configuration mistakes on the web server side. You should only limit
|
||||
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
"en": "Social Communication Server",
|
||||
"fr": "Serveur de Communication Social"
|
||||
},
|
||||
"version": "2020.03-ynh2",
|
||||
"url": "http://friendi.ca",
|
||||
"license": "free",
|
||||
"version": "2020.03-ynh2",
|
||||
"maintainer": {
|
||||
"name": "Anmol Sharma",
|
||||
"email": "anmol@datamol.org"
|
||||
|
@ -23,7 +23,7 @@
|
|||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"php7.0-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
|
@ -46,7 +46,6 @@
|
|||
},
|
||||
"example": "homer"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,36 +7,14 @@
|
|||
# dependencies used by the app
|
||||
pkg_dependencies="php-mbstring php-cli php-imagick php-gd php-xml"
|
||||
|
||||
# =============================================================================
|
||||
# COMMON ROUNDCUBE FUNCTIONS
|
||||
# =============================================================================
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Execute a composer command from a given directory
|
||||
# usage: composer_exec workdir COMMAND [ARG ...]
|
||||
exec_composer() {
|
||||
local workdir=$1
|
||||
shift 1
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
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"
|
||||
}
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
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
|
||||
|
@ -64,7 +63,13 @@ ynh_script_progression --message="Backing up the MySQL database..." --time --wei
|
|||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
# Backup cron job
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP A CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up a cron file..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
|
|
133
scripts/install
133
scripts/install
|
@ -7,6 +7,7 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_composer__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -14,7 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
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
|
||||
|
@ -24,7 +24,6 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url='/'
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
|
@ -32,34 +31,13 @@ admin_mail=$(yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
|
|||
is_public=1
|
||||
database="1"
|
||||
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
### The 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 interests you most, since this is
|
||||
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||
### db names, ...
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
### About --weight and --time
|
||||
### ynh_script_progression will show to your final users the progression of each scripts.
|
||||
### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
|
||||
### --time is a packager option, it will show you the execution time since the previous call.
|
||||
### This option should be removed before releasing your app.
|
||||
### Use the execution time, given by --time, to estimate the weight of a step.
|
||||
### A common way to do it is to set a weight equal to the execution time in second +1.
|
||||
### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
|
||||
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||
|
||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app 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
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
|
@ -83,14 +61,6 @@ ynh_app_setting_set --app=$app --key=database --value=$database
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||
|
||||
### `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.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||
### - Remove the variable "pkg_dependencies" in _common.sh
|
||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
|
@ -98,15 +68,6 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
|
||||
|
||||
### 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.
|
||||
### The password will be stored as 'mysqlpwd' into the app settings,
|
||||
### and will be available as $db_pwd
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
|
||||
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
|
||||
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
|
@ -117,10 +78,6 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
|||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --time --weight=1
|
||||
|
||||
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||
### downloaded from an upstream source, like a git repository.
|
||||
### `ynh_setup_source` use the file conf/app.src
|
||||
|
||||
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"
|
||||
|
@ -128,7 +85,7 @@ ynh_setup_source --dest_dir="$final_path"
|
|||
cp -f "$final_path/.htaccess-dist" "$final_path/.htaccess"
|
||||
|
||||
# 2 - Addons
|
||||
sudo mkdir $final_path/addon
|
||||
sudo mkdir -p $final_path/addon
|
||||
ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
|
||||
|
||||
#=================================================
|
||||
|
@ -136,28 +93,9 @@ ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
|
||||
# Create a dedicated nginx config
|
||||
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"
|
||||
|
||||
|
||||
# init db
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql"
|
||||
|
||||
# addon config
|
||||
cp "../conf/addon.config.php" "$final_path/config/."
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -171,56 +109,79 @@ ynh_system_user_create --username=$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
|
||||
|
||||
### `ynh_add_fpm_config` is used to set up a PHP config.
|
||||
### You can remove it if your app doesn't use PHP.
|
||||
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
||||
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
|
||||
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
||||
### With the reload at the end of the script.
|
||||
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# CONFIGURE FRIENDICA
|
||||
#=================================================
|
||||
|
||||
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="REGISTER_OPEN" --replace_string="REGISTER_CLOSED" --target_file="$final_path/config/local.config.php"
|
||||
|
||||
#=================================================
|
||||
# INIT DB
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql"
|
||||
|
||||
#=================================================
|
||||
# ADDON CONFIG
|
||||
#=================================================
|
||||
|
||||
cp "../conf/addon.config.php" "$final_path/config/."
|
||||
|
||||
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
|
||||
|
||||
# Set up poller
|
||||
#=================================================
|
||||
# SETUP A 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"
|
||||
cp ../conf/poller-cron /etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# INSTALL THE APPLICATION
|
||||
#=================================================
|
||||
|
||||
### `ynh_store_file_checksum` is used to store the checksum of a file.
|
||||
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
|
||||
### you can make a backup of this file before modifying it again if the admin had modified it.
|
||||
ynh_install_composer
|
||||
(cd $final_path && sudo bin/console config system addon ldapauth)
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
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)
|
||||
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');"
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Securing files and directories..."
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
|
@ -62,12 +62,11 @@ ynh_script_progression --message="Removing php-fpm configuration..." --time --we
|
|||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
# REMOVE THE CRON FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the cron file..." --time --weight=1
|
||||
|
||||
# Remove a cron file
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
|
@ -86,4 +85,4 @@ ynh_system_user_delete --username=$app
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||
|
|
|
@ -15,14 +15,11 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
@ -34,7 +31,7 @@ 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)
|
||||
|
||||
db_user=$db_name
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -54,13 +51,6 @@ test ! -d $final_path \
|
|||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -71,16 +61,26 @@ ynh_restore_file --origin_path="$final_path"
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Recreating the dedicated system user..."
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user rights..." --time --weight=1
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $final_path
|
||||
# set permission
|
||||
chmod -R 775 $final_path/view/smarty3
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -92,23 +92,20 @@ ynh_script_progression --message="Reinstalling dependencies..." --time --weight=
|
|||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
# set permission
|
||||
chmod -R 775 $final_path/view/smarty3
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
|
||||
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)
|
||||
|
||||
chown -R $app: $final_path
|
||||
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_composer__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -28,12 +29,6 @@ admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||
### $upgrade_type can have 2 different values
|
||||
### - UPGRADE_APP if the upstream app version has changed
|
||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
|
@ -61,7 +56,6 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
@ -96,6 +90,8 @@ if [ -z $admin_mail ]; then
|
|||
ynh_app_setting_set --app=$app --key=email --value=$admin_mail
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -106,27 +102,13 @@ then
|
|||
|
||||
# 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"
|
||||
|
||||
# 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"
|
||||
|
||||
|
||||
#Copy Addons
|
||||
rm -Rf "$final_path/addon"
|
||||
ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
|
||||
|
||||
# 3 - some extra folders
|
||||
chmod -R 775 $final_path/view/smarty3
|
||||
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -159,28 +141,56 @@ ynh_script_progression --message="Upgrading php-fpm configuration..." --time --w
|
|||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPGRADE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/config/local.config.php"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$final_path/config/local.config.php"
|
||||
# Copy config file for correct place
|
||||
cp -f "/var/www/$app/config/local-sample.config.php" "$final_path/config/local.config.php"
|
||||
|
||||
# Set up cron job
|
||||
# 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="REGISTER_OPEN" --replace_string="REGISTER_CLOSED" --target_file="$final_path/config/local.config.php"
|
||||
|
||||
ynh_store_file_checksum --file="$final_path/config/local.config.php"
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# SETUP CRON JOB
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
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"
|
||||
cp "../conf/poller-cron" "/etc/cron.d/$app"
|
||||
fi
|
||||
|
||||
# Run composer
|
||||
(cd $final_path && sudo php bin/composer.phar install)
|
||||
#=================================================
|
||||
# INSTALL THE APPLICATION
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_install_composer
|
||||
(cd $final_path && sudo bin/console config system addon ldapauth)
|
||||
fi
|
||||
|
||||
# Set app as owner
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
|
@ -203,4 +213,3 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||
|
||||
|
|
48
scripts/ynh_composer__2
Normal file
48
scripts/ynh_composer__2
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Execute a command with Composer
|
||||
#
|
||||
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -c, --commands - Commands to execute.
|
||||
ynh_composer_exec () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=vwc
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||
local phpversion
|
||||
local workdir
|
||||
local commands
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
|
||||
COMPOSER_HOME="$workdir/.composer" \
|
||||
php${phpversion} "$workdir/composer.phar" $commands \
|
||||
-d "$workdir" --quiet --no-interaction
|
||||
}
|
||||
|
||||
# Install and initialize Composer in the given directory
|
||||
#
|
||||
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
ynh_install_composer () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=vw
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
|
||||
local phpversion
|
||||
local workdir
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
| COMPOSER_HOME="$workdir/.composer" \
|
||||
php${phpversion} -- --quiet --install-dir="$workdir" \
|
||||
|| ynh_die "Unable to install Composer."
|
||||
|
||||
# update dependencies to create composer.lock
|
||||
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|
||||
|| ynh_die "Unable to update core dependencies with Composer."
|
||||
}
|
Loading…
Add table
Reference in a new issue