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

Merge pull request #33 from asbiin/version-2.14.0

Updated to version 2.14.0 and switch to php7.2
This commit is contained in:
anmol26s 2019-06-28 00:43:21 +05:30 committed by GitHub
commit d086eb8fa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 503 additions and 147 deletions

View file

@ -4,7 +4,7 @@
[![Installer Monica with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=monica)
Shipped version: **2.12.0**
Shipped version: **2.14.0**
<p align="center"><img src="37693034-5783b3d6-2c93-11e8-80ea-bd78438dcd51.png"></p>
<h1 align="center">Personal Relationship Manager</h1>
@ -18,11 +18,11 @@ Shipped version: **2.12.0**
Monica is an open-source web application to organize the interactions with your loved ones. I call it a PRM, or Personal Relationship Management. Think of it as a [CRM](https://en.wikipedia.org/wiki/Customer_relationship_management) (a popular tool used by sales teams in the corporate world) for your friends or family.
## Install
##### This app will install PHP7.1
##### This app will install PHP7.2
```
sudo yunohost app install https://github.com/YunoHost-Apps/monica_ynh
```
**First User Registraion:** Visit the app **domain** after the installtion is complete to register as **first user**. After the first user is registerd the registration will be **locked**. You can open the register for all by chaning the value **APP_DISABLE_SIGNUP** to **false** in **.env**. There is **no admin interface** in the Monica app currently.
**First User Registration:** Visit the app **domain** after the installation is complete to register as **first user**. After the first user is registered the registration will be **locked**. You can open the register for all by changing the value **APP_DISABLE_SIGNUP** to **false** in **.env**. There is **no admin interface** in the Monica app currently.
## Update
```
@ -38,10 +38,7 @@ Monica is an open-source web application to organize the interactions with your
* [x] make root domain redirect to index.php
* [x] Chang URL (Need testing,backup before trying this)
* [ ] LDAP/SSO support
* [ ] Make monica installable into subdirectory (eg. https://example.com/monica/)
* Currently it is only possible to install monica into the root of a domain (eg. https://example.com/)
* This is due to a limitation in monica, not yunohost!
* See [here](https://github.com/monicahq/monica/issues/139) for the current progress.
* [x] Make monica installable into subdirectory (eg. https://example.com/monica/)
## License

View file

@ -55,7 +55,6 @@ MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=monica@yunodomain
MAIL_FROM_NAME="Monica"
APP_EMAIL_NEW_USERS_NOTIFICATION=yunomail
APP_EMAIL_NEW_USERS_NOTIFICATION=monica@yunodomain
# Default locale used in the application.

View file

@ -1,6 +1,6 @@
SOURCE_URL=https://github.com/monicahq/monica/archive/v2.12.0.zip
SOURCE_SUM=983c9c1b9866a1a276ac8793e3017c09e0b61a1cbcb73b300d6963ca98fa1a57
SOURCE_URL=https://github.com/monicahq/monica/archive/v2.14.0.zip
SOURCE_SUM=796ff50a2b7778c58835da1aa07fd8b5626faee50471cfd9b475325821aea725
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=v2.10.2.zip
SOURCE_FILENAME=v2.14.0.zip

View file

@ -8,7 +8,7 @@ location ^~ __PATH__ {
}
location ~ \.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php7.1-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php7.2-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
@ -18,5 +18,14 @@ location ^~ __PATH__ {
}
location @monica {
rewrite /(.*)$ /index.php?/$1 last;
# Redirect .well-known urls (https://en.wikipedia.org/wiki/List_of_/.well-known/_services_offered_by_webservers)
rewrite .well-known/carddav __PATH__/dav/ permanent;
rewrite .well-known/caldav __PATH__/dav/ permanent;
rewrite .well-known/security.txt$ __PATH__/security.txt permanent;
# Old carddav url
rewrite carddav/(.*) __PATH__/dav/$1 permanent;
# rewrite all to index.php
rewrite ^(.*)$ __PATH__/index.php/$1 last;
}

View file

@ -24,7 +24,7 @@
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php7.1-fpm-__NAMETOCHANGE__.sock
listen = /var/run/php/php7.2-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)

View file

@ -7,7 +7,7 @@
},
"url": "https://monica.com",
"license": "GPL-3.0",
"version": "2.12.0",
"version": "2.14.0",
"maintainer": {
"name": "Sebastian Gumprich",
"email": "yunohost@gumpri.ch",
@ -19,7 +19,6 @@
"multi_instance": true,
"services": [
"nginx",
"php7.1",
"mysql"
],
"arguments": {
@ -33,6 +32,16 @@
},
"example": "monica.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Monica",
"fr": "Choisissez un chemin pour Monica"
},
"example": "/monica",
"default": "/monica"
},
{
"name": "admin",
"type": "user",

View file

@ -1,5 +1,9 @@
#!/bin/bash
source helpers/ynh_add_extra_apt_repos__3
source helpers/ynh_install_php__3
source helpers/ynh_composer__2
# =============================================================================
# YUNOHOST 2.7 FORTHCOMING HELPERS
# =============================================================================
@ -7,115 +11,29 @@
# Create a dedicated php-fpm config
#
# usage: ynh_add_fpm_config
ynh_add_fpm7.1_config () {
# Configure PHP-FPM 7.1 by default
local fpm_config_dir="/etc/php/7.1/fpm"
local fpm_service="php7.1-fpm"
ynh_app_setting_set $app fpm_config_dir "$fpm_config_dir"
ynh_app_setting_set $app fpm_service "$fpm_service"
finalphpconf="$fpm_config_dir/pool.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalphpconf"
sudo cp ../conf/php-fpm.conf "$finalphpconf"
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
ynh_replace_string "__USER__" "$app" "$finalphpconf"
sudo chown root: "$finalphpconf"
ynh_store_file_checksum "$finalphpconf"
if [ -e "../conf/php-fpm.ini" ]
then
finalphpini="$fpm_config_dir/conf.d/20-$app.ini"
ynh_backup_if_checksum_is_different "$finalphpini"
sudo cp ../conf/php-fpm.ini "$finalphpini"
sudo chown root: "$finalphpini"
ynh_store_file_checksum "$finalphpini"
fi
sudo systemctl reload $fpm_service
}
# Remove the dedicated php-fpm config
#
# usage: ynh_remove_fpm7.1_config
ynh_remove_fpm7.1_config () {
local fpm_config_dir=$(ynh_app_setting_get $app fpm_config_dir)
local fpm_service=$(ynh_app_setting_get $app fpm_service)
ynh_secure_remove "$fpm_config_dir/pool.d/$app.conf"
ynh_secure_remove "$fpm_config_dir/conf.d/20-$app.ini" 2>&1
sudo systemctl reload $fpm_service
}
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval $@
else
# use sudo twice to be root and be allowed to use another user
sudo sudo -u "$USER" $@
fi
ynh_add_fpm7.2_config () {
ynh_add_fpm_config --phpversion="7.2"
}
#
# Composer helpers
#
# Execute a composer command from a given directory
# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
exec_composer() {
local WORKDIR=$1
shift 1
COMPOSER_HOME="${WORKDIR}/.composer" \
sudo /usr/bin/php7.1 "${WORKDIR}/composer.phar" $@ \
-d "${WORKDIR}" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
# usage: init_composer DESTDIR [AS_USER]
# usage: init_composer
init_composer() {
local DESTDIR=$1
local AS_USER=${2:-admin}
# install composer
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="${DESTDIR}/.composer" \
sudo /usr/bin/php7.1 -- --quiet --install-dir="$DESTDIR" \
|| ynh_die "Unable to install Composer"
ynh_install_composer --phpversion="7.2" --workdir="$final_path"
# update dependencies to create composer.lock
exec_composer "$DESTDIR" install --quiet --no-dev --prefer-dist \
ynh_composer_exec --phpversion="7.2" --workdir="$final_path" --commands="install --no-dev --prefer-dist" \
|| ynh_die "Unable to update monica core dependencies"
}
sudo_path () {
sudo env "PATH=$PATH" $@
}
#
# PHP7 helpers
#
pkg_dependencies="php7.2-cli php7.2-json php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-intl php7.2-xml php7.2-curl php7.2-gd php7.2-gmp"
ynh_install_php7 () {
ynh_package_update
ynh_package_install apt-transport-https --no-install-recommends
wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list
ynh_package_update
ynh_install_app_dependencies php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-bcmath php7.1-intl php7.1-simplexml php7.1-dom php7.1-curl php7.1-gd
sudo update-alternatives --install /usr/bin/php php /usr/bin/php5 70
}
ynh_remove_php7 () {
sudo rm -f /etc/apt/sources.list.d/php7.list
sudo apt-key del 4096R/89DF5277
sudo apt-key del 2048R/11A06851
ynh_remove_app_dependencies php7.1 php7.1-zip php7.1-fpm php7.1-mysql php7.1-xml php7.1-intl php7.1-mbstring php7.1-gd php7.1-curl php7.1-bcmath
ynh_install_php7.2 () {
ynh_install_php --phpversion="7.2" --package="$pkg_dependencies"
}

View file

@ -56,7 +56,7 @@ ynh_mysql_dump_db "$db_name" > db.sql
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup "/etc/php/7.1/fpm/pool.d/$app.conf"
ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE CRON FILE

View file

@ -17,7 +17,7 @@ old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
@ -60,13 +60,11 @@ if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Replace locations starting with old_path
# Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path"
# Replace path in "return" directives
ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path"
# Calculate and store the nginx config file checksum
ynh_store_file_checksum "$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
fi
# Change the domain for nginx
@ -83,7 +81,7 @@ fi
# SPECIFIC MODIFICATIONS
#=================================================
# Run monica update
cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force
cd $final_path && sudo /usr/bin/php7.2 artisan monica:update --force
#=================================================
# GENERIC FINALISATION

View file

@ -0,0 +1,295 @@
#!/bin/bash
# See https://github.com/YunoHost-Apps/Experimental_helpers/blob/222a89d3d32f656e41d234cf79021a8e86371b21/ynh_add_extra_apt_repos/ynh_add_extra_apt_repos__3
# Pin a repository.
#
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
# | arg: -i, --pin - Filter for the pin.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
#
ynh_pin_repo () {
# Declare an array to define the options of this helper.
local legacy_args=pirna
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
local package
local pin
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
package="${package:-*}"
priority=${priority:-50}
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ]
then
append="tee -a"
else
append="tee"
fi
mkdir -p "/etc/apt/preferences.d"
echo "Package: $package
Pin: $pin
Pin-Priority: $priority" \
| $append "/etc/apt/preferences.d/$name"
}
# Add a repository.
#
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
# | arg: -u, --uri - Uri of the repository.
# | arg: -s, --suite - Suite of the repository.
# | arg: -c, --component - Component of the repository.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
# uri suite component
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
#
ynh_add_repo () {
# Declare an array to define the options of this helper.
local legacy_args=uscna
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
local uri
local suite
local component
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ]
then
append="tee -a"
else
append="tee"
fi
mkdir -p "/etc/apt/sources.list.d"
# Add the new repo in sources.list.d
echo "deb $uri $suite $component" \
| $append "/etc/apt/sources.list.d/$name.list"
}
# Add an extra repository correctly, pin it and get the key.
#
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -k, --key - url to get the public key.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
ynh_install_extra_repo () {
# Declare an array to define the options of this helper.
local legacy_args=rkpna
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
local repo
local key
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
append=${append:-0}
key=${key:-0}
priority=${priority:-}
if [ $append -eq 1 ]
then
append="--append"
wget_append="tee -a"
else
append=""
wget_append="tee"
fi
# Split the repository into uri, suite and components.
# Remove "deb " at the beginning of the repo.
repo="${repo#deb }"
# Get the uri
local uri="$(echo "$repo" | awk '{ print $1 }')"
# Get the suite
local suite="$(echo "$repo" | awk '{ print $2 }')"
# Get the components
local component="${repo##$uri $suite }"
# Add the repository into sources.list.d
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
# Pin the new repo with the default priority, so it won't be used for upgrades.
# Build $pin from the uri without http and any sub path
local pin="${uri#*://}"
pin="${pin%%/*}"
# Set a priority only if asked
if [ -n "$priority" ]
then
priority="--priority=$priority"
fi
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
# Get the public key for the repo
if [ -n "$key" ]
then
mkdir -p "/etc/apt/trusted.gpg.d"
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
fi
# Update the list of package with the new repo
ynh_package_update
}
# Remove an extra repository and the assiociated configuration.
#
# usage: ynh_remove_extra_repo [--name=name]
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_remove_extra_repo () {
# Declare an array to define the options of this helper.
local legacy_args=n
declare -Ar args_array=( [n]=name= )
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
ynh_secure_remove "/etc/apt/preferences.d/$name"
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
# Update the list of package to exclude the old repo
ynh_package_update
}
# Install packages from an extra repository properly.
#
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -p, --package - The packages to install from this extra repository
# | arg: -k, --key - url to get the public key.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_install_extra_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=rpkn
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
local repo
local package
local key
local name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
name="${name:-$app}"
key=${key:-0}
# Set a key only if asked
if [ -n "$key" ]
then
key="--key=$key"
fi
# Add an extra repository for those packages
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
# Install requested dependencies from this extra repository.
ynh_add_app_dependencies --package="$package"
# Remove this extra repository after packages are installed
ynh_remove_extra_repo --name=$app
}
#=================================================
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
# Define and install dependencies with a equivs control file
# This helper can/should only be called once per app
#
# usage: ynh_install_app_dependencies dep [dep [...]]
# | arg: dep - the package name to install in dependence
# You can give a choice between some package with this syntax : "dep1|dep2"
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
#
# Requires YunoHost version 2.6.4 or higher.
ynh_install_app_dependencies () {
local dependencies=$@
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
dependencies=${dependencies//|/ | }
local manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
if [ ${#version} -eq 0 ]; then
version="1.0"
fi
local dep_app=${app//_/-} # Replace all '_' by '-'
# Handle specific versions
if [[ "$dependencies" =~ [\<=\>] ]]
then
# Replace version specifications by relationships syntax
# https://www.debian.org/doc/debian-policy/ch-relationships.html
# Sed clarification
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
# [\<=\>] matches < = or >
# \+ matches one or more occurence of the previous characters, for >= or >>.
# [^,]\+ matches all characters except ','
# Ex: package>=1.0 will be replaced by package (>= 1.0)
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
fi
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies}
Architecture: all
Description: Fake package for $app (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
rm /tmp/${dep_app}-ynh-deps.control
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
}
ynh_add_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=pr
declare -Ar args_array=( [p]=package= [r]=replace)
local package
local replace
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
replace=${replace:-0}
local current_dependencies=""
if [ $replace -eq 0 ]
then
local dep_app=${app//_/-} # Replace all '_' by '-'
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
then
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
fi
current_dependencies=${current_dependencies// | /|}
fi
ynh_install_app_dependencies "${current_dependencies}${package}"
}

View 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."
}

View file

@ -0,0 +1,78 @@
#!/bin/bash
# See https://raw.githubusercontent.com/YunoHost-Apps/Experimental_helpers/master/ynh_install_php/ynh_install_php__3
# Install another version of php.
#
# usage: ynh_install_php --phpversion=phpversion [--package=packages]
# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3
# | arg: -p, --package - Additionnal php packages to install
ynh_install_php () {
# Declare an array to define the options of this helper.
local legacy_args=vp
declare -Ar args_array=( [v]=phpversion= [p]=package= )
local phpversion
local package
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
package=${package:-}
# Store php_version into the config of this app
ynh_app_setting_set $app php_version $phpversion
if [ "$phpversion" == "7.0" ]
then
ynh_die "Do not use ynh_install_php to install php7.0"
fi
# Store the ID of this app and the version of php requested for it
echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version"
# Add an extra repository for those packages
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version
# Install requested dependencies from this extra repository.
# Install php-fpm first, otherwise php will install apache as a dependency.
ynh_add_app_dependencies --package="php${phpversion}-fpm"
ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
# Set php7.0 back as the default version for php-cli.
update-alternatives --set php /usr/bin/php7.0
# Remove this extra repository after packages are installed
ynh_remove_extra_repo --name=extra_php_version
# Advertise service in admin panel
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
}
ynh_remove_php () {
# Get the version of php used by this app
local phpversion=$(ynh_app_setting_get $app php_version)
if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ]
then
if [ "$phpversion" == "7.0" ]
then
ynh_print_err "Do not use ynh_remove_php to install php7.0"
fi
return 0
fi
# Remove the line for this app
sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version"
# If no other app uses this version of php, remove it.
if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version"
then
# Purge php dependences for this version.
ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common"
# Remove the service from the admin panel
yunohost service remove php${phpversion}-fpm
fi
# If no other app uses alternate php versions, remove the extra repo for php
if [ ! -s "/etc/php/ynh_app_version" ]
then
ynh_secure_remove /etc/php/ynh_app_version
fi
}

View file

@ -21,7 +21,7 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
@ -71,7 +71,7 @@ ynh_app_setting_set $app random_key $random_key
# INSTALL DEPENDENCIES
#=================================================
ynh_install_php7
ynh_install_php7.2
#=================================================
# CREATE A MYSQL DATABASE
@ -89,7 +89,7 @@ ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
init_composer $final_path
init_composer
#=================================================
# NGINX CONFIGURATION
@ -106,11 +106,11 @@ ynh_add_nginx_config
ynh_system_user_create $app
#=================================================
# PHP-FPM 7.1 CONFIGURATION
# PHP-FPM 7.2 CONFIGURATION
#=================================================
# Create a dedicated php-fpm7.1 config
ynh_add_fpm7.1_config
# Create a dedicated php-fpm7.2 config
ynh_add_fpm7.2_config
#=================================================
# SPECIFIC SETUP
@ -134,9 +134,9 @@ ynh_replace_string "language" "$language" "$final_path/.env"
# setup application config
( cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force )
( cd $final_path && sudo /usr/bin/php7.1 artisan passport:install )
( cd $final_path && sudo /usr/bin/php7.1 artisan passport:client --password -n > key.txt )
( cd $final_path && sudo /usr/bin/php7.2 artisan monica:update --force )
( cd $final_path && sudo /usr/bin/php7.2 artisan passport:keys )
( cd $final_path && sudo /usr/bin/php7.2 artisan passport:client --password -n > key.txt )
mobile_id=$( cd $final_path && tail -2 key.txt | head -1 | cut -c 12- )
mobile_key=$( cd $final_path && tail -1 key.txt | cut -c 16- )
ynh_replace_string "__IDENTITY__" "$mobile_id" "$final_path/.env"
@ -147,7 +147,7 @@ ynh_app_setting_set $app mobile_key $mobile_key
# create a cronjob to run the scheduler
echo "* * * * * -u $app /usr/bin/php7.1 $final_path/artisan schedule:run" > /tmp/cron$app
echo "* * * * * -u $app /usr/bin/php7.2 $final_path/artisan schedule:run" > /tmp/cron$app
sudo mv /tmp/cron$app /etc/cron.d/$app
#=================================================
@ -184,8 +184,8 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
service php7.1-fpm start
systemctl reload php7.1-fpm
service php7.2-fpm start
systemctl reload php7.2-fpm
systemctl reload nginx
# Set default php to php5 or php7.0
if [ "$(lsb_release --codename --short)" == "jessie" ]; then

View file

@ -51,15 +51,20 @@ ynh_secure_remove "$final_path"
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM 7.1 CONFIGURATION
# REMOVE PHP-FPM 7.2 CONFIGURATION
#=================================================
# Remove the dedicated php-fpm7.1 config
ynh_remove_fpm7.1_config
# Remove the dedicated php-fpm7.2 config
ynh_remove_fpm_config
#=================================================
# SPECIFIC REMOVE
#=================================================
# Remove php packages
ynh_remove_php
#=================================================
# REMOVE THE CRON FILE
#=================================================

View file

@ -48,7 +48,7 @@ test ! -d $final_path \
#=================================================
# Define and install dependencies
ynh_install_php7
ynh_install_php7.2
#=================================================
# RESTORE THE NGINX CONFIGURATION
@ -84,7 +84,7 @@ ynh_system_user_create $app
#=================================================
# Run migration
cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force
cd $final_path && sudo /usr/bin/php7.2 artisan monica:update --force
#=================================================
@ -98,7 +98,7 @@ chown -R $app: $final_path
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file "/etc/php/7.1/fpm/pool.d/$app.conf"
ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE CRON FILE
@ -112,7 +112,7 @@ ynh_restore_file "/etc/cron.d/$app"
# RELOAD NGINX AND PHP-FPM
#=================================================
systemctl reload php7.1-fpm
systemctl reload php7.2-fpm
systemctl reload nginx
# Set default php to php5 or php7.0
if [ "$(lsb_release --codename --short)" == "jessie" ]; then

View file

@ -72,7 +72,7 @@ ynh_setup_source "$final_path"
#=================================================
# INSTALL COMPOSER
#=================================================
init_composer $final_path
init_composer
#=================================================
# NGINX CONFIGURATION
@ -94,14 +94,14 @@ ynh_system_user_create $app
#=================================================
# install new dependencies
ynh_install_app_dependencies php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-bcmath php7.1-intl php7.1-simplexml php7.1-dom php7.1-curl php7.1-gd
ynh_update_php_pkg
#=================================================
# PHP-FPM 7.1 CONFIGURATION
# PHP-FPM 7.2 CONFIGURATION
#=================================================
# Create a dedicated php-fpm7.1 config
ynh_add_fpm7.1_config
# Create a dedicated php-fpm7.2 config
ynh_add_fpm7.2_config
# setup application config
# Get admin email
@ -121,7 +121,7 @@ ynh_replace_string "__DOMAIN__" "$domain" "$final_path/.env"
# Run monica update
cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force
cd $final_path && sudo /usr/bin/php7.2 artisan monica:update --force
if [ -f $final_path/storage/oauth-private.key ]; then
mobile_id=$(ynh_app_setting_get $app mobile_id)
@ -129,8 +129,8 @@ if [ -f $final_path/storage/oauth-private.key ]; then
ynh_replace_string "__IDENTITY__" "$mobile_id" "$final_path/.env"
ynh_replace_string "__KEY__" "$mobile_key" "$final_path/.env"
else
( cd $final_path && sudo /usr/bin/php7.1 artisan passport:install )
( cd $final_path && sudo /usr/bin/php7.1 artisan passport:client --password -n > key.txt )
( cd $final_path && sudo /usr/bin/php7.2 artisan passport:keys )
( cd $final_path && sudo /usr/bin/php7.2 artisan passport:client --password -n > key.txt )
mobile_id=$( cd $final_path && tail -2 key.txt | head -1 | cut -c 12- )
mobile_key=$( cd $final_path && tail -1 key.txt | cut -c 16- )
ynh_replace_string "__IDENTITY__" "$mobile_id" "$final_path/.env"