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

151 lines
5.4 KiB
Text
Raw Normal View History

2018-01-24 20:18:53 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_abort_if_errors
2018-01-24 20:18:53 +01:00
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
#REMOVEME? path=$YNH_APP_ARG_PATH
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
#REMOVEME? language=$YNH_APP_ARG_LANGUAGE
#REMOVEME? password=$YNH_APP_ARG_PASSWORD
2019-03-09 10:14:08 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
2018-01-24 20:18:53 +01:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
2018-01-24 20:18:53 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die "This path already contains a folder"
2018-01-24 20:18:53 +01:00
# Register (book) web path
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_webpath_register $app $domain $path
2018-01-24 20:18:53 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
2018-01-24 20:18:53 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
2021-08-16 12:16:15 +02:00
ynh_app_setting_set --app=$app --key=language --value=$language
2018-01-24 20:18:53 +01:00
2021-11-28 10:16:53 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
2021-11-28 10:16:53 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
2021-11-28 10:16:53 +01:00
2019-03-09 10:14:08 +01:00
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..."
2019-03-09 10:14:08 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? db_name=$(ynh_sanitize_dbid $app)
#REMOVEME? db_user=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
2018-01-24 20:18:53 +01:00
2021-08-16 12:16:15 +02:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_script_progression --message="Configuring system user..."
2021-08-16 12:16:15 +02:00
# Create a system user
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
2021-08-16 12:16:15 +02:00
2018-01-24 20:18:53 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2020-12-07 11:33:01 +01:00
ynh_script_progression --message="Setting up source files..."
2018-01-24 20:18:53 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_app_setting_set $app install_dir $install_dir
2018-01-24 20:18:53 +01:00
# Download, check integrity, uncompress and patch the source from app.src
2023-10-15 14:03:13 +02:00
ynh_setup_source "$install_dir"
2018-01-24 20:18:53 +01:00
2023-10-15 14:03:13 +02:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-08-16 12:16:15 +02:00
2018-01-24 20:18:53 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2020-12-07 12:03:27 +01:00
ynh_script_progression --message="Configuring NGINX web server..."
2018-01-24 20:18:53 +01:00
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2020-12-07 12:03:27 +01:00
ynh_script_progression --message="Configuring PHP-FPM..."
2018-01-24 20:18:53 +01:00
2020-12-07 12:03:27 +01:00
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
2023-10-15 14:03:13 +02:00
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
2019-03-09 10:14:08 +01:00
2020-12-07 12:03:27 +01:00
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
2018-01-24 20:18:53 +01:00
2020-12-07 12:03:27 +01:00
# Set the app as temporarily public for cURL call
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_permission_update --permission "main" --add "visitors"
2018-01-24 20:18:53 +01:00
2020-12-07 12:03:27 +01:00
# Reload NGINX
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
2020-12-07 12:03:27 +01:00
ynh_script_progression --message="Finalizing installation..."
2018-01-24 20:18:53 +01:00
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
2019-03-09 10:14:08 +01:00
# =========== modif perso ===========
#page 1
ynh_local_curl "/admin/install.php" "install_form_1_sended=1" "langue=$language"
#page 2
2023-10-15 14:03:13 +02:00
ynh_local_curl "/admin/install.php?s=2&l=$language" "identifiant=$admin" "mdp=$password" "racine=https://$domain$path/" "comm_defaut_status=1" "langue=$language" "install_form_2_sended=1"
2019-03-09 10:14:08 +01:00
#page 3
ynh_local_curl "/admin/install.php?s=3&l=$language" "sgdb=mysql" "mysql_user=$db_user" "mysql_passwd=$db_pwd" "mysql_db=$db_name" "mysql_host=localhost" "langue=$language" "install_form_3_sended=1"
2018-01-24 20:18:53 +01:00
#=================================================
# SETUP SSOWAT
#=================================================
2020-12-07 11:33:01 +01:00
ynh_script_progression --message="Configuring SSOwat..."
2018-01-24 20:18:53 +01:00
2020-12-07 11:54:33 +01:00
# Make app public if necessary or protect it
2023-10-15 14:03:13 +02:00
#REMOVEME? if [ $is_public -eq 0 ]
2018-01-24 20:18:53 +01:00
then
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_permission_update --permission="main" --remove="visitors"
2018-01-24 20:18:53 +01:00
fi
#=================================================
# RELOAD NGINX
#=================================================
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
2018-01-24 20:18:53 +01:00
2023-10-15 14:03:13 +02:00
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
2019-03-09 10:14:08 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-12-07 11:33:01 +01:00
ynh_script_progression --message="Installation of $app completed"