#!/bin/bash # Here are some advices about the packaging: # .respect order operation from https://github.com/YunoHost/example_ynh/blob/master/scripts/install (this is just style) # .every sudo can be removed, they are not usefull anymore (everything is run as root) # .use this helper for nginx: ynh_add_nginx_config (doc: https://helpers.yunohost.org/), it will requiere to rename document_root in final_path # .use this helper for debian packages: ynh_install_app_dependencies (doc: https://helpers.yunohost.org/), mostly to make sure you dont remove usefull package for other application (or the other way around) # .use PIP, here is an example https://github.com/YunoHost-Apps/weblate_ynh/blob/master/scripts/install#L196 #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= 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 app=$YNH_APP_INSTANCE_NAME #force location to be / or /foo location=${path:-/} # Check domain/path availability sudo yunohost app checkurl $domain$path -a $app \ || ynh_die "The path ${domain}${path} is not available for app installation." # 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}${path}@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