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:
commit
1f0251856e
6 changed files with 75 additions and 12 deletions
|
@ -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"
|
||||
|
|
2
conf/sync_user_importer.sh
Normal file
2
conf/sync_user_importer.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
sudo -u __USER__ bash -c "cd __INSTALL_DIR__ && ./yeswicli importer:sync -s yunohost-users"
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
@ -100,14 +100,36 @@ 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
|
||||
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"
|
||||
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
|
||||
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
|
||||
|
|
|
@ -20,11 +20,21 @@ ynh_remove_nginx_config
|
|||
# Remove the dedicated PHP-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_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
|
||||
|
|
|
@ -82,22 +82,48 @@ 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
|
||||
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"
|
||||
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
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue