mirror of
https://github.com/YunoHost-Apps/h5ai_ynh.git
synced 2024-09-03 20:36:25 +02:00
Refactor / clean app
This commit is contained in:
parent
0598ba9ffe
commit
14a5db3e00
5 changed files with 131 additions and 73 deletions
6
conf/app.src
Normal file
6
conf/app.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://release.larsjung.de/h5ai/h5ai-0.29.0.zip
|
||||||
|
SOURCE_SUM=508324f14df32bfa79096b8c272dd644cbd8ff97d0dbc7dde2eec6ce7d95104e
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=zip
|
||||||
|
SOURCE_IN_SUBDIR=false
|
||||||
|
SOURCE_FILENAME=h5ai-0.29.0.zip
|
|
@ -1,23 +1,28 @@
|
||||||
location YNH_WWW_PATH {
|
location __PATH__ {
|
||||||
|
|
||||||
# Path to source
|
# Path to source
|
||||||
alias YNH_WWW_ALIAS ;
|
alias __FINALPATH__;
|
||||||
|
|
||||||
# Example PHP configuration
|
index index.php __PATH__/_h5ai/public/index.php;
|
||||||
index index.php /YNH_WWW_PATH/public/index.php;
|
|
||||||
|
|
||||||
try_files $uri $uri/ index.php;
|
try_files $uri.html $uri $uri/ =404;
|
||||||
location ~ [^/]\.php(/|$) {
|
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
|
||||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
|
|
||||||
fastcgi_index index.php;
|
client_max_body_size 10G;
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
if ($scheme = http) {
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ [^/]\.php(/|$) {
|
||||||
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
|
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"name": "H5AI",
|
"name": "H5AI",
|
||||||
"id": "h5ai",
|
"id": "h5ai",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
|
"version": "0.29.0~ynh1",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "A modern HTTP web server index for Nginx.",
|
"en": "A modern HTTP web server index for Nginx.",
|
||||||
"fr": "Un serveur moderne d'index pour Nginx."
|
"fr": "Un serveur moderne d'index pour Nginx."
|
||||||
|
@ -9,11 +10,11 @@
|
||||||
"url": "https://larsjung.de/h5ai/",
|
"url": "https://larsjung.de/h5ai/",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "inrepublica",
|
"name": "alexAubin",
|
||||||
"email": "duvalmickael@gmail.com"
|
"email": "alex.aubin@mailoo.org"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.4.0.6"
|
"yunohost": ">= 3.0.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -38,8 +39,17 @@
|
||||||
"en": "Choose a path for H5AI",
|
"en": "Choose a path for H5AI",
|
||||||
"fr": "Choisissez un chemin pour H5AI"
|
"fr": "Choisissez un chemin pour H5AI"
|
||||||
},
|
},
|
||||||
"example": "/_h5ai",
|
"example": "/documents",
|
||||||
"default": "/_h5ai"
|
"default": "/documents"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is_public",
|
||||||
|
"type": "boolean",
|
||||||
|
"ask": {
|
||||||
|
"en": "Is it a public application?",
|
||||||
|
"fr": "Est-ce une application publique ?"
|
||||||
|
},
|
||||||
|
"default": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
102
scripts/install
102
scripts/install
|
@ -1,54 +1,80 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Define app
|
source /usr/share/yunohost/helpers
|
||||||
app=h5ai
|
|
||||||
version=0.29.0
|
#=================================================
|
||||||
md5_source=dd44880a4353bec140ded7fdec0ac3ce
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# Source YunoHost helpers
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
. /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
# Save app settings
|
final_path=/var/www/$path_url # so e.g. if path_url is /docs, we put stuff in /var/www/docs
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
|
||||||
ynh_app_setting_set "$app" path "$path"
|
|
||||||
|
|
||||||
# Check domain/path availability
|
#=================================================
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
#=================================================
|
||||||
|
|
||||||
# Download source, check md5, untar, copy it
|
# Register (book) web path
|
||||||
sudo wget -q https://release.larsjung.de/h5ai/h5ai-$version.zip -O /tmp/h5ai.zip
|
ynh_webpath_register $app $domain $path_url
|
||||||
|
|
||||||
# Check md5
|
# Check final_path availability
|
||||||
md5_check=($(md5sum /tmp/h5ai.zip))
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
if [ $md5_source != $md5_check ]
|
|
||||||
then
|
|
||||||
ynh_die "the download is corrupted (md5 different)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# unzip and copy it
|
#=================================================
|
||||||
sudo unzip -o /tmp/h5ai.zip -d /tmp/
|
# STORE SETTINGS FROM MANIFEST
|
||||||
final_path=/var/www/$path
|
#=================================================
|
||||||
sudo mkdir -p $final_path
|
|
||||||
sudo cp -a /tmp/_h5ai/. $final_path
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
# For this app sources are in app subdirectory
|
||||||
|
ynh_setup_source "$final_path"
|
||||||
|
|
||||||
# Set permissions to phpsysinfo directory
|
# Set permissions to phpsysinfo directory
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: "$final_path"
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
#=================================================
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
# NGINX CONFIGURATION
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
#=================================================
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
# Create a dedicated nginx config
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_add_nginx_config
|
||||||
|
|
||||||
# Restart services
|
#=================================================
|
||||||
sudo service nginx reload
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Make app public if necessary or protect it
|
||||||
|
if [ $is_public -eq 1 ]
|
||||||
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
|
|
@ -1,20 +1,31 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Define app
|
#=================================================
|
||||||
app=h5ai
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source YunoHost helpers
|
source /usr/share/yunohost/helpers
|
||||||
. /usr/share/yunohost/helpers
|
|
||||||
|
|
||||||
# Retrieve app settings
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# LOAD SETTINGS
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
#=================================================
|
||||||
|
|
||||||
|
readonly app=$YNH_APP_INSTANCE_NAME
|
||||||
|
readonly domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
readonly final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE THE MAIN DIR OF THE APP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Remove sources
|
# Remove sources
|
||||||
sudo rm -rf /var/www/$path
|
ynh_secure_remove "$final_path"
|
||||||
|
|
||||||
# Remove configuration files
|
#=================================================
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
# REMOVE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Restart services
|
ynh_remove_nginx_config
|
||||||
sudo service nginx reload
|
systemctl reload nginx
|
||||||
|
|
Loading…
Add table
Reference in a new issue