Helper for running piku.py on configured remote. (#56)

This patch adds a little shell script called `piku`.

What it does is check for a git remote called `piku` and then uses that
remote to infer server & app name and SSH in to run piku.py.

Put it on your path and then from any piku configured local repo you can
do things like: `piku restart` and `piku destroy`.
pull/57/head
Chris McCormick 2019-07-07 19:07:09 +08:00 zatwierdzone przez Rui Carmo
rodzic b5daedb5bc
commit 19b301aaba
1 zmienionych plików z 35 dodań i 0 usunięć

35
piku 100755
Wyświetl plik

@ -0,0 +1,35 @@
#!/bin/sh
# TODO: support config locations:
# ./.piku-server
# ~/.piku-server
# git config --get remote.piku.url
# git config --get remote.paas.url
remote=`git config --get remote.piku.url`
echo "Piku remote operator."
if [ "$remote" = "" ]
then
echo
echo "Error: no piku server configured."
echo "Use PIKU_SERVER=piku@MYSERVER.NET or configure a git remote called 'piku'."
echo
else
server=${PIKU_SERVER:-`echo $remote | cut -f1 -d":" 2>/dev/null`}
app=${PIKU_APP:-`echo $remote | cut -f2 -d":" 2>/dev/null`}
cmd="$1"
echo "Server: $server"
echo "App: $app"
echo
case "$cmd" in
apps|setup|setup:ssh|"")
ssh -A "$server" "$@"
;;
*)
shift # remove cmd arg
ssh -A "$server" "$cmd" "$app" "$@"
;;
esac
fi