Created
July 25, 2021 08:37
-
-
Save fmtarif/ca6bf3cb5c716faabd4d45238bcaa324 to your computer and use it in GitHub Desktop.
#scripts #cli #devops a local script to keep within project dir in git and run ssh cmds remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
DIR="$( dirname "$_" )" | |
DIR=${DIR/\./} #if script invoked like ./index then remove the dot | |
commands=("sshprod", "sshproddeploy") | |
echo ${commands[@]} | |
show_commands() { | |
echo 'Available commands: | |
sshprod | |
sshproddeploy | |
' | |
} | |
#if [ ${commands[@]} | grep -o "sshproddeploys" | wc -w ]; then | |
#echo 'yes' | |
#else | |
#echo 'no' | |
#fi | |
if [ $# -gt 0 ]; then | |
if [ "$1" == "sshprod" ]; then | |
shift 1 | |
ssh "$@" -F $DIR/sshconfig prod | |
fi | |
if [ "$1" == "sshproddeploy" ]; then | |
shift 1 | |
ssh "$@" -F $DIR/sshconfig prod -t "cd /project/path && git pull" | |
fi | |
else | |
show_commandsode | |
fi | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host prod | |
Hostname actual_host_here | |
StrictHostKeyChecking no | |
User username_here | |
Port 22 | |
CheckHostIP no | |
IdentityFile ./id_rsa_itc_dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment