From ad9e8702c8acc412822f6209103669c431f83a75 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 29 Jan 2025 09:40:27 +0530 Subject: [PATCH] style(upstall): lint --- docker-compose/1_Auto_Upstall/noco.sh | 361 +++++++++++++------------- 1 file changed, 176 insertions(+), 185 deletions(-) diff --git a/docker-compose/1_Auto_Upstall/noco.sh b/docker-compose/1_Auto_Upstall/noco.sh index a6c2cd6516..aca7b1700f 100755 --- a/docker-compose/1_Auto_Upstall/noco.sh +++ b/docker-compose/1_Auto_Upstall/noco.sh @@ -49,19 +49,17 @@ print_success() { print_color "$GREEN" "SUCCESS: $1"; } print_warning() { print_color "$YELLOW" "WARNING: $1"; } print_error() { print_color "$RED" "ERROR: $1"; } -die() -{ +die() { : "${1:?}" - command -v notify-send > /dev/null && + command -v notify-send >/dev/null && notify-send "upstall" "$1" printf "\033[31;1merr: %b\033[0m\n" "$1" exit "${2:-1}" } -trim() -{ +trim() { : "${1:?}" _trimstr="${1#"${1%%[![:space:]]*}"}" @@ -70,8 +68,7 @@ trim() echo "$_trimstr" } -kvstore_get() -{ +kvstore_get() { # usage kvstore_get [ getval ] line= _key= @@ -79,15 +76,14 @@ kvstore_get() [ -s "$state_file" ] || return 1 - while read -r line - do + while read -r line; do [ -z "$line" ] && continue _key="${line%%"$state_dlim"*}" _key="$(trim "$_key")" case "$_key" in - \#*) continue + \#*) continue ;; esac if [ "$1" = "getval" ]; then @@ -100,14 +96,13 @@ kvstore_get() else echo "$_key" fi - done < "$state_file" + done <"$state_file" unset _key _value [ "$1" = "getval" ] && return 1 } -kvstore_rm() -{ +kvstore_rm() { # usage kvstore_rm : "${1:?}" cl= @@ -116,8 +111,7 @@ kvstore_rm() old_ifs="$IFS" IFS= - while read -r line - do + while read -r line; do cl="$line\n" key="$(trim "${cl%%"$state_dlim"*}")" @@ -127,25 +121,23 @@ kvstore_rm() fi file="${file}${cl}" - done < "$state_file" + done <"$state_file" IFS="$old_ifs" # shellcheck disable=SC2059 - printf "$file" > "$state_file" + printf "$file" >"$state_file" unset cl line file value old_ifs } -kvstore_valverify() -{ +kvstore_valverify() { # kvstore_valverify case "$1" in - *"\n"*|*$state_dlim*) return 1 ;; + *"\n"* | *$state_dlim*) return 1 ;; esac } -kvstore_set() -{ +kvstore_set() { # kvstore_set : "${1:?}" : "${2:?}" @@ -154,12 +146,12 @@ kvstore_set() key="$(trim "$key")" val="$(trim "$2")" - kvstore_get getval "$key" > /dev/null && + kvstore_get getval "$key" >/dev/null && die "keys must be unique" kvstore_valverify "$val" || die "invalid: $val" - echo "${key:?} $state_dlim $val" >> "$state_file" + echo "${key:?} $state_dlim $val" >>"$state_file" } print_box_message() { @@ -209,7 +201,7 @@ urlencode() { generate_password() { if ! pass="$(kvstore_get getval generated_password)"; then - pass="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 32)" + pass="$(tr -dc A-Za-z0-9 /dev/null 2>&1; then + if ! $CONFIG_DOCKER_COMMAND stop "$container" >/dev/null 2>&1; then print_error "Failed to stop ${container}" exit 1 fi @@ -563,8 +555,7 @@ check_existing_installation() { # add more state handling in the future, if we want that # so we do not have carry arround backward compatibility ifs - kvstore_get getval state_version > /dev/null || kvstore_set state_version 1 - + kvstore_get getval state_version >/dev/null || kvstore_set state_version 1 # Check if nocodb is already installed if [ "$NOCO_FOUND" = true ]; then @@ -616,156 +607,156 @@ check_system_requirements() { } get_user_inputs() { - # For fixing test failures due to missing XTerm environment - clear || : - cat << EOF + # For fixing test failures due to missing XTerm environment + clear || : + cat <>"$compose_file" <>"$compose_file" <>"$compose_file" <>"$compose_file" <>"$compose_file" <