mirror of
https://github.com/YunoHost-Apps/spip_ynh.git
synced 2024-09-03 20:25:59 +02:00
191 lines
7.5 KiB
Bash
191 lines
7.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
ynh_clean_setup() {
|
|
### Remove this function if there's nothing to clean before calling the remove script.
|
|
true
|
|
}
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
path_url=$YNH_APP_ARG_PATH
|
|
admin=$YNH_APP_ARG_ADMIN
|
|
password=$YNH_APP_ARG_PASSWORD
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
users_status=$YNH_APP_ARG_USERS_STATUS
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
#=================================================
|
|
ynh_script_progression --message="Validating installation parameters..."
|
|
|
|
final_path=/var/www/$app
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
|
|
|
# Register (book) web path
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_script_progression --message="Storing installation settings..."
|
|
|
|
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=admin --value=$admin
|
|
ynh_app_setting_set --app=$app --key=password --value=$password
|
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
|
ynh_app_setting_set --app=$app --key=users_status --value=$users_status
|
|
|
|
#=================================================
|
|
# CREATE A MYSQL DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Creating a MySQL database..."
|
|
|
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
|
|
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
|
|
|
# Create a dedicated nginx config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# CREATE DEDICATED USER
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring system user..."
|
|
|
|
# Create a system user
|
|
ynh_system_user_create --username=$app
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
|
|
|
# Create a dedicated php-fpm config
|
|
ynh_add_fpm_config --package="$extra_php_dependencies"
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# SETUP APPLICATION WITH CURL
|
|
#=================================================
|
|
|
|
# Set right permissions for curl install
|
|
mkdir -p $final_path/plugins/auto
|
|
chown -R $app: $final_path
|
|
|
|
# Set the app as temporarily public for curl call
|
|
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
|
|
# Reload SSOwat config
|
|
yunohost app ssowatconf
|
|
|
|
# Reload Nginx
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
ynh_script_progression --message="Finalizing installation..."
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=chmod"
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=2" "chmod=755" "adresse_db=localhost" "login_db=$db_name" "pass_db=$db_pwd" "server_db=mysql"
|
|
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"
|
|
# 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"
|
|
|
|
# Fix db initialization
|
|
ynh_local_curl "/ecrire/?exec=install" "etape=3b"
|
|
|
|
email=$(yunohost user info $admin | grep mail: | cut -d' ' -f2 | tr -d '\n')
|
|
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"
|
|
ynh_local_curl "/ecrire/?suivant" "exec=install" "etape=fin"
|
|
|
|
ynh_app_setting_delete --app=$app --key=skipped_uris
|
|
|
|
#=================================================
|
|
# MODIFY A CONFIG FILE
|
|
#=================================================
|
|
|
|
#ynh_replace_string "'','utf8');" "'ldap.php','utf8');" $final_path/config/connect.php
|
|
cp ../conf/mes_options.php $final_path/config/mes_options.php
|
|
|
|
#=================================================
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
#=================================================
|
|
|
|
ynh_store_file_checksum --file="$final_path/config/connect.php"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# SETUP SSOWAT
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring SSOwat..."
|
|
|
|
# Make app public if necessary
|
|
if [ $is_public -eq 1 ]; then
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
fi
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|