#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers source ./_extrahelpers # Really needed ? #================================================= # LOAD SETTINGS #================================================= app=$YNH_APP_INSTANCE_NAME version=$(cat ../sources/version) # Exit if an error occurs during the execution of the script ynh_abort_if_errors # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) path=$(ynh_app_setting_get "$app" path) old_version=$(ynh_app_setting_get "$app" version) # Copy source files src_path=/var/www/$app # Download, unzip and copy source sudo wget -q https://github.com/Dolibarr/dolibarr/archive/${version}.zip -O dolibarr-${version}.zip sudo unzip -qq dolibarr-${version}.zip sudo cp -a dolibarr-${version}/. $src_path # Modify Nginx configuration file and copy it to Nginx conf directory nginx_conf=../conf/nginx.conf sed -i "s@YNH_WWW_PATH@${path%/}@g" $nginx_conf sed -i "s@YNH_WWW_ALIAS@$src_path/htdocs/@g" $nginx_conf sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # PHP sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf sed -i "s@YNH_WWW_ALIAS@$src_path@g" ../conf/php-fpm.conf finalphpconf=/etc/php5/fpm/pool.d/$app.conf sudo cp ../conf/php-fpm.conf $finalphpconf sudo chown root: $finalphpconf sudo chmod 644 $finalphpconf sudo service php5-fpm reload # Set permissions to app files sudo chmod -R 755 $src_path sudo chown -R www-data: $src_path # Reload nginx service sudo service nginx reload # Upgrade # Disable SSO ynh_app_setting_set "$app" unprotected_uris "/" sudo yunohost app ssowatconf # Remove the lock if it exists lock=$src_path/documents/install.lock [[ -f $lock ]] && sudo rm $lock # Upgrade with CURL ynh_local_curl "/install/upgrade.php" \ "action=upgrade" \ "versionfrom=$old_version" \ "versionto=$version" ynh_local_curl "/install/upgrade2.php" \ "versionfrom=$old_version" \ "versionto=$version" \ "testpost=ok" \ "action=upgrade" ynh_local_curl "/install/step5.php" \ "versionfrom=$old_version" \ "versionto=$version" \ "testpost=ok" \ "action=upgrade" # Recreate the lock sudo touch $lock sudo chmod 444 $lock sudo chown www-data: $lock # Re-enable SSO ynh_app_setting_delete $app unprotected_uris sudo yunohost app ssowatconf # Store the new version ynh_app_setting_set $app version $version