From c09462555a51fcde11a2e62ee32010a0cef59529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Thu, 1 Aug 2019 14:01:59 +0200 Subject: [PATCH] Use getop for helpers --- scripts/_common.sh | 2 +- scripts/backup | 10 +++++----- scripts/change_url | 4 ++-- scripts/install | 11 +++++------ scripts/restore | 8 ++++---- scripts/upgrade | 4 ++-- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f165264..6da9ba3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,7 +22,7 @@ elif [ -n "$(uname -m | grep armv7)" ]; then elif [ -n "$(uname -m | grep arm)" ]; then architecture="arm" else - ynh_die "Unable to detect your achitecture, please open a bug describing \ + ynh_die --message "Unable to detect your achitecture, please open a bug describing \ your hardware and the result of the command \"uname -m\"." 1 fi diff --git a/scripts/backup b/scripts/backup index 6987560..8c43f5a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -22,17 +22,17 @@ domain=$(ynh_app_setting_get --app $app --key domain) #================================================= # Copy the app source files -ynh_backup "$final_path" +ynh_backup --src_path "$final_path" # Copy the data files -ynh_backup "$DATADIR" +ynh_backup --src_path "$DATADIR" # Copy the conf files -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" -ynh_backup "/etc/systemd/system/${app}.service" +ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf" +ynh_backup --src_path "/etc/systemd/system/${app}.service" # Backup logs -ynh_backup "/var/log/$app" +ynh_backup --src_path "/var/log/$app" # Dump the database ynh_mysql_dump_db "$dbname" > ./db.sql diff --git a/scripts/change_url b/scripts/change_url index 804a0c5..72b0d48 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -38,10 +38,10 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the domain for nginx if [[ "$old_domain" != "$domain" ]]; then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file "$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf" fi config_nginx diff --git a/scripts/install b/scripts/install index 2d294af..e49ddf0 100644 --- a/scripts/install +++ b/scripts/install @@ -20,16 +20,15 @@ path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH) admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC -# Check domain/path availability -ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain." -ynh_webpath_register $app $domain $path_url +# Register (book) web path +ynh_webpath_register --app $app --domain $domain --path_url $path_url # Check user parameter ynh_user_exists "$admin" \ - || ynh_die "The chosen admin user does not exist." + || ynh_die --message "The chosen admin user does not exist." # Check Final Path availability -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message "This path already contains a folder" # Generate random password and key dbpass=$(ynh_string_random) @@ -63,7 +62,7 @@ ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" # We can't use the official helper (for now) because we need to set the shell for the login test getent passwd "$app" &>/dev/null || \ useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \ - ynh_die "Unable to create $app system account" + ynh_die --message "Unable to create $app system account" # Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5) # ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell diff --git a/scripts/restore b/scripts/restore index f83803f..15bf903 100644 --- a/scripts/restore +++ b/scripts/restore @@ -22,14 +22,14 @@ admin=$(ynh_app_setting_get --app $app --key adminusername) port=$(ynh_app_setting_get --app $app --key web_port) # Check domain/path availability with app helper -ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain." +ynh_webpath_available $domain $path_url || ynh_die --message "$domain is not available as domain, please use an other domain." # Check user parameter ynh_user_exists "$admin" \ - || ynh_die "The chosen admin user does not exist." + || ynh_die --message "The chosen admin user does not exist." # Check Final Path availability -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message "This path already contains a folder" #================================================= # STANDARD RESTORATION STEPS @@ -39,7 +39,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # We can't use the official helper (for now) because we need to set the shell for the login test getent passwd "$app" &>/dev/null || \ useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \ - ynh_die "Unable to create $app system account" + ynh_die --message "Unable to create $app system account" # Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5) # ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell diff --git a/scripts/upgrade b/scripts/upgrade index 112a8c4..988ff52 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,7 +39,7 @@ systemctl stop "$app".service [[ $YNH_APP_ID == "gogs" ]] \ && [[ "$(cat "/opt/$app/templates/.VERSION")" != 0.11.79.1211 ]] \ - && ynh_die "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea." + && ynh_die --message "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea." ynh_handle_app_migration gogs gogs_migrations if [[ $migration_process -eq 1 ]]; then @@ -55,7 +55,7 @@ if [[ $migration_process -eq 1 ]]; then ynh_system_user_delete $old_app test getent passwd "$app" &>/dev/null || \ useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \ - ynh_die "Unable to create $app system account" + ynh_die --message "Unable to create $app system account" # Clean old binary ynh_secure_remove --file=$final_path/gogs