mirror of
https://github.com/YunoHost-Apps/dolibarr_ynh.git
synced 2024-09-03 18:35:53 +02:00
5cc9b9c96f
YunoHost users are now instantly logged in with HTTP auth For this feature to work, the app now needs to be private, all YNH users must be added in the database, and the admin user must be a YNH user. As a result, the manifest has changed: - Admin password is replaced by admin user - Public/Private is removed - Adding YNH users as Dolibarr users is removed: this is default now Unfortunately, upgrading the app will not change the previous behavior (ie no automatic login). For automatic login to work, you **must** reinstall the app The sync script does not delete users. Therefore the post_user_delete hook is not needed (and does not work anyway)
72 lines
2.4 KiB
Bash
Executable file
72 lines
2.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
set -eu
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
version=$(cat ../sources/version)
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# 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 unzip -qq /tmp/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
|
|
curl -kL -H "Host: $domain" "https://$domain$path/install/upgrade.php?action=upgrade&versionfrom=$old_version&versionto=$version" > /dev/null 2>&1
|
|
curl -kL -H "Host: $domain" -X POST "https://$domain$path/install/upgrade2.php?versionfrom=$old_version&versionto=$version" --data "testpost=ok&action=upgrade" > /dev/null 2>&1
|
|
curl -kL -H "Host: $domain" -X POST "https://$domain$path/install/step5.php?versionfrom=$old_version&versionto=$version" --data "testpost=ok&action=upgrade" > /dev/null 2>&1
|
|
|
|
# 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
|