commit 301fb8162ecb79bfdaaa7626f4f87419f1f55ad4 Author: Artus Date: Wed Jun 10 14:50:30 2020 +0200 first version diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..3b2ee28 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,3 @@ +location __PATH__/ { + alias __FINALPATH__/; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..ac21b6b --- /dev/null +++ b/manifest.json @@ -0,0 +1,65 @@ +{ + "name": "Zola website", + "id": "zola_website", + "packaging_format": 1, + "description": { + "en": "Zola project installer for Yunohost", + "fr": "Installateur de projet Zola pour Yunohost" + }, + "version": "1.0~ynh1", + "url": "https://git.landoftheunicorn.ovh/gogs/artus/zola_ynh", + "license": "GPL-3.0", + "maintainer": { + "name": "Arthur G", + "email": "artus@landoftheunicorn.ovh" + }, + "requirements": { + "yunohost": ">= 3.4" + }, + "multi_instance": false, + "services": [ + "nginx" + ], + "arguments": { + "install": [ + { + "name": "project_url", + "type": "string", + "ask": { + "en": "Url of your git project", + "fr": "Url vers le dépôt git de votre projet" + }, + "default": false + }, + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose domain for the website", + "fr": "Choississez le domain pour votre site" + }, + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose path for the website", + "fr": "Choississez le chemin pour votre site" + }, + "example": "/my-zola-website" + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Should it be public ?", + "fr": "Le site est-il public ?" + }, + "default": false + } + ] + + + } +} diff --git a/scripts/_zola b/scripts/_zola new file mode 100644 index 0000000..81c6e16 --- /dev/null +++ b/scripts/_zola @@ -0,0 +1,14 @@ +#!/bin/bash + +source /usr/share/yunohost/helpers + +function check_zola_is_present() { + if zola --version >/dev/null 2>&1; then + echo "true" + else + echo "false" + fi +} + +# function install_zola() {} + diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..f4d8596 --- /dev/null +++ b/scripts/install @@ -0,0 +1,72 @@ +#!/bin/bash + +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +# RETRIEVE ARGUMENTS +app=$YNH_APP_INSTANCE_NAME + +ynh_script_progression --message="Installing zola project : $app" + +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC +git_url=$YNH_APP_ARG_PROJECT_URL + + +# PRE-INSTALLATION CHECKS + +ynh_script_progression --message="Doing some checks" + +path_url=$(ynh_normalize_url_path $path_url) + +final_path=/var/www/$app +test ! -e "$final_path" || ynh_dir "This path already contains a folder" + +ynh_webpath_available $domain $path_url +ynh_webpath_register $app $domain $path_url + +# STORE SETTINGS + +ynh_script_progression --message="Going through with installation" + +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path_url +ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set $app git_url $git_url + +# SETUP SSOWAT + +if [ $is_public -eq 1 ]; then + ynh_permission_update --permission "main" --add visitors +fi + +# BUILD PROJECT + +ynh_script_progression --message="Build zola project" + +echo $(pwd) +( + tmp_dir=/tmp/$app + mkdir $tmp_dir && cd $tmp_dir + git clone $git_url source + cd source/ + zola build --base-url $path_url --output-dir $final_path + rm -r $tmp_dir +) +echo $(pwd) + +chmod 755 -R $final_path + +# CONFIGURE NGINX + +ynh_script_progression --message="Configure nginx" +ynh_add_nginx_config + + + + + + diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..a9ed35d --- /dev/null +++ b/scripts/remove @@ -0,0 +1,10 @@ +#!/bin/bash + +source /usr/share/yunohost/helpers + +app=$YNH_APP_INSTANCE_NAME +domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) + +ynh_secure_remove "$final_path" +ynh_remove_nginx_config