Compare commits
2 Commits
04215f8320
...
e2d0f220e4
Author | SHA1 | Date | |
---|---|---|---|
e2d0f220e4 | |||
dad2a0a902 |
31
s3h.sh
31
s3h.sh
@ -8,6 +8,13 @@ if [[ $# -eq 1 && -d "$1" ]]; then
|
|||||||
START_DIR="$1"
|
START_DIR="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$START_DIR" ]]; then
|
||||||
|
echo "start directory '$START_DIR' does not exist" >&2
|
||||||
|
echo -e "either create or set 'start directory' parameter\n" >&2
|
||||||
|
echo "Usage: $0 [start directory]" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
# select config file
|
# select config file
|
||||||
configFile=''
|
configFile=''
|
||||||
while [[ -z "$configFile" ]]; do
|
while [[ -z "$configFile" ]]; do
|
||||||
@ -24,14 +31,24 @@ while [[ -z "$configFile" ]]; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# add directory selectors
|
# add directory selectors
|
||||||
for d in `find $dir -mindepth 1 -maxdepth 1 -type d -printf "%f\n" |sort`; do
|
dirs=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type d -printf "%f\n" |sort`
|
||||||
|
for d in $dirs; do
|
||||||
para+=("$d" "<$d>")
|
para+=("$d" "<$d>")
|
||||||
done
|
done
|
||||||
# add file selectors
|
# add file selectors
|
||||||
for d in `find $dir -mindepth 1 -maxdepth 1 -type f -printf "%f\n" |sort`; do
|
files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort`
|
||||||
|
for d in $files; do
|
||||||
para+=("$d" "$d")
|
para+=("$d" "$d")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ ${#para[@]} -eq 0 ]]; then
|
||||||
|
echo "no file or directory found in '$dir'" >&2
|
||||||
|
echo "either create a connection file like" >&2
|
||||||
|
echo -e "\ttouch '$dir/root@example.org'" >&2
|
||||||
|
echo "or create a group by adding a directory" >&2
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
# run dialog
|
# run dialog
|
||||||
ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1)
|
ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1)
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
@ -53,14 +70,22 @@ done
|
|||||||
|
|
||||||
# read config file and connect
|
# read config file and connect
|
||||||
if [[ -f "$configFile" ]]; then
|
if [[ -f "$configFile" ]]; then
|
||||||
|
clear
|
||||||
# each line equals one config option
|
# each line equals one config option
|
||||||
para=()
|
para=()
|
||||||
while read -r configLine; do
|
while read -r configLine; do
|
||||||
para+=($configLine)
|
para+=($configLine)
|
||||||
done < "$configFile"
|
done < "$configFile"
|
||||||
|
|
||||||
|
# lookup group specific option file
|
||||||
|
if [[ -f "$dir/.options" ]]; then
|
||||||
|
while read -r configLine; do
|
||||||
|
para+=($configLine)
|
||||||
|
done < "$dir/.options"
|
||||||
|
echo "using group options file '$dir/.options'"
|
||||||
|
fi
|
||||||
|
|
||||||
# clear screen // remove dialog colors
|
# clear screen // remove dialog colors
|
||||||
clear
|
|
||||||
echo "config file '$configFile' selected. connecting..."
|
echo "config file '$configFile' selected. connecting..."
|
||||||
|
|
||||||
# execute ssh
|
# execute ssh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user