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

159 lines
6.9 KiB
Text
Raw Normal View History

2020-04-16 14:08:38 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2020-11-28 15:37:48 +01:00
ynh_script_progression --message="Setting up source files..." --weight=5
2020-04-16 14:08:38 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-06-14 10:41:57 +02:00
ynh_setup_source --dest_dir="$install_dir"
2020-04-16 14:08:38 +02:00
2024-06-14 11:31:13 +02:00
chown -R ${app}:www-data $install_dir
chmod -R u=rwX,g=rX,o-rwx $install_dir
2022-07-07 03:08:58 +02:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2023-07-10 08:53:40 +02:00
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1
2022-07-07 03:08:58 +02:00
# Create a dedicated PHP-FPM config
2023-07-10 08:53:40 +02:00
ynh_add_fpm_config --usage=low --footprint=low
2020-04-16 14:08:38 +02:00
2020-10-06 13:58:22 +02:00
# Create a dedicated NGINX config
2020-04-16 14:08:38 +02:00
ynh_add_nginx_config
#=================================================
2022-07-07 03:08:58 +02:00
# SPECIFIC SETUP
2020-04-16 14:08:38 +02:00
#=================================================
2022-07-07 03:08:58 +02:00
# INSTALL COMPOSER DEPENDENCIES
#=================================================
2023-07-02 18:39:53 +02:00
ynh_script_progression --message="Installing composer dependencies..."
2020-04-16 14:08:38 +02:00
2023-06-14 10:41:57 +02:00
ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir"
2020-04-16 14:08:38 +02:00
2020-04-27 11:37:38 +02:00
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
2020-04-16 14:08:38 +02:00
2020-04-27 11:37:38 +02:00
# Installation with curl
2020-11-28 15:37:48 +01:00
ynh_script_progression --message="Finalizing installation..." --weight=2
admin_temp_pass=$(ynh_string_random 20)
wiki_name_escaped=$(echo "$wiki_name" | sed 's/ /%20/g')
if [ "${wikimodel}" = "CLIC" ]; then
# replace default yeswiki model with CLIC model
mv $install_dir/setup/sql/default-content.sql $install_dir/setup/sql/default-content.sql.original
cp ../conf/CLIC/default-content.sql $install_dir/setup/sql/default-content.sql
fi
ynh_local_curl "/?PagePrincipale&installAction=install" "config[default_language]=$language" "config[wakka_name]=$wiki_name_escaped" \
2020-04-21 19:52:06 +02:00
"config[root_page]=PagePrincipale" "config[mysql_host]=localhost" \
"config[mysql_database]=$app" "config[mysql_user]=$db_user" "config[mysql_password]=$db_pwd" "config[table_prefix]=yeswiki_" \
"admin_name=$admin" "admin_password=$admin_temp_pass" "admin_password_conf=$admin_temp_pass" \
2022-03-08 17:00:38 +01:00
"admin_email=$admin%40$domain" "submit=Continue"
2020-04-27 11:37:38 +02:00
if [ "${wikimodel}" = "CLIC" ]; then
# restore original yeswiki model
mv -f $install_dir/setup/sql/default-content.sql.original $install_dir/setup/sql/default-content.sql
fi
2020-11-21 20:56:29 +01:00
# authorization of html
# (kind of strange, should be doable using the previous curl?)
2023-06-14 10:41:57 +02:00
ynh_replace_string --match_string="'allow_raw_html' => false," --replace_string="'allow_raw_html' => true," --target_file="$install_dir/wakka.config.php"
2020-11-21 20:56:29 +01:00
2024-05-24 15:36:21 +02:00
#=================================================
# DOWNLOAD AND CONFIGURE IMPORTER PLUGIN
#=================================================
ynh_script_progression --message="Configure importer plugin" --weight=1
# Download importer plugin from yeswiki repository
2024-05-24 15:36:21 +02:00
mkdir -p "$install_dir/tools/importer"
ynh_setup_source --dest_dir="$install_dir/tools/importer" --source_id="importerplugin"
2024-05-24 15:36:21 +02:00
#=================================================
# DOWNLOAD AND CONFIGURE YUNOHOST PLUGIN
#=================================================
ynh_script_progression --message="Configure yunohost plugin" --weight=2
2024-05-24 14:28:39 +02:00
2024-05-24 15:36:21 +02:00
# Download yeswiki plugin from yeswiki repository
mkdir -p "$install_dir/tools/yunohost"
ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostplugin"
2024-05-24 14:28:39 +02:00
2024-05-24 15:36:21 +02:00
# Add config at the end of wakka.config.php
ynh_replace_string --match_string=");" --replace_string=" 'dataSources' => [\n'yunohost-cli' => [\n'formId' => '5', // form id used in local bazar\n'lang' => 'fr',\n'importer' => 'YunohostCLIApp', // importer class name (without Importer suffix)\n],\n],\n);" --target_file="$install_dir/wakka.config.php"
2024-06-14 11:15:41 +02:00
SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //')
ynh_replace_string --match_string=");" --replace_string=" 'yunohost_sso_domain' => '${SSO_DOMAIN}',\n);" --target_file="$install_dir/wakka.config.php"
2024-05-24 14:28:39 +02:00
2024-05-24 15:36:21 +02:00
# Ensure that scripts are executable
chmod +x $install_dir/tools/yunohost/private/scripts/*.sh
2024-05-24 14:28:39 +02:00
2024-05-24 15:36:21 +02:00
# Add app user in sudoers to authorize to launch yunohost cli commands without password
2024-05-24 15:46:25 +02:00
ynh_add_config --template="sudoers" --destination="/etc/sudoers.d/$app"
chown root:root /etc/sudoers.d/$app
# Add a post app install hook to sync the app importer
mkdir -p /etc/yunohost/hooks.d/post_app_install
2024-06-14 11:31:13 +02:00
ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh
chmod +x /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh
2024-05-24 14:28:39 +02:00
2024-05-24 15:36:21 +02:00
# At last, run the YunoHost app importer
ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2
pushd $install_dir
ynh_exec_as $app ./yeswicli importer:sync -s yunohost-cli
popd
2024-05-24 14:28:39 +02:00
2024-05-24 15:36:21 +02:00
if [ "${authprovider}" = "Yunohost SSO" ]; then
#=================================================
# CONFIGURE YUNOHOST PLUGIN
#=================================================
ynh_script_progression --message="Enable YunoHost SSO" --weight=1
# Add config at the end of wakka.config.php
ynh_replace_string --match_string=");" --replace_string=" 'enable_yunohost_sso' => true,\n);" --target_file="$install_dir/wakka.config.php"
fi
if [ "${wikimodel}" = "CLIC" ]; then
#=================================================
# DOWNLOAD AND CONFIGURE FERME PLUGIN
#=================================================
ynh_script_progression --message="Configure ferme plugin" --weight=2
# Download ferme plugin from yeswiki repository
mkdir -p "$install_dir/tools/ferme"
ynh_setup_source --dest_dir="$install_dir/tools/ferme" --source_id="ferme"
# copy css presets and files from CLIC
cp -R ../source/CLIC/custom/* $install_dir/custom/
cp -R ../source/CLIC/files/* $install_dir/files/
# update configuration
ynh_replace_string --match_string=");" --replace_string=" 'favorite_preset' => 'custom/clic.css',\n);" --target_file="$install_dir/wakka.config.php"
ynh_replace_string --match_string=");" --replace_string=" 'favicon' => 'files/faviconclic.png',\n);" --target_file="$install_dir/wakka.config.php"
fi
2020-04-16 14:08:38 +02:00
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2024-06-14 11:31:13 +02:00
chown -R ${app}:www-data $install_dir
chmod -R u=rwX,g=rX,o-rwx $install_dir
chmod g-rwx $install_dir/wakka.config.php
2020-04-16 14:08:38 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2021-11-05 22:50:45 +01:00
ynh_script_progression --message="Installation of $app completed" --last