From 38b39ebaeaa9ce234db210caa5cf0d3280f6a8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 31 Aug 2024 10:28:18 +0200 Subject: [PATCH] helpersv1: Tabs to spaces --- helpers/helpers.v1.d/apps | 170 +++++++-------- helpers/helpers.v1.d/apt | 2 +- helpers/helpers.v1.d/getopts | 2 +- helpers/helpers.v1.d/logging | 8 +- helpers/helpers.v1.d/mongodb | 410 +++++++++++++++++------------------ helpers/helpers.v1.d/redis | 38 ++-- helpers/helpers.v1.d/ruby | 6 +- 7 files changed, 318 insertions(+), 318 deletions(-) diff --git a/helpers/helpers.v1.d/apps b/helpers/helpers.v1.d/apps index 81a5717eb..e1458d0ed 100644 --- a/helpers/helpers.v1.d/apps +++ b/helpers/helpers.v1.d/apps @@ -7,52 +7,52 @@ # # Requires YunoHost version *.*.* or higher. ynh_install_apps() { - # Declare an array to define the options of this helper. - local legacy_args=a - local -A args_array=([a]=apps=) - local apps - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=a + local -A args_array=([a]=apps=) + local apps + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - # Split the list of apps in an array - local apps_list=($(echo $apps | tr " " "\n")) - local apps_dependencies="" - - # For each app - for one_app_and_its_args in "${apps_list[@]}" - do - # Retrieve the name of the app (part before ?) - local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args") - [ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install" + # Split the list of apps in an array + local apps_list=($(echo $apps | tr " " "\n")) + local apps_dependencies="" - yunohost tools update apps - - # Installing or upgrading the app depending if it's installed or not - if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' >/dev/null - then - # Retrieve the arguments of the app (part after ?) - local one_argument="" - if [[ "$one_app_and_its_args" == *"?"* ]]; then - one_argument=$(cut -d "?" -f2- <<< "$one_app_and_its_args") - one_argument="--args $one_argument" - fi - - # Install the app with its arguments - yunohost app install $one_app $one_argument - else - # Upgrade the app - yunohost app upgrade $one_app - fi + # For each app + for one_app_and_its_args in "${apps_list[@]}" + do + # Retrieve the name of the app (part before ?) + local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args") + [ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install" - if [ ! -z "$apps_dependencies" ] - then - apps_dependencies="$apps_dependencies, $one_app" - else - apps_dependencies="$one_app" - fi - done + yunohost tools update apps - ynh_app_setting_set --app=$app --key=apps_dependencies --value="$apps_dependencies" + # Installing or upgrading the app depending if it's installed or not + if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' >/dev/null + then + # Retrieve the arguments of the app (part after ?) + local one_argument="" + if [[ "$one_app_and_its_args" == *"?"* ]]; then + one_argument=$(cut -d "?" -f2- <<< "$one_app_and_its_args") + one_argument="--args $one_argument" + fi + + # Install the app with its arguments + yunohost app install $one_app $one_argument + else + # Upgrade the app + yunohost app upgrade $one_app + fi + + if [ ! -z "$apps_dependencies" ] + then + apps_dependencies="$apps_dependencies, $one_app" + else + apps_dependencies="$one_app" + fi + done + + ynh_app_setting_set --app=$app --key=apps_dependencies --value="$apps_dependencies" } # Remove other YunoHost apps @@ -63,53 +63,53 @@ ynh_install_apps() { # # Requires YunoHost version *.*.* or higher. ynh_remove_apps() { - # Retrieve the apps dependencies of the app - local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies) - ynh_app_setting_delete --app=$app --key=apps_dependencies + # Retrieve the apps dependencies of the app + local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies) + ynh_app_setting_delete --app=$app --key=apps_dependencies - if [ ! -z "$apps_dependencies" ] - then - # Split the list of apps dependencies in an array - local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n")) - - # For each apps dependencies - for one_app in "${apps_dependencies_list[@]}" - do - # Retrieve the list of installed apps - local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id) - local required_by="" - local installed_app_required_by="" + if [ ! -z "$apps_dependencies" ] + then + # Split the list of apps dependencies in an array + local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n")) - # For each other installed app - for one_installed_app in $installed_apps_list - do - # Retrieve the other apps dependencies - one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies) - if [ ! -z "$one_installed_apps_dependencies" ] - then - one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n")) + # For each apps dependencies + for one_app in "${apps_dependencies_list[@]}" + do + # Retrieve the list of installed apps + local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id) + local required_by="" + local installed_app_required_by="" - # For each dependency of the other apps - for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}" - do - if [[ $one_installed_app_dependency == $one_app ]]; then - required_by="$required_by $one_installed_app" - fi - done - fi - done + # For each other installed app + for one_installed_app in $installed_apps_list + do + # Retrieve the other apps dependencies + one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies) + if [ ! -z "$one_installed_apps_dependencies" ] + then + one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n")) - # If $one_app is no more required - if [[ -z "$required_by" ]] - then - # Remove $one_app - ynh_print_info --message="Removing of $one_app" - yunohost app remove $one_app --purge - else - ynh_print_info --message="$one_app was not removed because it's still required by${required_by}" - fi - done - fi + # For each dependency of the other apps + for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}" + do + if [[ $one_installed_app_dependency == $one_app ]]; then + required_by="$required_by $one_installed_app" + fi + done + fi + done + + # If $one_app is no more required + if [[ -z "$required_by" ]] + then + # Remove $one_app + ynh_print_info --message="Removing of $one_app" + yunohost app remove $one_app --purge + else + ynh_print_info --message="$one_app was not removed because it's still required by${required_by}" + fi + done + fi } # Spawn a Bash shell with the app environment loaded diff --git a/helpers/helpers.v1.d/apt b/helpers/helpers.v1.d/apt index cd648438a..798d954f2 100644 --- a/helpers/helpers.v1.d/apt +++ b/helpers/helpers.v1.d/apt @@ -372,7 +372,7 @@ ynh_add_app_dependencies() { # # Requires YunoHost version 2.6.4 or higher. ynh_remove_app_dependencies() { - local dep_app=${app//_/-} # Replace all '_' by '-' + local dep_app=${app//_/-} # Replace all '_' by '-' local current_dependencies="" if ynh_package_is_installed --package="${dep_app}-ynh-deps"; then diff --git a/helpers/helpers.v1.d/getopts b/helpers/helpers.v1.d/getopts index f9ef5dc0b..9fd84f82e 100644 --- a/helpers/helpers.v1.d/getopts +++ b/helpers/helpers.v1.d/getopts @@ -20,7 +20,7 @@ # | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function # # This helper need an array, named "args_array" with all the arguments used by the helper -# that want to use ynh_handle_getopts_args +# that want to use ynh_handle_getopts_args # Be carreful, this array has to be an associative array, as the following example: # local -A args_array=( [a]=arg1 [b]=arg2= [c]=arg3 ) # Let's explain this array: diff --git a/helpers/helpers.v1.d/logging b/helpers/helpers.v1.d/logging index accb8f9b0..1b3cd7760 100644 --- a/helpers/helpers.v1.d/logging +++ b/helpers/helpers.v1.d/logging @@ -271,9 +271,9 @@ ynh_script_progression() { # Always activate time when running inside CI tests if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then - time=${time:-1} + time=${time:-1} else - time=${time:-0} + time=${time:-0} fi last=${last:-0} @@ -298,8 +298,8 @@ ynh_script_progression() { local weight_values=$(($(echo "$weight_valuesA" "$weight_valuesB" | grep -v -E '^\s*$' | tr '\n' '+' | sed 's/+$/+0/g'))) # max_progression is a total number of calls to this helper. - # Less the number of calls with a weight value. - # Plus the total of weight values + # Less the number of calls with a weight value. + # Plus the total of weight values max_progression=$(($helper_calls - $weight_calls + $weight_values)) fi diff --git a/helpers/helpers.v1.d/mongodb b/helpers/helpers.v1.d/mongodb index 8736aad31..ae4cf812a 100644 --- a/helpers/helpers.v1.d/mongodb +++ b/helpers/helpers.v1.d/mongodb @@ -6,100 +6,100 @@ # example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")" # # usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval] -# | arg: -u, --user= - The user name to connect as -# | arg: -p, --password= - The user password -# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to -# | arg: -d, --database= - The database to connect to -# | arg: -h, --host= - The host to connect to -# | arg: -P, --port= - The port to connect to -# | arg: -c, --command= - The command to evaluate -# | arg: -e, --eval - Evaluate instead of execute the command. +# | arg: -u, --user= - The user name to connect as +# | arg: -p, --password= - The user password +# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to +# | arg: -d, --database= - The database to connect to +# | arg: -h, --host= - The host to connect to +# | arg: -P, --port= - The port to connect to +# | arg: -c, --command= - The command to evaluate +# | arg: -e, --eval - Evaluate instead of execute the command. # # ynh_mongo_exec() { - # Declare an array to define the options of this helper. - local legacy_args=upadhPce - local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval ) - local user - local password - local authenticationdatabase - local database - local host - local port - local command - local eval - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - user="${user:-}" - password="${password:-}" - authenticationdatabase="${authenticationdatabase:-}" - database="${database:-}" - host="${host:-}" - port="${port:-}" - eval=${eval:-0} + # Declare an array to define the options of this helper. + local legacy_args=upadhPce + local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval ) + local user + local password + local authenticationdatabase + local database + local host + local port + local command + local eval + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + user="${user:-}" + password="${password:-}" + authenticationdatabase="${authenticationdatabase:-}" + database="${database:-}" + host="${host:-}" + port="${port:-}" + eval=${eval:-0} - # If user is provided - if [ -n "$user" ] - then - user="--username=$user" + # If user is provided + if [ -n "$user" ] + then + user="--username=$user" - # If password is provided - if [ -n "$password" ] - then - password="--password=$password" - fi + # If password is provided + if [ -n "$password" ] + then + password="--password=$password" + fi - # If authenticationdatabase is provided - if [ -n "$authenticationdatabase" ] - then - authenticationdatabase="--authenticationDatabase=$authenticationdatabase" - else - authenticationdatabase="--authenticationDatabase=admin" - fi - else - password="" - authenticationdatabase="" - fi + # If authenticationdatabase is provided + if [ -n "$authenticationdatabase" ] + then + authenticationdatabase="--authenticationDatabase=$authenticationdatabase" + else + authenticationdatabase="--authenticationDatabase=admin" + fi + else + password="" + authenticationdatabase="" + fi - # If host is provided - if [ -n "$host" ] - then - host="--host=$host" - fi + # If host is provided + if [ -n "$host" ] + then + host="--host=$host" + fi - # If port is provided - if [ -n "$port" ] - then - port="--port=$port" - fi + # If port is provided + if [ -n "$port" ] + then + port="--port=$port" + fi - # If eval is not provided - if [ $eval -eq 0 ] - then - # If database is provided - if [ -n "$database" ] - then - database="use $database" - else - database="" - fi + # If eval is not provided + if [ $eval -eq 0 ] + then + # If database is provided + if [ -n "$database" ] + then + database="use $database" + else + database="" + fi - mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port < ./dump.bson # # usage: ynh_mongo_dump_db --database=database -# | arg: -d, --database= - The database name to dump +# | arg: -d, --database= - The database name to dump # | ret: the mongodump output # # ynh_mongo_dump_db() { - # Declare an array to define the options of this helper. - local legacy_args=d - local -A args_array=( [d]=database= ) - local database - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=d + local -A args_array=( [d]=database= ) + local database + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - mongodump --quiet --db="$database" --archive + mongodump --quiet --db="$database" --archive } # Create a user @@ -149,49 +149,49 @@ ynh_mongo_dump_db() { # [internal] # # usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name -# | arg: -u, --db_user= - The user name to create -# | arg: -p, --db_pwd= - The password to identify user by -# | arg: -n, --db_name= - Name of the database to grant privilegies +# | arg: -u, --db_user= - The user name to create +# | arg: -p, --db_pwd= - The password to identify user by +# | arg: -n, --db_name= - Name of the database to grant privilegies # # ynh_mongo_create_user() { - # Declare an array to define the options of this helper. - local legacy_args=unp - local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= ) - local db_user - local db_name - local db_pwd - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=unp + local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= ) + local db_user + local db_name + local db_pwd + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - # Create the user and set the user as admin of the db - ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );' + # Create the user and set the user as admin of the db + ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );' - # Add clustermonitoring rights - ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);' + # Add clustermonitoring rights + ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);' } # Check if a mongo database exists # # usage: ynh_mongo_database_exists --database=database -# | arg: -d, --database= - The database for which to check existence +# | arg: -d, --database= - The database for which to check existence # | exit: Return 1 if the database doesn't exist, 0 otherwise # # ynh_mongo_database_exists() { - # Declare an array to define the options of this helper. - local legacy_args=d - local -A args_array=([d]=database=) - local database - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=d + local -A args_array=([d]=database=) + local database + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ] - then - return 1 - else - return 0 - fi + if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ] + then + return 1 + else + return 0 + fi } # Restore a database @@ -199,18 +199,18 @@ ynh_mongo_database_exists() { # example: ynh_mongo_restore_db --database=wekan < ./dump.bson # # usage: ynh_mongo_restore_db --database=database -# | arg: -d, --database= - The database name to restore +# | arg: -d, --database= - The database name to restore # # ynh_mongo_restore_db() { - # Declare an array to define the options of this helper. - local legacy_args=d - local -A args_array=( [d]=database= ) - local database - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=d + local -A args_array=( [d]=database= ) + local database + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - mongorestore --quiet --db="$database" --archive + mongorestore --quiet --db="$database" --archive } # Drop a user @@ -218,97 +218,97 @@ ynh_mongo_restore_db() { # [internal] # # usage: ynh_mongo_drop_user --db_user=user --db_name=name -# | arg: -u, --db_user= - The user to drop -# | arg: -n, --db_name= - Name of the database +# | arg: -u, --db_user= - The user to drop +# | arg: -n, --db_name= - Name of the database # # ynh_mongo_drop_user() { - # Declare an array to define the options of this helper. - local legacy_args=un - local -A args_array=( [u]=db_user= [n]=db_name= ) - local db_user - local db_name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=un + local -A args_array=( [u]=db_user= [n]=db_name= ) + local db_user + local db_name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})' + ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})' } # Create a database, an user and its password. Then store the password in the app's config # # usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd] -# | arg: -u, --db_user= - Owner of the database -# | arg: -n, --db_name= - Name of the database -# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated +# | arg: -u, --db_user= - Owner of the database +# | arg: -n, --db_name= - Name of the database +# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated # # After executing this helper, the password of the created database will be available in $db_pwd # It will also be stored as "mongopwd" into the app settings. # # ynh_mongo_setup_db() { - # Declare an array to define the options of this helper. - local legacy_args=unp - local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= ) - local db_user - local db_name - db_pwd="" - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=unp + local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= ) + local db_user + local db_name + db_pwd="" + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - local new_db_pwd=$(ynh_string_random) # Generate a random password - # If $db_pwd is not provided, use new_db_pwd instead for db_pwd - db_pwd="${db_pwd:-$new_db_pwd}" + local new_db_pwd=$(ynh_string_random) # Generate a random password + # If $db_pwd is not provided, use new_db_pwd instead for db_pwd + db_pwd="${db_pwd:-$new_db_pwd}" - # Create the user and grant access to the database - ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name" + # Create the user and grant access to the database + ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name" - # Store the password in the app's config - ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd + # Store the password in the app's config + ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd } # Remove a database if it exists, and the associated user # # usage: ynh_mongo_remove_db --db_user=user --db_name=name -# | arg: -u, --db_user= - Owner of the database -# | arg: -n, --db_name= - Name of the database +# | arg: -u, --db_user= - Owner of the database +# | arg: -n, --db_name= - Name of the database # # ynh_mongo_remove_db() { - # Declare an array to define the options of this helper. - local legacy_args=un - local -A args_array=( [u]=db_user= [n]=db_name= ) - local db_user - local db_name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=un + local -A args_array=( [u]=db_user= [n]=db_name= ) + local db_user + local db_name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists - ynh_mongo_drop_db --database=$db_name # Remove the database - else - ynh_print_warn --message="Database $db_name not found" - fi + if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists + ynh_mongo_drop_db --database=$db_name # Remove the database + else + ynh_print_warn --message="Database $db_name not found" + fi - # Remove mongo user if it exists - ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name + # Remove mongo user if it exists + ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name } # Install MongoDB and integrate MongoDB service in YunoHost # # usage: ynh_install_mongo [--mongo_version=mongo_version] -# | arg: -m, --mongo_version= - Version of MongoDB to install +# | arg: -m, --mongo_version= - Version of MongoDB to install # # ynh_install_mongo() { - # Declare an array to define the options of this helper. - local legacy_args=m - local -A args_array=([m]=mongo_version=) - local mongo_version - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - mongo_version="${mongo_version:-$YNH_MONGO_VERSION}" + # Declare an array to define the options of this helper. + local legacy_args=m + local -A args_array=([m]=mongo_version=) + local mongo_version + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + mongo_version="${mongo_version:-$YNH_MONGO_VERSION}" - ynh_print_info --message="Installing MongoDB Community Edition ..." - local mongo_debian_release=$(ynh_get_debian_release) + ynh_print_info --message="Installing MongoDB Community Edition ..." + local mongo_debian_release=$(ynh_get_debian_release) if [[ "$(grep '^flags' /proc/cpuinfo | uniq)" != *"avx"* && "$mongo_version" != "4.4" ]]; then ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)." @@ -319,19 +319,19 @@ ynh_install_mongo() { mongo_debian_release=buster fi - ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc" - mongodb_servicename=mongod + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc" + mongodb_servicename=mongod - # Make sure MongoDB is started and enabled - systemctl enable $mongodb_servicename --quiet - systemctl daemon-reload --quiet - ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$mongodb_servicename.log" + # Make sure MongoDB is started and enabled + systemctl enable $mongodb_servicename --quiet + systemctl daemon-reload --quiet + ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$mongodb_servicename.log" - # Integrate MongoDB service in YunoHost - yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log" + # Integrate MongoDB service in YunoHost + yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log" - # Store mongo_version into the config of this app - ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version + # Store mongo_version into the config of this app + ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version } # Remove MongoDB @@ -342,14 +342,14 @@ ynh_install_mongo() { # # ynh_remove_mongo() { - # Only remove the mongodb service if it is not installed. - if ! ynh_package_is_installed --package="mongodb*" - then - ynh_print_info --message="Removing MongoDB service..." - mongodb_servicename=mongod - # Remove the mongodb service - yunohost service remove $mongodb_servicename - ynh_secure_remove --file="/var/lib/mongodb" - ynh_secure_remove --file="/var/log/mongodb" - fi + # Only remove the mongodb service if it is not installed. + if ! ynh_package_is_installed --package="mongodb*" + then + ynh_print_info --message="Removing MongoDB service..." + mongodb_servicename=mongod + # Remove the mongodb service + yunohost service remove $mongodb_servicename + ynh_secure_remove --file="/var/lib/mongodb" + ynh_secure_remove --file="/var/log/mongodb" + fi } diff --git a/helpers/helpers.v1.d/redis b/helpers/helpers.v1.d/redis index 545bb8705..4adcbe0dc 100644 --- a/helpers/helpers.v1.d/redis +++ b/helpers/helpers.v1.d/redis @@ -5,27 +5,27 @@ # usage: ynh_redis_get_free_db # | returns: the database number to use ynh_redis_get_free_db() { - local result max db - result=$(redis-cli INFO keyspace) + local result max db + result=$(redis-cli INFO keyspace) - # get the num - max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+") + # get the num + max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+") - db=0 - # default Debian setting is 15 databases - for i in $(seq 0 "$max") - do - if ! echo "$result" | grep -q "db$i" - then - db=$i - break 1 - fi - db=-1 - done + db=0 + # default Debian setting is 15 databases + for i in $(seq 0 "$max") + do + if ! echo "$result" | grep -q "db$i" + then + db=$i + break 1 + fi + db=-1 + done - test "$db" -eq -1 && ynh_die --message="No available Redis databases..." + test "$db" -eq -1 && ynh_die --message="No available Redis databases..." - echo "$db" + echo "$db" } # Create a master password and set up global settings @@ -34,6 +34,6 @@ ynh_redis_get_free_db() { # usage: ynh_redis_remove_db database # | arg: database - the database to erase ynh_redis_remove_db() { - local db=$1 - redis-cli -n "$db" flushdb + local db=$1 + redis-cli -n "$db" flushdb } diff --git a/helpers/helpers.v1.d/ruby b/helpers/helpers.v1.d/ruby index 24e4b218b..103534b19 100644 --- a/helpers/helpers.v1.d/ruby +++ b/helpers/helpers.v1.d/ruby @@ -8,8 +8,8 @@ export RBENV_ROOT="$rbenv_install_dir" export rbenv_root="$rbenv_install_dir" if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then - build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool" - build_pkg_dependencies="${build_pkg_dependencies:-} $build_ruby_dependencies" + build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool" + build_pkg_dependencies="${build_pkg_dependencies:-} $build_ruby_dependencies" fi # Load the version of Ruby for an app, and set variables. @@ -275,7 +275,7 @@ ynh_cleanup_ruby () { required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}" fi done - + # Remove no more needed Ruby versions local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/') for installed_ruby_version in $installed_ruby_versions