Compare commits
2 Commits
1b91439dfb
...
ac4f568feb
Author | SHA1 | Date | |
---|---|---|---|
|
ac4f568feb | ||
|
aa3382675c |
@ -1,18 +1,41 @@
|
||||
#!/bin/bash -e
|
||||
#!/bin/bash -eE
|
||||
|
||||
exec 100> $HOME/homepage.lock
|
||||
|
||||
flock 100
|
||||
|
||||
log=$(mktemp)
|
||||
|
||||
catch_err () {
|
||||
(
|
||||
echo "An error occured during building"
|
||||
echo ""
|
||||
cat "$log"
|
||||
) >&12
|
||||
}
|
||||
|
||||
catch_exit() {
|
||||
rm -f "$log"
|
||||
}
|
||||
|
||||
trap catch_err ERR
|
||||
trap catch_exit EXIT
|
||||
|
||||
src=/srv/data/tsc-cloud/homepage/hugo-page
|
||||
dst=/srv/http/tsc/hugo
|
||||
prod=/srv/data/tsc-cloud/homepage/production
|
||||
|
||||
if [ -n "$SSH_ORIGINAL_COMMAND" ]
|
||||
then
|
||||
cmd="$SSH_ORIGINAL_COMMAND"
|
||||
else
|
||||
cmd="$@"
|
||||
fi
|
||||
# echo "$cmd"
|
||||
|
||||
publishToStage=
|
||||
publishToProduction=y
|
||||
verboseLogs=n
|
||||
|
||||
branch=develop
|
||||
|
||||
@ -34,6 +57,9 @@ parseCMD() {
|
||||
--debug)
|
||||
set -x
|
||||
;;
|
||||
--verbose|-v)
|
||||
verboseLogs=y
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command $part"
|
||||
exit 1
|
||||
@ -43,6 +69,11 @@ parseCMD() {
|
||||
}
|
||||
parseCMD $cmd
|
||||
|
||||
if [ "$verboseLogs" = "n" ]
|
||||
then
|
||||
exec 11>&1 12>&2 > "$log" 2>&1
|
||||
fi
|
||||
|
||||
doPublishToStage() {
|
||||
rsync -ah --delete --delete-delay public/ "$dst/"
|
||||
}
|
||||
@ -87,13 +118,13 @@ echo "Synchronizing files to web server"
|
||||
if [ -n "$publishToStage" ]
|
||||
then
|
||||
echo "Pushing to stage"
|
||||
time doPublishToStage
|
||||
( time doPublishToStage )
|
||||
fi
|
||||
|
||||
if [ -n "$publishToProduction" ]
|
||||
then
|
||||
echo "Publishing to production server"
|
||||
time doPublishToProduction
|
||||
( time doPublishToProduction )
|
||||
fi
|
||||
|
||||
echo "Deployment done"
|
||||
|
Loading…
Reference in New Issue
Block a user