1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/spip_ynh.git synced 2024-09-03 20:25:59 +02:00
spip_ynh/scripts/install

204 lines
7.3 KiB
Text
Raw Normal View History

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
#=================================================
ynh_clean_setup() {
### Remove this function if there's nothing to clean before calling the remove script.
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
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
2016-09-20 01:51:28 +02:00
is_public=$YNH_APP_ARG_IS_PUBLIC
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
#=================================================
ynh_print_info "Validating installation parameters..."
2016-09-20 01:51:28 +02:00
2019-03-10 02:20:27 +01:00
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
2015-04-28 17:54:25 +02:00
2019-03-10 02:20:27 +01:00
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
2015-04-28 17:05:35 +02:00
2019-03-10 02:20:27 +01:00
# Register (book) web path
ynh_webpath_register $app $domain $path_url
2015-04-28 17:05:35 +02:00
2019-03-10 02:20:27 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Storing installation settings..."
2015-04-28 17:05:35 +02:00
2017-02-21 04:02:03 +01:00
ynh_app_setting_set $app domain $domain
2019-03-10 02:20:27 +01:00
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app password $password
2017-02-21 04:02:03 +01:00
ynh_app_setting_set $app is_public $is_public
2019-03-10 02:20:27 +01:00
ynh_app_setting_set $app users_status $users_status
2015-04-28 17:05:35 +02:00
2019-03-10 02:20:27 +01:00
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_print_info "Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
2020-01-31 12:27:51 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
2019-03-10 02:20:27 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
2015-04-28 17:05:35 +02:00
2017-02-21 15:34:35 +01:00
ynh_app_setting_set $app final_path $final_path
2019-03-10 02:20:27 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
# Create a system user
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm..."
# Create a dedicated php-fpm config
ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Set right permissions for curl install
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
# Reload Nginx
systemctl reload nginx
ynh_print_info "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"
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"
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
# Remove the public access
if [ $is_public -eq 0 ]; then
ynh_app_setting_delete $app skipped_uris
fi
2015-04-28 17:05:35 +02:00
2019-03-10 02:20:27 +01:00
#=================================================
# MODIFY A CONFIG 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
2019-03-10 02:20:27 +01:00
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
2015-04-28 17:05:35 +02:00
2019-03-10 02:20:27 +01:00
ynh_store_file_checksum "$final_path/config/connect.php"
2017-02-23 23:52:18 +01:00
2019-03-10 02:20:27 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
2017-03-05 19:42:06 +01:00
2019-03-10 02:20:27 +01:00
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
2017-03-05 19:42:06 +01:00
2019-03-10 02:20:27 +01:00
# 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 unprotected_uris "/"
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
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
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
2019-03-10 02:20:27 +01:00
ynh_print_info "Installation of $app completed"