From ea731c8427d9316a4d3c560164012e897ed8fede Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 8 Jun 2022 22:30:14 +0200 Subject: [PATCH] More example_ynh --- scripts/install | 31 ++++++++++++++++++------------- scripts/restore | 8 ++++++++ scripts/upgrade | 17 +++++++++++++++-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/scripts/install b/scripts/install index cc92f02..31c964b 100644 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_add_config source /usr/share/yunohost/helpers #================================================= @@ -141,14 +140,25 @@ if [ $sudo ]; then fi fi +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." + +ynh_add_config --template="common.config.php" --destination="$final_path/core/config/common.config.php" + +chmod 400 "$final_path/core/config/common.config.php" +chown $app:$app "$final_path/core/config/common.config.php" + +# Cron +ynh_add_config --template="cronjeedom" --destination="/etc/cron.d/${app}" +ynh_add_config --template="cronjeedom_watchdog" --destination="/etc/cron.d/${app}_watchdog" + #================================================= # INSTALL JEEDOM #================================================= ynh_script_progression --message="Installing Jeedom..." -# Configure Jeedom database -ynh_add_config --template="common.config.php" --destination="$final_path/core/config/common.config.php" - # Install Jeedom php$phpversion $final_path/install/install.php mode=force @@ -156,10 +166,6 @@ php$phpversion $final_path/install/install.php mode=force ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="../conf/config.sql" ynh_mysql_execute_file_as_root --file="../conf/config.sql" --database=$db_name -# Cron -ynh_add_config --template="cronjeedom" --destination="/etc/cron.d/${app}" -ynh_add_config --template="cronjeedom_watchdog" --destination="/etc/cron.d/${app}_watchdog" - # Check #sudo php $final_path/install/sick.php @@ -183,11 +189,10 @@ chown www-data:www-data -R /tmp/jeedom #================================================= ynh_script_progression --message="Configuring permissions..." -# Remove the public access -ynh_app_setting_delete --app=$app --key=skipped_uris - -# Access to API without SSO -ynh_app_setting_set --app=$app --key=unprotected_uris --value="/core/api/jeeApi.php" +# Everyone can access the API part +# We don't want to display the tile in the SSO so we put --show_tile="false" +# And we don't want the YunoHost admin to be able to remove visitors group to this permission, so we put --protected="true" +ynh_permission_create --permission="api" --url="/core/api/jeeApi.php" --allowed="visitors" --show_tile="false" --protected="true" #================================================= # RELOAD NGINX diff --git a/scripts/restore b/scripts/restore index a772bca..93ccbb0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -45,6 +45,14 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0ca2f52..e398d18 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_add_config source /usr/share/yunohost/helpers #================================================= @@ -94,7 +93,7 @@ then ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="/core/config/common.config.php" fi chmod 750 "$final_path" @@ -157,6 +156,20 @@ if [ $sudo ]; then fi fi +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." + +ynh_add_config --template="common.config.php" --destination="$final_path/core/config/common.config.php" + +chmod 400 "$final_path/core/config/common.config.php" +chown $app:$app "$final_path/core/config/common.config.php" + +# Cron +ynh_add_config --template="cronjeedom" --destination="/etc/cron.d/${app}" +ynh_add_config --template="cronjeedom_watchdog" --destination="/etc/cron.d/${app}_watchdog" + #================================================= # UPGRADE JEEDOM #=================================================