mirror of
https://github.com/YunoHost-Apps/baikal_ynh.git
synced 2024-09-03 18:16:11 +02:00
69 lines
2 KiB
Bash
69 lines
2 KiB
Bash
#!/bin/bash
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
set -eu
|
|
|
|
# Retrieve app id
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
# Load common variables and helpers
|
|
. ./_common.sh
|
|
|
|
# Retrieve app settings
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
path=${path%/}
|
|
|
|
# Set app specific variables
|
|
dbname=$app
|
|
dbuser=$app
|
|
|
|
# Check destination directory
|
|
DESTDIR="/var/www/$app"
|
|
[[ ! -d $DESTDIR ]] && ynh_die \
|
|
"The destination directory '$DESTDIR' does not exist.\
|
|
The app is not correctly installed, you should remove it first."
|
|
|
|
# Create tmp directory and fetch new app inside
|
|
TMPDIR=$(ynh_mkdir_tmp)
|
|
extract_baikal "$TMPDIR"
|
|
|
|
# Get Specific folder from current installation
|
|
# FIXME: config.php and config.system.php are not updated with possible
|
|
# new or changed configurations
|
|
rm -rf "${TMPDIR}/Specific"
|
|
sudo cp -r "${DESTDIR}/Specific" "$TMPDIR"
|
|
sudo chown -hR "${USER}" "${TMPDIR}/Specific"
|
|
|
|
# Run Baikal upgrade from tmp directory
|
|
cp -r ../sources/bin "$TMPDIR"
|
|
php "${TMPDIR}/bin/upgrade.sh" \
|
|
|| echo "The Baïkal upgrade failed, you should try to go to " \
|
|
"https://${domain}${path}/admin/install"
|
|
|
|
# Install new app and set permissions
|
|
sudo rm -rf "$DESTDIR"
|
|
sudo mv "$TMPDIR" "$DESTDIR"
|
|
sudo chown -R www-data: "$DESTDIR"
|
|
|
|
# Copy and set nginx configuration
|
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
sed -i "s@{PATH}@${path}@g" ../conf/nginx.conf
|
|
sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf
|
|
sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf
|
|
sed -i "s@{POOLNAME}@${app}@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
|
|
|
# Copy and set php-fpm configuration
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
sed -i "s@{POOLNAME}@${app}@g" ../conf/php-fpm.conf
|
|
sed -i "s@{DESTDIR}@${DESTDIR}/@g" ../conf/php-fpm.conf
|
|
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
|
|
|
# Set SSOwat rules
|
|
ynh_app_setting_set "$app" skipped_uris "/"
|
|
ynh_app_setting_set "$app" protected_uris "/admin/"
|
|
|
|
# Reload services
|
|
sudo service php5-fpm restart || true
|
|
sudo service nginx reload || true
|