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

add more importer hooks and change yunohost app importer data source name

This commit is contained in:
Douze Baie 2024-07-03 08:45:57 +02:00
parent 7b5a73f1ff
commit 1b04f525d9
6 changed files with 64 additions and 8 deletions

View file

@ -1,2 +1,2 @@
#!/usr/bin/env bash
sudo -u __USER__ bash -c "cd __INSTALL_DIR__ && ./yeswicli importer:sync -s yunohost-cli"
sudo -u __USER__ bash -c "cd __INSTALL_DIR__ && ./yeswicli importer:sync -s yunohost-apps"

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
sudo -u __USER__ bash -c "cd __INSTALL_DIR__ && ./yeswicli importer:sync -s yunohost-users"

View file

@ -40,10 +40,13 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/sudoers.d/$app"
#=================================================
# BACKUP THE IMPORTER PLUGIN POST APP INSTALL HOOK
# BACKUP THE IMPORTERS HOOKS
#=================================================
ynh_backup --src_path="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh"
ynh_backup --src_path="/etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh"
ynh_backup --src_path="/etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh"
ynh_backup --src_path="/etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh"
#=================================================
# BACKUP THE MYSQL DATABASE

View file

@ -87,7 +87,7 @@ mkdir -p "$install_dir/tools/yunohost"
ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostplugin"
# 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"
ynh_replace_string --match_string=");" --replace_string=" 'dataSources' => [\n'yunohost-apps' => [\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"
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"
@ -104,10 +104,28 @@ ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/ho
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
# Add a post app remove hook to sync the app importer
mkdir -p /etc/yunohost/hooks.d/post_app_remove
ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh
chmod +x /etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh
# Add a post user create hook to sync the user importer
mkdir -p /etc/yunohost/hooks.d/post_user_create
ynh_add_config --template="sync_user_importer.sh" --destination="/etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh
chmod +x /etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh
# Add a post user delete hook to sync the user importer
mkdir -p /etc/yunohost/hooks.d/post_user_delete
ynh_add_config --template="sync_user_importer.sh" --destination="/etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh
chmod +x /etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh
# 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
ynh_exec_as $app ./yeswicli importer:sync -s yunohost-apps
popd
if [ "${authprovider}" = "Yunohost SSO" ]; then

View file

@ -20,11 +20,21 @@ ynh_remove_nginx_config
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# Remove sudoers file
#=================================================
ynh_script_progression --message="Removing sudoers file..." --weight=1
ynh_secure_remove --file="/etc/sudoers/$app"
# Remove post app install hook
#=================================================
# Remove hooks
#=================================================
ynh_script_progression --message="Removing hooks..." --weight=1
ynh_secure_remove --file="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh"
ynh_secure_remove --file="/etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh"
ynh_secure_remove --file="/etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh"
ynh_secure_remove --file="/etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh"
#=================================================
# END OF SCRIPT

View file

@ -86,18 +86,41 @@ ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/ho
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
# Add a post app remove hook to sync the app importer
mkdir -p /etc/yunohost/hooks.d/post_app_remove
ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh
chmod +x /etc/yunohost/hooks.d/post_app_remove/${app}_sync_app_importer.sh
# Add a post user create hook to sync the user importer
mkdir -p /etc/yunohost/hooks.d/post_user_create
ynh_add_config --template="sync_user_importer.sh" --destination="/etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh
chmod +x /etc/yunohost/hooks.d/post_user_create/${app}_sync_user_importer.sh
# Add a post user delete hook to sync the user importer
mkdir -p /etc/yunohost/hooks.d/post_user_delete
ynh_add_config --template="sync_user_importer.sh" --destination="/etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh"
chown root:root /etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh
chmod +x /etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh
if [ $(grep yunohost_sso_domain "$install_dir/wakka.config.php" | wc -l) = "0" ]; then
SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //')
ynh_replace_string --match_string="'wakka_version'" --replace_string="'yunohost_sso_domain' => '${SSO_DOMAIN}',\n 'wakka_version'" --target_file="$install_dir/wakka.config.php"
fi
# ToDo : Add app importer config in wakka.config.php if it is not already there ?
if [ $(grep yunohost-cli "$install_dir/wakka.config.php" | wc -l) != "0" ]; then
ynh_replace_string --match_string="'yunohost-cli'" --replace_string="'yunohost-apps'" --target_file="$install_dir/wakka.config.php"
fi
# ToDo : Add app importer config in wakka.config.php if it is not already there ? (need to find a formid that is not already used)
# At last, run the YunoHost app importer if its data source is configured
if [ $(grep yunohost-cli "$install_dir/wakka.config.php" | wc -l) != "0" ]; then
if [ $(grep yunohost-apps "$install_dir/wakka.config.php" | wc -l) != "0" ]; then
ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2
pushd $install_dir
ynh_exec_as $app ./yeswicli importer:sync -s yunohost-cli
ynh_exec_as $app ./yeswicli importer:sync -s yunohost-apps
popd
fi