2016-08-21 01:03:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-04-24 16:04:55 +02:00
|
|
|
version=$(cat ../sources/version)
|
|
|
|
source='https://sourceforge.net/projects/humhub/files/'
|
2016-08-21 01:03:46 +02:00
|
|
|
|
|
|
|
# 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)
|
2017-04-23 17:29:55 +02:00
|
|
|
dbuser=$app
|
|
|
|
dbname=$app
|
|
|
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
2017-04-24 16:04:55 +02:00
|
|
|
src_path=/var/www/$app
|
2017-04-23 17:29:55 +02:00
|
|
|
|
|
|
|
# Correct path: puts a / at the start and nothing at the end
|
|
|
|
if [ "${path:0:1}" != "/" ]; then
|
|
|
|
path="/$path"
|
|
|
|
fi
|
|
|
|
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
|
|
|
|
path="${path:0:${#path}-1}"
|
|
|
|
fi
|
2016-08-21 01:03:46 +02:00
|
|
|
|
|
|
|
# Copy source files
|
2017-04-24 16:04:55 +02:00
|
|
|
sudo mv "$src_path" "$src_path.old"
|
2016-08-21 01:03:46 +02:00
|
|
|
sudo mkdir -p $src_path
|
2017-04-24 16:04:55 +02:00
|
|
|
sudo wget -q "${source}humhub-${version}.zip/download" -O humhub-${version}.zip
|
|
|
|
sudo unzip -qq humhub-${version}.zip
|
2016-08-21 01:03:46 +02:00
|
|
|
sudo cp -a humhub-$version/. $src_path
|
|
|
|
|
2017-04-24 16:04:55 +02:00
|
|
|
# Restore files
|
|
|
|
sudo cp -a "$src_path.old/uploads/." "$src_path/uploads/."
|
|
|
|
sudo cp -a "$src_path.old/protected/runtime" "$src_path/protected/runtime"
|
|
|
|
sudo cp -a "$src_path.old/protected/config/." "$src_path/protected/config/"
|
|
|
|
sudo cp -a "$src_path.old/protected/modules/." "$src_path/protected/modules/"
|
|
|
|
sudo cp -a "$src_path.old/themes/." "$src_path/themes/"
|
2017-04-23 17:29:55 +02:00
|
|
|
|
|
|
|
# Hotfixes
|
|
|
|
# Fix LDAP email. See https://github.com/humhub/humhub/issues/1949
|
|
|
|
sudo cp -a ../sources/fix/AuthClientHelpers.php $src_path/protected/humhub/modules/user/authclient/AuthClientHelpers.php
|
|
|
|
# Fix to allow passwordless LDAP login
|
|
|
|
sudo cp -a ../sources/fix/ZendLdapClient.php $src_path/protected/humhub/modules/user/authclient/ZendLdapClient.php
|
2017-04-24 16:04:55 +02:00
|
|
|
sudo sed -i "s@defined('YII_DEBUG') or define('YII_DEBUG', true);@//defined('YII_DEBUG') or define('YII_DEBUG', true);@g" $src_path/index.php
|
|
|
|
sudo sed -i "s@defined('YII_ENV') or define('YII_ENV', 'dev');@//defined('YII_ENV') or define('YII_ENV', 'dev');@g" $src_path/index.php
|
2017-04-23 17:29:55 +02:00
|
|
|
|
2016-08-21 01:03:46 +02:00
|
|
|
# Set permissions to app files
|
2016-08-22 00:09:13 +02:00
|
|
|
sudo chown -R www-data: $src_path
|
2017-04-23 17:29:55 +02:00
|
|
|
|
2017-04-24 16:04:55 +02:00
|
|
|
# Upgrade
|
|
|
|
sudo sudo -u www-data php $src_path/protected/yii migrate/up --includeModuleMigrations=1 --interactive=0 > /dev/null 2>&1
|
|
|
|
|
|
|
|
# Upgrade cron
|
2016-08-22 00:02:33 +02:00
|
|
|
echo "30 * * * * $src_path/protected/yii cron hourly >/dev/null 2>&1" > cron
|
|
|
|
echo "00 18 * * * $src_path/protected/yii cron daily >/dev/null 2>&1" > cron
|
2016-08-21 01:03:46 +02:00
|
|
|
sudo mv cron /etc/cron.d/${app}
|
|
|
|
sudo chown root /etc/cron.d/${app}
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
nginx_conf=../conf/nginx.conf
|
2017-04-23 17:29:55 +02:00
|
|
|
sed -i "s@YNH_WWW_PATH@${path:-/}@g" $nginx_conf
|
2016-08-21 01:03:46 +02:00
|
|
|
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
2017-04-24 16:04:55 +02:00
|
|
|
sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
2016-08-21 01:03:46 +02:00
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
2017-04-24 16:04:55 +02:00
|
|
|
# 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
|
|
|
|
|
2016-08-21 01:03:46 +02:00
|
|
|
# Reload nginx service
|
2017-04-23 17:29:55 +02:00
|
|
|
sudo service php5-fpm reload
|
2016-08-21 01:03:46 +02:00
|
|
|
sudo service nginx reload
|
2017-04-24 16:04:55 +02:00
|
|
|
|
|
|
|
# Delete old source
|
|
|
|
sudo rm -rf "$src_path.old"
|