diff --git a/scripts/install b/scripts/install index f9a4687..821a0db 100644 --- a/scripts/install +++ b/scripts/install @@ -65,32 +65,6 @@ mkdir -p $final_path/sessions mkdir -p $final_path/conf.d mkdir -p $final_path/storage/fgal -#================================================= -# 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 -ynh_mysql_execute_as_root --sql="ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" -ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < $final_path/db/tiki.sql -ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < $final_path/db/tiki-secdb_22.1_mysql.sql -ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_host','localhost');" --database=$db_name -ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_basedn','ou=users,dc=yunohost,dc=org');" --database=$db_name -ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_scope','base');" --database=$db_name -ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_method','ldap');" --database=$db_name -ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_emailattr','mail');" --database=$db_name -ynh_mysql_execute_as_root --sql="UPDATE users_users set login='$admin_tiki' where userID = '1';" --database=$app - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=3 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= @@ -115,8 +89,6 @@ fi ynh_add_fpm_config --usage=$usage --footprint=medium --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#================================================= -# GENERIC FINALISATION #================================================= # SECURING FILES AND DIRECTORIES #================================================= @@ -125,15 +97,52 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) # Files have to be own by the user of wordpress. To allow upgrade from the app. chown -R $app: $final_path +#================================================= +# 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 +ynh_mysql_execute_as_root --sql="ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" + +# Workaround bug +ynh_replace_string --match_string="new GetStringsCommand," --replace_string="new InstallCommand," --target_file=$final_path/lib/core/Tiki/Command/ConsoleApplicationBuilder.php + +# Deploy database +sudo -u $app php7.4 $final_path/console.php database:configure $db_name $db_pwd $db_name +sudo -u $app php7.4 $final_path/console.php database:install + +# Undo Workaround bug +ynh_replace_string --match_string="new InstallCommand," --replace_string="new GetStringsCommand," --target_file=$final_path/lib/core/Tiki/Command/ConsoleApplicationBuilder.php + +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_host','localhost');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_basedn','ou=users,dc=yunohost,dc=org');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_scope','base');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_method','ldap');" --database=$db_name +ynh_mysql_execute_as_root --sql="INSERT INTO tiki_preferences (name, value) VALUES ('auth_ldap_emailattr','mail');" --database=$db_name +ynh_mysql_execute_as_root --sql="UPDATE users_users set login='$admin_tiki' where userID = '1';" --database=$app + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=3 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# GENERIC FINALISATION +#================================================= + #================================================= # SPECIFIC SETUP #================================================= -# CONFIGURE DATABASE +# CONFIGURE TIKI #================================================= ynh_script_progression --message="Configuring Tiki..." -sudo -u $app php7.4 $final_path/console.php database:configure $db_name $db_pwd $db_name - sudo -u $app php7.4 $final_path/console.php installer:lock #=================================================