#!/bin/bash set -u # Load common variables and helpers . ./_common.sh # Set app specific variables app=${!#} dbname=$app dbuser=$app # Retrieve arguments domain=$(ynh_app_setting_get "$app" domain) path=$(ynh_app_setting_get "$app" path) path=${path%/} # 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 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" #sudo chown root: $phpfpm_conf #sudo chmod 644 $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