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/install
2017-08-09 18:46:12 +02:00

52 lines
1.5 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
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| exit 1
DESTDIR="/var/www/${app}"
[[ -d "$DESTDIR" ]] && ynh_die \
"The destination directory '${DESTDIR}' already exists.\
You should safely delete it before installing this app."
# 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
mkdir -p ${DESTDIR}
# cd ${DESTDIR}
# git clone https://github.com/YliesC/website.git .
# Configure Nginx
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
sed -i "s@{PATH}@${path}@g" ../conf/nginx.conf
sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf
sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf
sed -i "s@{POOLNAME}@${app}@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf "$nginx_conf"
sudo nginx -t && sudo service nginx reload
[[ $is_public -eq 1 ]] \
&& ynh_app_setting_set "$app" unprotected_uris "/"