1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garradin_ynh.git synced 2024-09-03 18:36:17 +02:00
garradin_ynh/scripts/install

144 lines
5.1 KiB
Text
Raw Normal View History

2017-01-28 22:05:00 +01:00
#!/bin/bash
#=================================================
2018-03-24 01:16:50 +01:00
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
2017-01-28 22:05:00 +01:00
2018-03-24 01:16:50 +01:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
2017-01-28 22:05:00 +01:00
# Retrieve arguments
#=================================================
2017-03-17 22:51:37 +01:00
domain=$YNH_APP_ARG_DOMAIN
2018-03-24 01:36:34 +01:00
path_url=$YNH_APP_ARG_PATH
2017-03-17 22:51:37 +01:00
is_public=$YNH_APP_ARG_IS_PUBLIC
2017-01-28 22:05:00 +01:00
app=$YNH_APP_INSTANCE_NAME
#=================================================
2018-03-24 01:16:50 +01:00
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
2018-03-24 01:16:50 +01:00
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
2017-02-11 20:26:05 +01:00
2018-03-24 01:16:50 +01:00
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
2017-02-12 11:08:59 +01:00
2018-03-24 01:16:50 +01:00
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
2017-02-11 19:50:47 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --time --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
2017-01-28 23:11:24 +01:00
# Install dependency to convert tracks to a readable format for the browser
#=================================================
ynh_script_progression --message="Installing dependencies..." --time --weight=1
2020-03-31 17:43:53 +02:00
2020-04-02 16:34:46 +02:00
if [ "$(lsb_release --codename --short)" != "jessie" ]
then
ynh_install_app_dependencies $pkg_dependencies
2020-04-02 16:34:46 +02:00
else
ynh_die --message="Votre version de Debian n'est pas compatible..." --time --weight=1
2020-04-02 16:34:46 +02:00
fi
2017-01-29 16:06:11 +01:00
#=================================================
2018-03-24 01:16:50 +01:00
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1
2018-03-24 01:16:50 +01:00
# Create a system user
ynh_system_user_create --username=$app
2017-01-28 22:05:00 +01:00
#=================================================
2018-03-24 01:16:50 +01:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --time --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
2018-03-24 01:16:50 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
2018-03-24 01:16:50 +01:00
#=================================================
2020-04-05 15:01:54 +02:00
# Change options in file config.dist.php
# and copy in local.dist.php
#=================================================
2020-04-05 15:01:54 +02:00
cp -a $final_path/config.dist.php $final_path/config.local.php
# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php"
ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php"
2020-04-07 14:17:32 +02:00
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
2018-03-24 01:16:50 +01:00
#=================================================
# Files owned by user app
#=================================================
sudo chown $app:$app $final_path -R
2017-01-28 22:05:00 +01:00
sudo chmod 755 $final_path -R
#=================================================
2018-03-24 01:16:50 +01:00
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
2018-03-24 01:16:50 +01:00
# Create a dedicated nginx config
2020-04-02 16:34:46 +02:00
ynh_add_nginx_config
2017-01-28 22:05:00 +01:00
2018-03-24 01:25:15 +01:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
2018-03-24 01:25:15 +01:00
# Create a dedicated php-fpm config
2020-04-02 16:34:46 +02:00
ynh_add_fpm_config
2018-03-24 01:25:15 +01:00
#=================================================
2018-03-24 01:16:50 +01:00
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
2018-03-24 01:16:50 +01:00
if [ $is_public -eq 0 ]
2020-04-02 16:34:46 +02:00
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
2018-03-24 01:16:50 +01:00
fi
# Make app public if necessary
if [ $is_public -eq 1 ]
2017-01-28 22:05:00 +01:00
then
2020-04-02 16:34:46 +02:00
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
2017-01-28 22:05:00 +01:00
fi
#=================================================
2018-03-24 01:16:50 +01:00
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --time --last