bitreich-drist

fork of bitreich.org/drist
git clone git://git.pyratebeard.net/bitreich-drist.git
Log | Files | Refs | README | LICENSE

commit 5dc65972c62ddd2b7ba962af007ad44a41bbe400
parent 597c9a998cc850a353896336ed08346afb6c6c91
Author: Solene Rapenne <solene@perso.pw>
Date:   Mon, 15 Jun 2020 13:10:57 +0200

Add a -d flag to use short hostnames. Patch from Molly Miller

Diffstat:
Mdrist | 10++++++++--
Mdrist.1 | 8+++++++-
2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drist b/drist @@ -5,15 +5,17 @@ SUDO=0 SUDO_BIN=sudo EXEC="" SSHONCE=0 +TRUNCATE=0 usage() { - echo "$0 [-n] [-s [-e sudo|doas]] server" + echo "$0 [-n] [-d] [-s [-e sudo|doas]] server" exit 0 } -while getopts pnse: arg; do +while getopts pndse: arg; do case ${arg} in n) SIMULATE=1 ;; + d) TRUNCATE=1 ;; s) SUDO=1 ;; e) SUDO_BIN="${OPTARG}" ;; p) SSHONCE=1 ;; @@ -43,6 +45,10 @@ else echo "Error while ssh ${1}" exit 2 fi + + if [ "$TRUNCATE" -eq 1 ]; then + HOSTNAME="${HOSTNAME%%.*}" + fi fi # $1 = directory name diff --git a/drist.1 b/drist.1 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: July 17 2018 $ +.Dd $Mdocdate: April 27 2020 $ .Dt DRIST 1 .Os .Sh NAME @@ -8,6 +8,7 @@ .Nm .Op Fl p .Op Fl n +.Op Fl d .Op Fl s Op Fl e Ar sudo|doas .Ar server .Sh OPTIONS @@ -22,6 +23,11 @@ Tells .Nm to show what will happens if it runs. This will make a ssh connection to check the remote hostname. +.Op Fl d +to truncate reported hostname. +Tells +.Nm +to truncate the reported remote hostname to the left-most component. .Op Fl s use a program to execute a command as root on the remote server. Default is sudo.