mirror of
https://github.com/coderofsalvation/podi.git
synced 2026-05-18 05:04:56 +02:00
work in progress [might break]
This commit is contained in:
32
recipe/envfile
Normal file
32
recipe/envfile
Normal file
@@ -0,0 +1,32 @@
|
||||
# installation : run 'podmen recipe env-file' or put this file into .podman folder
|
||||
# example usage: * put an .env file in your repo (with 'export FOO=1' e.g.)
|
||||
# * override them on remote-server using './podmen .env git@server FOO=2'
|
||||
# * run './podmen .env' to see all local/remote env-vars
|
||||
|
||||
recipe_envfile(){
|
||||
trigger recipe:envfile
|
||||
test -f .env && print "reading '.env'" && . .env
|
||||
test -f .env.live && print "override '.env' << .env.live" && . .env.live
|
||||
print PORT=$PORT
|
||||
}
|
||||
|
||||
envset(){ # envset [remote] [FOO=bar] : shows or sets [remote] environment variables
|
||||
test -f .env || echo 'export FOO=bar # used for development' > .env
|
||||
test -z $1 && {
|
||||
test -f .env || echo 'export PORT=1234' > .env; print .env; echo; cat .env; echo;
|
||||
for i in .podmen/*@*; do $0 envset $(basename $i); echo; done
|
||||
exit 0;
|
||||
}
|
||||
loadremote $1
|
||||
if ! test -z "$2"; then
|
||||
printf "export %-40s # $(date)\n" "$2\"" | awk '{ gsub("=","=\"",$0); print $0; }' | ssh -p $port $1 "cat >> $gitpath/.env.live"
|
||||
print OK
|
||||
else
|
||||
print $1:$gitpath/.env.live:
|
||||
echo
|
||||
test -z $2 && ssh -p $port $1 "test -f $gitpath/.env.live && cat $gitpath/.env.live || echo no env-vars yet"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
on start recipe_envfile
|
||||
10
recipe/hello
Normal file
10
recipe/hello
Normal file
@@ -0,0 +1,10 @@
|
||||
# a barebones recipe
|
||||
|
||||
hello(){ echo ' \o/ hello' ; }
|
||||
world(){ echo ' world' ; }
|
||||
|
||||
mycmd(){ # mycmd [myopt] : simple example cmd
|
||||
echo "howdy! $1"
|
||||
}
|
||||
|
||||
on hello world
|
||||
17
recipe/rollback.simple
Normal file
17
recipe/rollback.simple
Normal file
@@ -0,0 +1,17 @@
|
||||
# installation : run 'podmen recipe rollback.simple' or put this file into .podman folder
|
||||
# example usage: ./podman rollback git@server 3fe2f615
|
||||
|
||||
on_extract(){
|
||||
test -z $PM_ROLLBACK && trigger checkout || trigger do_rollback
|
||||
}
|
||||
|
||||
do_rollback(){
|
||||
print to rollback run: ./podmen rollback $PM_REMOTE $PM_COMMIT
|
||||
git reset $2 --hard
|
||||
}
|
||||
|
||||
rollback(){ # rollback <remote> <commit> : rolls back deployment to certain commit
|
||||
loadremote $1
|
||||
scp -P $port $0 $user@$server:/tmp/. 1>/dev/null
|
||||
ssh -p $port $user@$server "export HOST=$user@$server; export PM_ROLLBACK=1; cd $gitpath; ./podmen deploy"
|
||||
}
|
||||
14
recipe/sshkey
Normal file
14
recipe/sshkey
Normal file
@@ -0,0 +1,14 @@
|
||||
# installation : run 'podmen recipe sshkey' or put this file into .podman folder
|
||||
# example usage: ./podman init git@yourserver
|
||||
|
||||
on_init_server(){
|
||||
trigger init_server:sshkey
|
||||
local key=~/.ssh/id_rsa_${PM_APP}
|
||||
test -f $key && {
|
||||
ssh-keygen -t rsa -N "" -f $key
|
||||
ssh-key-copy -p $PM_PORT -i $key $PM_USER@$PM_SERVER
|
||||
}
|
||||
print "Yay! now:"
|
||||
print " 1. commit changes and type: 'git push $PM_SERVER $PM_BRANCH'"
|
||||
print " 2. share key '~/.ssh/id_rsa_$PM_APP' to collaborate with devs "
|
||||
}
|
||||
Reference in New Issue
Block a user