Update to last example_ynh

This commit is contained in:
yalh76
2019-02-11 06:05:30 +01:00
parent e4df144713
commit a329419716
11 changed files with 183 additions and 87 deletions

View File

@@ -24,6 +24,7 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_print_info "Retrieve arguments from the manifest ..."
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
@@ -47,6 +48,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating arguments ..."
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
@@ -62,6 +64,7 @@ ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Store settings from manifest ..."
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
@@ -74,6 +77,7 @@ ynh_app_setting_set $app is_public $is_public
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_print_info "Configuring firewall ..."
### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port.
@@ -83,7 +87,7 @@ ynh_app_setting_set $app is_public $is_public
# Find a free port
port=$(ynh_find_port 8095)
# Open this port
#yunohost firewall allow --no-upnp TCP $port 2>&1
#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_app_setting_set $app port $port
#=================================================
@@ -107,6 +111,8 @@ ynh_install_app_dependencies redis-server postgresql postgresql-contrib yarn
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_print_info "Creating a postgresql database ..."
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
@@ -127,6 +133,7 @@ ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files ..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
@@ -144,6 +151,7 @@ popd
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx ..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
@@ -153,6 +161,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user ..."
# Create a system user
ynh_system_user_create "$app" "$final_path"
@@ -160,6 +169,7 @@ ynh_system_user_create "$app" "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm ..."
### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
@@ -199,6 +209,7 @@ popd
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Configuring a systemd service ..."
### `ynh_systemd_config` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd.
@@ -228,6 +239,7 @@ ynh_add_systemd_config
#chown -R $app: $final_path
# Set the app as temporarily public for curl call
ynh_print_info "Configuring ssowat ..."
#ynh_app_setting_set $app skipped_uris "/"
# Reload SSOwat config
#yunohost app ssowatconf
@@ -236,6 +248,7 @@ ynh_add_systemd_config
#systemctl reload nginx
# Installation with curl
#ynh_print_info "Finalizing install ..."
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
# Remove the public access
@@ -285,6 +298,7 @@ chown -R "$app":"$app" "$final_path"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Configuring log rotation ..."
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app.
@@ -316,6 +330,7 @@ yunohost service add $app --description "$app daemon for Wiki.js" --log "/var/lo
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat ..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@@ -327,6 +342,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx ..."
systemctl reload nginx
@@ -335,3 +351,9 @@ systemctl reload nginx
#=================================================
ynh_systemd_action --action=start --service_name=$app --line_match="Redis connection:"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation completed"