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

Merge pull request #101 from Lab-8916100448256/testing

add more importer hooks and change app importer data source name
This commit is contained in:
Florian 2024-07-03 14:02:01 +03:00 committed by GitHub
commit 1f0251856e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 12 deletions

View file

@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/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" 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_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 # 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" ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostplugin"
# Add config at the end of wakka.config.php # 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/.*: //') 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" ynh_replace_string --match_string=");" --replace_string=" 'yunohost_sso_domain' => '${SSO_DOMAIN}',\n);" --target_file="$install_dir/wakka.config.php"
@ -100,14 +100,36 @@ chown root:root /etc/sudoers.d/$app
# Add a post app install hook to sync the app importer # Add a post app install hook to sync the app importer
mkdir -p /etc/yunohost/hooks.d/post_app_install mkdir -p /etc/yunohost/hooks.d/post_app_install
chmod 700 /etc/yunohost/hooks.d/post_app_install
ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" 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 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 chmod 700 /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
chmod 700 /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 700 /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
chmod 700 /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 700 /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
chmod 700 /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 700 /etc/yunohost/hooks.d/post_user_delete/${app}_sync_user_importer.sh
# At last, run the YunoHost app importer # At last, run the YunoHost app importer
ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2 ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2
pushd $install_dir pushd $install_dir
ynh_exec_as $app ./yeswicli importer:sync -s yunohost-cli ynh_exec_as $app ./yeswicli importer:sync -s yunohost-apps
popd popd
if [ "${authprovider}" = "Yunohost SSO" ]; then if [ "${authprovider}" = "Yunohost SSO" ]; then

View file

@ -20,11 +20,21 @@ ynh_remove_nginx_config
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config
# Remove sudoers file
ynh_secure_remove --file="/etc/sudoers/$app"
# Remove post app install hook #=================================================
# Remove sudoers file
#=================================================
ynh_script_progression --message="Removing sudoers file..." --weight=1
rm "/etc/sudoers.d/$app"
#=================================================
# 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_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 # END OF SCRIPT

View file

@ -82,22 +82,48 @@ chown root:root /etc/sudoers.d/$app
# Add a post app install hook to sync the app importer # Add a post app install hook to sync the app importer
mkdir -p /etc/yunohost/hooks.d/post_app_install mkdir -p /etc/yunohost/hooks.d/post_app_install
chmod 700 /etc/yunohost/hooks.d/post_app_install
ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" 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 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 chmod 700 /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
chmod 700 /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 700 /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
chmod 700 /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 700 /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
chmod 700 /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 700 /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 if [ $(grep yunohost_sso_domain "$install_dir/wakka.config.php" | wc -l) = "0" ]; then
SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //') 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" 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 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 # 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 ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2
pushd $install_dir pushd $install_dir
ynh_exec_as $app ./yeswicli importer:sync -s yunohost-cli ynh_exec_as $app ./yeswicli importer:sync -s yunohost-apps
popd popd
fi fi