From 6704482217e9187e1a3ad8396ad59d4a5d44319d Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 30 Dec 2023 02:53:28 +0100 Subject: [PATCH] add new parameters --- scripts/install | 26 +++++++++++++++----------- scripts/upgrade | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/scripts/install b/scripts/install index de1da35..b6f6d41 100644 --- a/scripts/install +++ b/scripts/install @@ -17,16 +17,20 @@ key=$(ynh_string_random --length=24) registration_enabled="true" login_enabled="true" captcha_enabled="true" +enable_user_notifications="true" +banner="" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set --app=$app --key=key --value=$key -ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled -ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled -ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled +ynh_app_setting_set --app="$app" --key=key --value="$key" +ynh_app_setting_set --app="$app" --key=registration_enabled --value=$registration_enabled +ynh_app_setting_set --app="$app" --key=login_enabled --value=$login_enabled +ynh_app_setting_set --app="$app" --key=captcha_enabled --value=$captcha_enabled +ynh_app_setting_set --app="$app" --key=enable_user_notifications --value=$enable_user_notifications +ynh_app_setting_set --app="$app" --key=banner --value="$banner" #================================================= # INSTALL DEPENDENCIES @@ -41,20 +45,20 @@ ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- - ynh_script_progression --message="Setting up source files..." --weight=4 mkdir -p "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" -git config --system --add safe.directory $install_dir +git config --system --add safe.directory "$install_dir" # Download, check integrity, uncompress and patch the source from GitHub git clone https://github.com/iv-org/invidious "$install_dir" --quiet pushd "$install_dir" - git reset --hard --quiet $version_commit + git reset --hard --quiet "$version_commit" make popd chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # MODIFY A CONFIG FILE @@ -64,7 +68,7 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml" chmod 600 "$install_dir/config/config.yml" -chown $app:$app "$install_dir/config/config.yml" +chown "$app:$app" "$install_dir/config/config.yml" #================================================= # SPECIFIC SETUP @@ -93,7 +97,7 @@ ynh_use_logrotate ynh_add_systemd_config -yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -101,7 +105,7 @@ yunohost service add $app --description="Invidious is an alternative front-end t ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path=systemd +ynh_systemd_action --service_name="$app" --action=start --log_path=systemd #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 0dd72ee..070e706 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=stop --log_path=systemd +ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -31,22 +31,32 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 if [ -z "${registration_enabled:-}" ]; then registration_enabled="true" - ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled + ynh_app_setting_set --app="$app" --key=registration_enabled --value=$registration_enabled fi if [ -z "${login_enabled:-}" ]; then login_enabled="true" - ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled + ynh_app_setting_set --app="$app" --key=login_enabled --value=$login_enabled fi if [ -z "${captcha_enabled:-}" ]; then captcha_enabled="true" - ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled + ynh_app_setting_set --app="$app" --key=captcha_enabled --value=$captcha_enabled fi if [ -z "${key:-}" ]; then key=$(ynh_string_random --length=24) - ynh_app_setting_set --app=$app --key=key --value=$key + ynh_app_setting_set --app="$app" --key=key --value="$key" +fi + +if [ -z "${enable_user_notifications:-}" ]; then + enable_user_notifications="true" + ynh_app_setting_set --app="$app" --key=enable_user_notifications --value="$enable_user_notifications" +fi + +if [ -z "${banner:-}" ]; then + banner="" + ynh_app_setting_set --app="$app" --key=banner --value="$banner" fi #================================================= @@ -64,21 +74,21 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=5 - pushd $install_dir - chown -R $app:www-data "$install_dir" - git config --system --add safe.directory $install_dir + pushd "$install_dir" + chown -R "$app:www-data" "$install_dir" + git config --system --add safe.directory "$install_dir" - ynh_exec_as $app git fetch + ynh_exec_as "$app" git fetch #git checkout master - ynh_exec_as $app git reset --hard --quiet $version_commit - ynh_exec_as $app git pull + ynh_exec_as "$app" git reset --hard --quiet "$version_commit" + ynh_exec_as "$app" git pull ynh_exec_warn_less shards install --production - ynh_exec_warn_less crystal build $install_dir/src/invidious.cr --release + ynh_exec_warn_less crystal build "$install_dir/src/invidious.c"r --release popd fi chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -96,7 +106,7 @@ chmod 644 "/etc/cron.d/$app" ynh_use_logrotate --non-append -yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" #================================================= # MODIFY A CONFIG FILE @@ -105,15 +115,15 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml" -chmod 600 $install_dir/config/config.yml -chown $app:$app "$install_dir/config/config.yml" +chmod 600 "$install_dir/config/config.yml" +chown "$app:$app" "$install_dir/config/config.yml" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=restart --log_path=systemd +ynh_systemd_action --service_name="$app" --action=restart --log_path=systemd #================================================= # END OF SCRIPT