2015-04-28 17:54:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2021-05-18 23:30:35 +02:00
|
|
|
ynh_clean_setup () {
|
2019-03-10 02:20:27 +01:00
|
|
|
true
|
2016-09-20 01:51:28 +02:00
|
|
|
}
|
2019-03-10 02:20:27 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2016-08-30 00:22:47 +02:00
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2019-03-10 02:20:27 +01:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
2016-09-20 01:51:28 +02:00
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2022-08-04 21:35:29 +02:00
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
2021-05-18 04:02:21 +02:00
|
|
|
password=$YNH_APP_ARG_PASSWORD
|
2019-03-10 02:20:27 +01:00
|
|
|
users_status=$YNH_APP_ARG_USERS_STATUS
|
2016-09-20 01:51:28 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2020-12-14 13:15:15 +01:00
|
|
|
ynh_script_progression --message="Validating installation parameters..."
|
2016-09-20 01:51:28 +02:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
final_path=/var/www/$app
|
2020-12-18 10:52:22 +01:00
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
2015-04-28 17:54:25 +02:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
# Register (book) web path
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
2015-04-28 17:05:35 +02:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2020-12-14 13:15:15 +01:00
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
2015-04-28 17:05:35 +02:00
|
|
|
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
2020-12-18 17:43:45 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=password --value=$password
|
|
|
|
ynh_app_setting_set --app=$app --key=users_status --value=$users_status
|
2015-04-28 17:05:35 +02:00
|
|
|
|
2022-08-04 21:35:29 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
2021-12-31 08:57:46 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing dependencies..."
|
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
2021-05-18 04:02:21 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring system user..."
|
|
|
|
|
|
|
|
# Create a system user
|
2022-08-04 21:35:29 +02:00
|
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
2021-05-18 04:02:21 +02:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
#=================================================
|
2020-12-14 13:15:15 +01:00
|
|
|
ynh_script_progression --message="Creating a MySQL database..."
|
2019-03-10 02:20:27 +01:00
|
|
|
|
2020-12-18 10:52:22 +01:00
|
|
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
2021-05-18 04:02:21 +02:00
|
|
|
db_user=$db_name
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
2021-05-18 04:02:21 +02:00
|
|
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
2020-12-18 10:52:22 +01:00
|
|
|
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
2020-01-31 12:27:51 +01:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-12-14 13:15:15 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2015-04-28 17:05:35 +02:00
|
|
|
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
2019-03-10 02:20:27 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
2019-03-10 02:20:27 +01:00
|
|
|
|
2021-05-18 04:02:21 +02:00
|
|
|
chmod 750 "$final_path"
|
|
|
|
chmod -R o-rwx "$final_path"
|
|
|
|
chown -R $app:www-data "$final_path"
|
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
2019-03-10 02:20:27 +01:00
|
|
|
|
2021-05-18 23:30:35 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2021-12-31 08:57:46 +01:00
|
|
|
ynh_add_fpm_config
|
2019-03-10 02:20:27 +01:00
|
|
|
|
2022-08-04 21:35:29 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# SETUP APPLICATION WITH CURL
|
|
|
|
#=================================================
|
2021-05-18 04:02:21 +02:00
|
|
|
ynh_script_progression --message="Setuping application with CURL..."
|
2019-03-10 02:20:27 +01:00
|
|
|
|
|
|
|
# Set right permissions for curl install
|
2021-01-13 17:02:59 +01:00
|
|
|
mkdir -p $final_path/plugins/auto
|
2021-05-18 04:02:21 +02:00
|
|
|
chown -R $app:www-data "$final_path"
|
2019-03-10 02:20:27 +01:00
|
|
|
|
|
|
|
# Set the app as temporarily public for curl call
|
2021-05-18 04:02:21 +02:00
|
|
|
ynh_script_progression --message="Configuring SSOwat..."
|
2020-12-18 10:52:22 +01:00
|
|
|
|
2021-05-19 02:06:11 +02:00
|
|
|
# Installation with curl
|
2020-12-17 14:37:04 +01:00
|
|
|
ynh_script_progression --message="Finalizing installation..."
|
2019-03-10 02:20:27 +01:00
|
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=chmod"
|
2021-08-09 11:25:34 +02:00
|
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=2" "chmod=750" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql"
|
2019-03-10 02:20:27 +01:00
|
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=3" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql" "choix_db=$db_name" "tprefix=$db_name"
|
2019-03-13 21:25:07 +01:00
|
|
|
# For now spip have a problem with LDAP
|
|
|
|
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap1"
|
|
|
|
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap2" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3"
|
|
|
|
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap3" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3"
|
|
|
|
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap4" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3" "base_ldap=dc=yunohost,dc=org"
|
|
|
|
#
|
|
|
|
## statut_ldap can take: 0minirezo for Administrator, 1comite for Editor, 6forum for Visitor
|
|
|
|
#if [ $users_status = "Administrator" ]; then
|
|
|
|
# status="0minirezo"
|
|
|
|
#elif [ $users_status = "Editor" ]; then
|
|
|
|
# status="1comite"
|
|
|
|
#else
|
|
|
|
# status="6forum"
|
|
|
|
#fi
|
|
|
|
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=ldap5" "adresse_ldap=localhost" "port_ldap=389" "tls_ldap=no" "protocole_ldap=3" "base_ldap=dc=yunohost,dc=org" "statut_ldap=$status" "ldap_login=sAMAccountName,uid,login,userid,cn,sn" "ldap_nom=cn" "ldap_email=mail" "ldap_bio=description"
|
|
|
|
#ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=3" "ldap_present=true"
|
2016-09-20 15:48:43 +02:00
|
|
|
|
2020-04-25 21:43:09 +02:00
|
|
|
# Fix db initialization
|
|
|
|
ynh_local_curl "/ecrire/?exec=install" "etape=3b"
|
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
email=$(yunohost user info $admin | grep mail: | cut -d' ' -f2 | tr -d '\n')
|
2019-03-13 21:25:07 +01:00
|
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=3b" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql" "sel_db=$db_name" "nom=$admin" "email=$email" "login=$admin" "pass=$password" "pass_verif=$password"
|
2019-03-10 02:20:27 +01:00
|
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=fin"
|
2015-04-28 17:05:35 +02:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
2022-08-04 21:35:29 +02:00
|
|
|
# ADD A CONFIGURATION
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
2022-08-04 21:35:29 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2017-02-21 18:00:37 +01:00
|
|
|
|
2019-03-13 21:25:07 +01:00
|
|
|
#ynh_replace_string "'','utf8');" "'ldap.php','utf8');" $final_path/config/connect.php
|
2019-03-10 02:20:27 +01:00
|
|
|
cp ../conf/mes_options.php $final_path/config/mes_options.php
|
2017-02-21 18:42:21 +01:00
|
|
|
|
2023-06-01 09:51:02 +02:00
|
|
|
# Add security fix https://www.spip.net/en_article4201.html
|
|
|
|
cp ../conf/ecran_securite.php $final_path/config/ecran_securite.php
|
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
|
#=================================================
|
2015-04-28 17:05:35 +02:00
|
|
|
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_store_file_checksum --file="$final_path/config/connect.php"
|
2017-02-23 23:52:18 +01:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2021-05-18 04:02:21 +02:00
|
|
|
ynh_script_progression --message="Configuring permissions..."
|
2021-03-15 00:27:35 +01:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
# Make app public if necessary
|
2021-05-18 04:02:21 +02:00
|
|
|
if [ $is_public -eq 1 ]
|
2021-03-15 00:27:35 +01:00
|
|
|
then
|
2021-05-18 04:02:21 +02:00
|
|
|
# Everyone can access the app.
|
|
|
|
# The "main" permission is automatically created before the install script.
|
2021-03-15 00:27:35 +01:00
|
|
|
ynh_permission_update --permission="main" --add="visitors"
|
2017-03-05 19:42:06 +01:00
|
|
|
fi
|
2017-02-21 17:22:15 +01:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2019-03-10 02:20:27 +01:00
|
|
|
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2017-02-21 18:00:37 +01:00
|
|
|
|
2019-03-10 02:20:27 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-02-21 04:02:03 +01:00
|
|
|
|
2020-12-18 10:52:22 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|