huge longrun improvements
This commit is contained in:
@@ -36,17 +36,42 @@
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Remove host from know_host (name and IP) for the active user
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage: rmhost <hostname|ip> [hostname2|ip2 [...]]
|
||||
rmhost()
|
||||
{
|
||||
if [[ "$#" -lt 1 ]]; then
|
||||
disp E "Incorrect number of parameters."
|
||||
disp E "Usage: rmhost <hostname|ip> [hostname2|ip2 [...]]"
|
||||
local PARSED
|
||||
PARSED=$(getopt -o h --long help -n 'rmhost' -- "$@")
|
||||
if [[ $? -ne 0 ]]; then return 1; fi
|
||||
eval set -- "$PARSED"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
printf "rmhost: Remove host/IP from ~/.ssh/known_hosts.\n\n"
|
||||
printf "Usage: rmhost <hostname|ip> [hostname2|ip2 ...]\n\n"
|
||||
printf "Options:\n"
|
||||
printf " -h, --help Display this help screen\n"
|
||||
return 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
disp E "Invalid options, use \"rmhost --help\" to display usage."
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validation: Ensure at least one argument remains
|
||||
if [[ $# -eq 0 ]]; then
|
||||
disp E "Missing argument. Use 'rmhost --help' for usage."
|
||||
return 1
|
||||
fi
|
||||
|
||||
while [[ $1 ]]; do
|
||||
local hst=$1 && shift
|
||||
for target in "$@"; do
|
||||
local hst=$target
|
||||
isipv4 "$hst" >/dev/null
|
||||
local v4=$?
|
||||
isipv6 "$hst" >/dev/null
|
||||
@@ -81,20 +106,36 @@ rmhost()
|
||||
done
|
||||
}
|
||||
export -f rmhost
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Login root via SSH on the given machine
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage: ssr <server [ssh options]>
|
||||
ssr()
|
||||
{
|
||||
for opt in $@; do
|
||||
case $opt in
|
||||
"-h" | "--help")
|
||||
echo "ssr: do a root user ssh login."
|
||||
echo
|
||||
echo "Usage: ssr <server [ssh options]>"
|
||||
return 0
|
||||
;;
|
||||
local PARSED
|
||||
PARSED=$(getopt -o h --long help -n 'ssr' -- "$@")
|
||||
if [[ $? -ne 0 ]]; then return 1; fi
|
||||
eval set -- "$PARSED"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
printf "ssr: SSH into a server as root.\n\n"
|
||||
printf "Usage: ssr <server> [ssh_options...]\n\n"
|
||||
printf "Options:\n"
|
||||
printf "\t-h, --help\t\tDisplay this help screen\n"
|
||||
return 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
disp E "Invalid options, use \"ssr --help\" to display usage."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -102,15 +143,17 @@ ssr()
|
||||
disp E "ssh is not installed."
|
||||
return 127
|
||||
}
|
||||
[[ ! $1 ]] &&
|
||||
disp E "Please specify the server you want to log in." &&
|
||||
[[ ! $1 ]] && {
|
||||
disp E "Please specify the server you want to log in."
|
||||
return 1
|
||||
}
|
||||
|
||||
local srv=$1 && shift
|
||||
|
||||
ssh -Y root@"$srv" "$@"
|
||||
}
|
||||
export -f ssr
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# EOF
|
||||
|
||||
Reference in New Issue
Block a user