-
-
Save nordringrayhide/8206680 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[core] | |
... | |
[remote "dokku"] | |
url = git@remote:appname | |
fetch = +refs/heads/*:refs/remotes/dokku/* |
This file contains hidden or 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
# Looks for the git remote "dokku" and runs dokku command via SSH | |
# Assumes user is root and no password is needed | |
# Example: | |
# dokku logs --> ssh root@remote 'dokku logs appname' | |
dokku() { | |
if [ -f ".git/config" ]; then | |
config=$(cat .git/config) | |
if [[ "$config" == *'[remote "dokku"]'* ]]; then | |
host=$(echo $config | sed 's/.*\[remote "dokku"\][[:space:]]*url[[:space:]]*=[[:space:]]git@\([a-z.0-9\-]*\):\([a-z.0-9\-\_]*\).*/\1/') | |
app=$(echo $config | sed 's/.*\[remote "dokku"\][[:space:]]*url[[:space:]]*=[[:space:]]git@\([a-z.0-9\-]*\):\([a-z.0-9\-\_]*\).*/\2/') | |
dokku_command="$1" | |
if [ "$dokku_command" == "logs" ]; then | |
eval "ssh root@$host 'dokku logs $app'" | |
elif [ "$dokku_command" == "run" ]; then | |
shift 1 | |
eval "ssh root@$host 'dokku run $app $@'" | |
elif [ "$dokku_command" == "url" ]; then | |
eval "ssh root@$host 'dokku url $app'" | |
else | |
echo " Host: $host App: $app" | |
echo "Usage:" | |
echo " dokku logs Show the last logs for the application" | |
echo " dokku run <cmd> Run a command in the environment of the application" | |
echo " dokku url Show the URL for the application" | |
fi | |
else | |
echo 'Could not find a git remote named "dokku".' | |
fi | |
else | |
echo "Not a git repository." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment