kopia lustrzana https://github.com/piku/piku
68 wiersze
1.8 KiB
Bash
Executable File
68 wiersze
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# TODO: support config locations:
|
|
# ./.piku-server
|
|
# ~/.piku-server
|
|
# git config --get remote.piku.url
|
|
# git config --get remote.paas.url
|
|
|
|
gitremote=`git config --get remote.piku.url`
|
|
remote=${gitremote:-"${PIKU_SERVER}:${PIKU_APP}"}
|
|
|
|
githome="https://raw.githubusercontent.com/piku/piku/master/"
|
|
|
|
out() { printf "%s\n" "$*" >&2; }
|
|
|
|
if [ "$1" = "init" ]
|
|
then
|
|
[ -f "ENV" ] && echo "ENV file already exists." || ( curl -s "${githome}examples/ENV" > ENV && echo "Wrote ./ENV file." )
|
|
[ -f "Procfile" ] && echo "Procfile already exists." || ( curl -s "${githome}examples/Procfile" > Procfile && echo "Wrote ./Procfile." )
|
|
if [ "$gitremote" = "" ]
|
|
then
|
|
echo "Now set up your piku remote for this app:"
|
|
echo "git remote add piku piku@HOSTNAME:APPNAME"
|
|
fi
|
|
exit
|
|
fi
|
|
|
|
out "Piku remote operator."
|
|
|
|
if [ "$remote" = "" ]
|
|
then
|
|
out
|
|
out "Error: no piku server configured."
|
|
out "Use PIKU_SERVER=piku@MYSERVER.NET or configure a git remote called 'piku'."
|
|
out
|
|
else
|
|
server=`echo "$remote" | cut -f1 -d":" 2>/dev/null`
|
|
app=`echo "$remote" | cut -f2 -d":" 2>/dev/null`
|
|
# gather SSH flags
|
|
while [ "${1#\-}"x != "${1}x" ];
|
|
do
|
|
sshflags="${sshflags} ${1}"
|
|
shift
|
|
done
|
|
# check the Piku command to be run
|
|
cmd="$1"
|
|
out "Server: $server"
|
|
out "App: $app"
|
|
out
|
|
case "$cmd" in
|
|
"")
|
|
ssh -o LogLevel=QUIET ${sshflags} "$server" "$@" | grep -v "INTERNAL"
|
|
echo " shell Local command to start an SSH session in the remote."
|
|
echo " init Local command to download an example ENV and Procfile."
|
|
;;
|
|
apps|setup|setup:ssh|update)
|
|
ssh ${sshflags} "$server" "$@"
|
|
;;
|
|
shell)
|
|
ssh -t "$server" run "$app" bash
|
|
;;
|
|
*)
|
|
shift # remove cmd arg
|
|
ssh ${sshflags} "$server" "$cmd" "$app" "$@"
|
|
;;
|
|
esac
|
|
fi
|