2016-06-14 12:25:46 +02:00
|
|
|
#!/bin/bash
|
2014-11-12 22:42:09 +01:00
|
|
|
|
2016-06-15 23:09:45 +02:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
2016-06-15 23:39:38 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2016-06-18 11:36:30 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path=$(ynh_app_setting_get $app path)
|
|
|
|
admin=$(ynh_app_setting_get $app admin)
|
|
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
|
|
|
|
2014-11-12 22:42:09 +01:00
|
|
|
# Remove trailing "/" for next commands
|
|
|
|
path=${path%/}
|
|
|
|
|
|
|
|
# Copy source files
|
2016-06-15 20:17:31 +02:00
|
|
|
src_path=/var/www/$app
|
|
|
|
sudo mkdir -p $src_path
|
2016-06-15 21:33:07 +02:00
|
|
|
|
|
|
|
# Retrieve sources and install them
|
|
|
|
version=$(cat ../conf/upstream_version)
|
|
|
|
wget -nc --quiet https://github.com/pluxml/PluXml/archive/$version.zip -P /tmp
|
2016-06-29 01:27:44 +02:00
|
|
|
sudo unzip -oq /tmp/$version.zip -d /tmp
|
2016-06-15 21:33:07 +02:00
|
|
|
# Copy only core data and do not erase data
|
2016-06-18 15:31:53 +02:00
|
|
|
sudo cp -r /tmp/PluXml-$version/{config.php,core,feed.php,index.php,sitemap.php,update} $src_path
|
2014-11-12 22:42:09 +01:00
|
|
|
|
2016-06-15 20:17:31 +02:00
|
|
|
sudo chown -R root: $src_path
|
2016-06-15 22:03:26 +02:00
|
|
|
sudo chown -R www-data: $src_path/{data,plugins}
|
2016-06-29 00:11:40 +02:00
|
|
|
sudo find $src_path -type f -exec chmod 644 {} +
|
|
|
|
sudo find $src_path -type d -exec chmod 755 {} +
|
2014-11-17 14:14:56 +01:00
|
|
|
|
2014-11-12 22:42:09 +01:00
|
|
|
#configure nginx settings
|
2016-06-15 21:33:07 +02:00
|
|
|
folder_path=${path%/}
|
|
|
|
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
|
|
|
# If path is only / (without subfolder), add trailing slash to alias
|
|
|
|
alias_path=$src_path
|
2016-06-15 20:25:51 +02:00
|
|
|
nginx_conf="../conf/nginx.conf"
|
2016-06-15 21:33:07 +02:00
|
|
|
[ "$path" == '/' ] && alias_path=$alias_path'/'
|
|
|
|
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" $nginx_conf
|
|
|
|
sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" $nginx_conf
|
2016-06-15 20:25:51 +02:00
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2014-11-12 22:42:09 +01:00
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
2016-06-14 12:55:55 +02:00
|
|
|
if [ "$is_public" = "Yes" ]; then
|
2016-06-18 11:36:30 +02:00
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2014-11-12 22:42:09 +01:00
|
|
|
fi
|
|
|
|
|
2016-06-14 12:55:55 +02:00
|
|
|
# Reload nginx service
|
2014-11-12 22:42:09 +01:00
|
|
|
sudo service nginx reload
|