From fa9e41357f334f52b535067b7db3764fa85f621f Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 7 Sep 2019 14:43:55 +0800 Subject: [PATCH] #8 add management scripts of docker-compose [ci-skip] --- admin/docker/flush.sh | 28 ++++++++++++++++++ admin/docker/start.sh | 15 ++++++++++ admin/docker/stop.sh | 15 ++++++++++ admin/release.sh | 68 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100755 admin/docker/flush.sh create mode 100755 admin/docker/start.sh create mode 100755 admin/docker/stop.sh create mode 100755 admin/release.sh diff --git a/admin/docker/flush.sh b/admin/docker/flush.sh new file mode 100755 index 0000000..67686a9 --- /dev/null +++ b/admin/docker/flush.sh @@ -0,0 +1,28 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +rootDir=$(cd $baseDir/../..;pwd) +SUDO_CMD="" + +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +which sudo +if [ $? -eq 0 ]; then + SUDO_CMD=sudo +fi + +cd $rootDir +echo "[WARN] wait for 10 seconds before clean up all data, be sure of what you are doing ..." +sleep 10 +set -x +docker-compose stop + +$SUDO_CMD rm -rf var/activemq/data/* +$SUDO_CMD rm -rf var/mysql/data/* +$SUDO_CMD rm -rf var/redis/data/* \ No newline at end of file diff --git a/admin/docker/start.sh b/admin/docker/start.sh new file mode 100755 index 0000000..7ee958f --- /dev/null +++ b/admin/docker/start.sh @@ -0,0 +1,15 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +rootDir=$(cd $baseDir/../..;pwd) + +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $rootDir +docker-compose up -d \ No newline at end of file diff --git a/admin/docker/stop.sh b/admin/docker/stop.sh new file mode 100755 index 0000000..7031551 --- /dev/null +++ b/admin/docker/stop.sh @@ -0,0 +1,15 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +rootDir=$(cd $baseDir/../..;pwd) + +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +cd $rootDir +docker-compose down \ No newline at end of file diff --git a/admin/release.sh b/admin/release.sh new file mode 100755 index 0000000..1bc14f4 --- /dev/null +++ b/admin/release.sh @@ -0,0 +1,68 @@ +#! /bin/bash +########################################### +# +########################################### + +# constants +baseDir=$(cd `dirname "$0"`;pwd) +rootDir=$(cd $baseDir/..;pwd) +SUDO_CMD="" +# functions + +# main +[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +which sudo +if [ $? -eq 0 ]; then + SUDO_CMD=sudo +fi + +if [ ! -d $baseDir/../tmp ]; then + mkdir $baseDir/../tmp +fi + +cd $baseDir/.. +GIT_COMMIT_SHORT=`git rev-parse --short HEAD` +relasedir=$baseDir/../tmp/clause.dist.$GIT_COMMIT_SHORT + +cd $baseDir/../tmp +rm -rf $relasedir; mkdir $relasedir + +# copy config file +cp $rootDir/sample.env $relasedir/.env +cp $rootDir/docker-compose.yml $relasedir +cp $rootDir/LICENSE $relasedir +cp $rootDir/README.md $relasedir + +# copy database persistence folders +mkdir $relasedir/var +cp -rf $rootDir/var/activemq $relasedir/var +$SUDO_CMD rm -rf $relasedir/var/activemq/data/* + +cp -rf $rootDir/var/redis $relasedir/var +$SUDO_CMD rm -rf $relasedir/var/redis/data/* + +cp -rf $rootDir/var/mysql $relasedir/var +$SUDO_CMD rm -rf $relasedir/var/mysql/data/* + +# copy clause data folder +mkdir $relasedir/var/local +cp -rf $rootDir/var/local/data $relasedir/var/local/data +mkdir -p $relasedir/var/local/workarea + +# copy clause mysql database init script +mkdir -p $relasedir/src/clause/config +cp -rf $rootDir/src/clause/config/sql $relasedir/src/clause/config + +# copy admin scripts +mkdir $relasedir/admin +cp -rf $rootDir/admin/docker $relasedir/admin + +# init git +cp -rf $rootDir/.gitignore $relasedir +cd $relasedir +git init +git add --all +git commit -m "init" +cd .. + +tar czf clause.dist.$GIT_COMMIT_SHORT.tgz clause.dist.$GIT_COMMIT_SHORT \ No newline at end of file