From 16bdda72d239ed57eeb1ad3047bbd53ca3f26d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 4 Mar 2021 08:55:39 +0100 Subject: [PATCH] Testing (#11) * Fix Crystal install --- conf/config.yml | 2 +- manifest.json | 12 +---------- pull_request_template.md | 4 +--- scripts/_common.sh | 2 +- scripts/install | 43 ++++++++++++---------------------------- scripts/restore | 9 ++++++--- scripts/upgrade | 25 ++++++++--------------- 7 files changed, 31 insertions(+), 66 deletions(-) diff --git a/conf/config.yml b/conf/config.yml index f24ddda..ba89482 100644 --- a/conf/config.yml +++ b/conf/config.yml @@ -3,7 +3,7 @@ feed_threads: 1 db: user: __DB_NAME__ - password: __DB_PASS__ + password: __DB_PWD__ host: localhost port: 5432 dbname: __DB_NAME__ diff --git a/manifest.json b/manifest.json index 4e6faf2..9c6cf12 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Alternative front-end to YouTube", "fr": "Front-end alternatif à YouTube" }, - "version": "0.20.1~ynh4", + "version": "0.20.1~ynh5", "url": "https://invidio.us/", "license": "GPL-3.0-only", "maintainer": { @@ -30,16 +30,6 @@ }, "example": "domain.org" }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for Invidious", - "fr": "Choisissez un chemin pour Invidious" - }, - "example": "/", - "default": "/" - }, { "name": "is_public", "type": "boolean", diff --git a/pull_request_template.md b/pull_request_template.md index 8f1777a..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/invidious_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/invidious_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/_common.sh b/scripts/_common.sh index eddc170..8f6e28d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev zlib1g-dev" +pkg_dependencies="crystal apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev zlib1g-dev" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index c828128..e1ea2bc 100644 --- a/scripts/install +++ b/scripts/install @@ -46,10 +46,9 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # STANDARD MODIFICATIONS @@ -67,10 +66,10 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=9 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 +ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append -# Install Crystal -ynh_install_extra_app_dependencies --repo="deb https://dist.crystal-lang.org/apt crystal main" --package="crystal" --key="https://keybase.io/crystal/pgp_keys.asc" +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A POSTGRESQL DATABASE @@ -79,13 +78,9 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -db_pwd=$(ynh_string_random --length=30) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd - ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # CREATE DEDICATED USER @@ -135,15 +130,7 @@ popd || ynh_die #================================================= ynh_script_progression --message="Modifying a config file..." -cp ../conf/config.yml "$final_path/config/config.yml" - -# Main config File -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config/config.yml" -#ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/config/config.yml" - +ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" ynh_store_file_checksum --file="$final_path/config/config.yml" #================================================= @@ -151,9 +138,6 @@ ynh_store_file_checksum --file="$final_path/config/config.yml" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" - ynh_add_systemd_config #================================================= @@ -161,8 +145,7 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Setuping a cron..." --weight=1 -cp ../conf/cron_invidious /etc/cron.d/$app -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" +ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app" #================================================= # SETUP LOGROTATE @@ -180,7 +163,7 @@ ynh_use_logrotate ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files -chown -R $app: "$final_path" +chown -R $app: $final_path chmod 0644 /etc/logrotate.d/$app #================================================= @@ -196,17 +179,17 @@ 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 #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary or protect it if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/restore b/scripts/restore index 65fc421..73f870d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -73,7 +73,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files -chown -R $app: "$final_path" +chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION @@ -82,6 +82,9 @@ chown -R $app: "$final_path" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 +ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 +ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append + # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies @@ -114,7 +117,7 @@ yunohost service add $app --description="Invidious is an alternative front-end t #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd #================================================= # RESTORE VARIOUS FILES diff --git a/scripts/upgrade b/scripts/upgrade index 775a170..5d01812 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,13 +18,12 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK VERSION @@ -54,17 +53,17 @@ ynh_abort_if_errors #================================================= 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 #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=8 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 +ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append -# Install Crystal -ynh_install_extra_app_dependencies --repo="deb https://dist.crystal-lang.org/apt crystal main" --package="crystal" --key="https://keybase.io/crystal/pgp_keys.asc" +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -104,14 +103,9 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Modifying a config file..." --weight=3 -cp ../conf/config.yml "$final_path/config/config.yml" +ynh_backup_if_checksum_is_different --file="$final_path/config/config.yml" -# Main config File -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config/config.yml" -#ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/config/config.yml" +ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" ynh_store_file_checksum --file="$final_path/config/config.yml" @@ -120,9 +114,6 @@ ynh_store_file_checksum --file="$final_path/config/config.yml" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" - # Create a dedicated systemd config ynh_add_systemd_config @@ -157,7 +148,7 @@ yunohost service add $app --description="Invidious is an alternative front-end t #================================================= 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 #================================================= # RELOAD NGINX