mirror of
https://github.com/YunoHost-Apps/pelican_ynh.git
synced 2024-09-03 19:46:35 +02:00
66 lines
1.9 KiB
Bash
66 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Source app helpers and functions
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
set -eu
|
|
|
|
# Retrieve arguments
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
path=$YNH_APP_ARG_PATH
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
author=$YNH_APP_ARG_AUTHOR
|
|
title=$YNH_APP_ARG_TITLE
|
|
|
|
#force location to be / or /foo
|
|
location=${path:-/}
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a $app \
|
|
|| (echo "Path not available: $domain$path" && exit 1)
|
|
|
|
# Document root
|
|
document_root=/var/www/$app
|
|
date=`date +%Y-%m-%d`
|
|
sudo mkdir -p $document_root
|
|
sudo sed -i "s@YNH_APP_URL@https://$domain@g" ../sources/pelicanconf.py
|
|
sudo sed -i "s@YNH_APP_AUTHOR@$author@g" ../sources/pelicanconf.py
|
|
sudo sed -i "s@YNH_APP_SITENAME@$title@g" ../sources/pelicanconf.py
|
|
sudo sed -i "s@YNH_APP_AUTHOR@$author@g" ../sources/content/first-article.md
|
|
sudo sed -i "s@YNH_APP_DATE@$date@g" ../sources/content/first-article.md
|
|
sudo cp -a ../sources/. $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
|
|
|
|
# Install pelican
|
|
pip install pelican markdown
|
|
|
|
# Generate the blog
|
|
cd $document_root
|
|
pelican -s pelicanconf.py -D
|
|
|
|
# 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
|