mirror of
https://github.com/YunoHost-Apps/pelican_ynh.git
synced 2024-09-03 19:46:35 +02:00
95 lines
2.7 KiB
Bash
95 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
admin=$(ynh_app_setting_get $app admin)
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
port=$(ynh_app_setting_get $app port)
|
|
author=$(ynh_app_setting_get $app author)
|
|
title=$(ynh_app_setting_get $app title)
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
|
|
# Fix is_public as a boolean value
|
|
if [ "$is_public" = "Yes" ]; then
|
|
ynh_app_setting_set $app is_public 1
|
|
is_public=1
|
|
elif [ "$is_public" = "No" ]; then
|
|
ynh_app_setting_set $app is_public 0
|
|
is_public=0
|
|
fi
|
|
|
|
# If final_path doesn't exist, create it
|
|
if [ -z $final_path ]; then
|
|
final_path=/var/www/$app
|
|
ynh_app_setting_set $app final_path $final_path
|
|
fi
|
|
|
|
#=================================================
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
#=================================================
|
|
|
|
# Backup the current version of the app
|
|
ynh_backup_before_upgrade
|
|
ynh_clean_setup () {
|
|
# restore it if the upgrade fails
|
|
ynh_restore_upgradebackup
|
|
}
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
|
|
#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
|