1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pelican_ynh.git synced 2024-09-03 19:46:35 +02:00
pelican_ynh/scripts/upgrade
2017-08-13 03:00:21 +02:00

55 lines
1.5 KiB
Bash

#!/bin/bash
# Source app helpers and functions
source /usr/share/yunohost/helpers
# Exit on command errors and treat unset variables as an error
set -eu
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
is_public=$(ynh_app_setting_get "$app" is_public)
author=$(ynh_app_setting_get "$app" author)
title=$(ynh_app_setting_get "$app" title)
# is_public is now a boolean field
if [ "$is_public" = "Yes" ];
then
is_public=1
fi
#force location to be / or /foo
location=${path:-/}
# Document root
document_root=/var/www/$app
sudo mkdir -p $document_root
# Nginx configuration
sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx.conf
sed -i "s@YNH_DOCUMENT_ROOT@$document_root/output/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Store settings from manifest
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app author $author
# Install python dependencies
sudo apt-get install -y python-pip python-virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev
# Upgrade pelican
pip install --upgrade pelican markdown
# Set permissions
sudo chmod 775 -R $document_root
sudo chown -hR www-data:www-data $document_root
# Make app public if necessary
[[ $is_public -eq 1 ]] \
&& ynh_app_setting_set "$app" unprotected_uris "/"
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload