Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
a3c476ca20 | |||
db7f539bd1 | |||
0c1c0d4788 | |||
53212b705a | |||
453a453f4f | |||
31b5e29c69 | |||
8b10b4b709 | |||
aad26d3fdd | |||
87a453c24c | |||
19eef79c2d |
@ -9,3 +9,10 @@ Select a ssh config file which will be used to connect to a host via - you guess
|
|||||||
```
|
```
|
||||||
|
|
||||||
Sample structure of `start directory` can be found in `test`.
|
Sample structure of `start directory` can be found in `test`.
|
||||||
|
|
||||||
|
## Quickstart
|
||||||
|
```
|
||||||
|
mkdir ~/.s3h
|
||||||
|
touch root@example.org
|
||||||
|
./s3h.sh
|
||||||
|
```
|
||||||
|
@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
|
|
||||||
NAME=s3h
|
NAME=s3h
|
||||||
VERSION=1.2
|
VERSION=`../../s3h.sh -v`
|
||||||
REVISION=1
|
REVISION=1
|
||||||
ARCH=all
|
ARCH=all
|
||||||
|
|
||||||
|
if ! git tag -l |fgrep $VERSION; then
|
||||||
|
git tag $VERSION
|
||||||
|
git push origin $VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
curdir=`dirname $0`
|
curdir=`dirname $0`
|
||||||
workdir="$curdir/${NAME}_${VERSION}-${REVISION}_${ARCH}"
|
workdir="$curdir/${NAME}_${VERSION}-${REVISION}_${ARCH}"
|
||||||
mkdir -p "$workdir"
|
mkdir -p "$workdir"
|
||||||
|
29
s3h.sh
29
s3h.sh
@ -2,12 +2,21 @@
|
|||||||
|
|
||||||
# config
|
# config
|
||||||
DIALOG=dialog #gdialog kdialog
|
DIALOG=dialog #gdialog kdialog
|
||||||
START_DIR='~/.s3h'
|
START_DIR="$HOME/.s3h"
|
||||||
|
VERSION="1.5"
|
||||||
|
|
||||||
|
# TODO: use opt parsing
|
||||||
|
if [[ $# -eq 1 && "$1" == "-v" ]]; then
|
||||||
|
echo "$VERSION"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# -eq 1 && -d "$1" ]]; then
|
if [[ $# -eq 1 && -d "$1" ]]; then
|
||||||
START_DIR="$1"
|
START_DIR="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
START_DIR=`realpath "$START_DIR"`
|
||||||
|
|
||||||
if [[ ! -d "$START_DIR" ]]; then
|
if [[ ! -d "$START_DIR" ]]; then
|
||||||
echo "start directory '$START_DIR' does not exist" >&2
|
echo "start directory '$START_DIR' does not exist" >&2
|
||||||
echo -e "either create or set 'start directory' parameter\n" >&2
|
echo -e "either create or set 'start directory' parameter\n" >&2
|
||||||
@ -38,7 +47,13 @@ while [[ -z "$configFile" ]]; do
|
|||||||
# add file selectors
|
# add file selectors
|
||||||
files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort`
|
files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort`
|
||||||
for d in $files; do
|
for d in $files; do
|
||||||
para+=("$d" "$d")
|
# text before ~ is tag
|
||||||
|
if [[ "$d" == *"~"* ]]; then
|
||||||
|
tag="${d%%~*}"
|
||||||
|
para+=("$d" "$tag")
|
||||||
|
else
|
||||||
|
para+=("$d" "$d")
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${#para[@]} -eq 0 ]]; then
|
if [[ ${#para[@]} -eq 0 ]]; then
|
||||||
@ -52,6 +67,7 @@ while [[ -z "$configFile" ]]; do
|
|||||||
# 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
|
||||||
|
clear
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -88,6 +104,13 @@ if [[ -f "$configFile" ]]; then
|
|||||||
# clear screen // remove dialog colors
|
# clear screen // remove dialog colors
|
||||||
echo "config file '$configFile' selected. connecting..."
|
echo "config file '$configFile' selected. connecting..."
|
||||||
|
|
||||||
|
# extract user@host if ~ in config file name
|
||||||
|
login=`basename "$configFile"`
|
||||||
|
if [[ "$login" == *"~"* ]]; then
|
||||||
|
login="${login#*~}"
|
||||||
|
fi
|
||||||
|
|
||||||
# execute ssh
|
# execute ssh
|
||||||
ssh ${para[@]} `basename "$configFile"`
|
echo "Running 'ssh ${para[@]} $login'"
|
||||||
|
ssh ${para[@]} "$login"
|
||||||
fi
|
fi
|
||||||
|
0
test/blah~foobar@devloop.de
Normal file
0
test/blah~foobar@devloop.de
Normal file
1
test/foo11/.options
Normal file
1
test/foo11/.options
Normal file
@ -0,0 +1 @@
|
|||||||
|
-o AddKeysToAgent=yes
|
Reference in New Issue
Block a user