Skip to content

Commit

Permalink
list-rods-logs: switched to tab indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tedgin committed Feb 12, 2021
1 parent 7848d4a commit 5485e40
Showing 1 changed file with 70 additions and 70 deletions.
140 changes: 70 additions & 70 deletions list-rods-logs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

show_help() {
cat <<EOF
cat <<EOF
$ExecName version $Version
Expand Down Expand Up @@ -35,94 +35,94 @@ readonly LogDir=/var/lib/irods/iRODS/server/log


main() {
local opts
if ! opts=$(format_opts "$@")
then
show_help >&2
return 1
fi

eval set -- "$opts"

local password=
local namePattern='*'

while true
do
case "$1" in
-h|--help)
show_help
return 0
;;
-N|--name-pattern)
namePattern="$2"
shift 2
;;
-P|--password)
password="$2"
shift 2
;;
-v|--version)
show_version
return 0
;;
--)
shift
break
;;
*)
show_help >&2
return 1
;;
esac
done

if [[ "$#" -lt 1 ]]
then
show_help >&2
return 1
fi

local host="$1"

list_logs "$host" "$password" "$namePattern" | sort
local opts
if ! opts=$(format_opts "$@")
then
show_help >&2
return 1
fi

eval set -- "$opts"

local password=
local namePattern='*'

while true
do
case "$1" in
-h|--help)
show_help
return 0
;;
-N|--name-pattern)
namePattern="$2"
shift 2
;;
-P|--password)
password="$2"
shift 2
;;
-v|--version)
show_version
return 0
;;
--)
shift
break
;;
*)
show_help >&2
return 1
;;
esac
done

if [[ "$#" -lt 1 ]]
then
show_help >&2
return 1
fi

local host="$1"

list_logs "$host" "$password" "$namePattern" | sort
}


format_opts() {
getopt \
--longoptions help,name-pattern:,password:,version \
--options hN:P:v \
--name "$ExecName" \
-- "$@"
getopt \
--longoptions help,name-pattern:,password:,version \
--options hN:P:v \
--name "$ExecName" \
-- "$@"
}


show_version() {
printf '%s\n' "$Version"
printf '%s\n' "$Version"
}


list_logs() {
local host="$1"
local password="$2"
local namePattern="$3"

#shellcheck disable=SC2087
mk_list_logs_script "$password" "$namePattern" \
| ssh -q -t "$host" 2> /dev/null \
| sed --quiet '/^\//p'
local host="$1"
local password="$2"
local namePattern="$3"

#shellcheck disable=SC2087
mk_list_logs_script "$password" "$namePattern" \
| ssh -q -t "$host" 2> /dev/null \
| sed --quiet '/^\//p'
}


mk_list_logs_script() {
local password="$1"
local namePattern="$2"
local password="$1"
local namePattern="$2"

cat <<EOF
cat <<EOF
if ! find "$LogDir" -maxdepth 1 -name "$namePattern" -type f 2> /dev/null
then
printf '%s\n' "$password" | sudo -S find "$LogDir" -maxdepth 1 -name "$namePattern" -type f
printf '%s\n' "$password" | sudo -S find "$LogDir" -maxdepth 1 -name "$namePattern" -type f
fi
EOF
}
Expand Down

0 comments on commit 5485e40

Please sign in to comment.