diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2a025ca..9bf8c06 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -3,49 +3,24 @@ name: Test
on: push
jobs:
- test-macos:
+ test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- os: [macos-latest]
+ os: [macos-latest, ubuntu-latest]
+ test_script: [
+ mongodb-4.4.10.sh,
+ mongodb-5.0.3.sh,
+ mysql-5.7.31.sh,
+ mysql-8.0.30.sh,
+ postgresql-12.4.sh,
+ postgresql-13.2.sh,
+ redis-6.0.16.sh,
+ redis-6.2.6.sh
+ ]
steps:
- uses: actions/checkout@v3
- - name: Run mongodb test
+ - name: Run test
run: |
cd tests
- /bin/bash mongodb-test.sh
- - name: Run mysql test
- run: |
- cd tests
- /bin/bash mysql-test.sh
- - name: Run postgresql test
- run: |
- cd tests
- /bin/bash postgresql-test.sh
- - name: Run redis test
- run: |
- cd tests
- /bin/bash redis-test.sh
- test-ubuntu:
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [ubuntu-latest]
- steps:
- - uses: actions/checkout@v3
- - name: Run mongodb test
- run: |
- cd tests
- /bin/bash mongodb-test.sh
- - name: Run mysql test
- run: |
- cd tests
- /bin/bash mysql-test.sh
- - name: Run postgresql test
- run: |
- cd tests
- /bin/bash postgresql-test.sh
- - name: Run redis test
- run: |
- cd tests
- /bin/bash redis-test.sh
+ /bin/bash ${{ matrix.test_script }}
diff --git a/README.md b/README.md
index eb26423..03ad8f5 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,8 @@ git clone https://github.com/pj8/dbdb.git
cd dbdb
```
+MySQL
+
## MySQL
### Manage MySQL Server on localhost
@@ -53,7 +55,9 @@ cd dbdb
- 8.0.23
- 8.0.30
----
+
+
+PostgreSQL
## PostgreSQL
@@ -79,7 +83,9 @@ cd dbdb
- 12.6
- 13.2
----
+
+
+Redis
## Redis
@@ -105,7 +111,9 @@ cd dbdb
- 6.0.16
- 6.2.6
----
+
+
+MongoDB
## MongoDB
@@ -130,7 +138,7 @@ cd dbdb
- 4.4.10
- 5.0.3
----
+
## Tips
@@ -149,7 +157,7 @@ cd dbdb
### Start by creating the database server if it does not exist.
```
-# Try create, then start server.
+# Create and start
/path/to/dbdb/mysql/create-start.sh mysql5-foo 5.7.31 3306
```
@@ -158,19 +166,7 @@ cd dbdb
- You can use `dbdb.sh` for that.
```
-/path/to/dbdb/dbdb.sh
-
-mongodb.4.4.3.mongo4 is stopped.
-/path/to/dbdb/mongodb/start.sh mongo4
-/path/to/dbdb/mongodb/stop.sh mongo4
-/path/to/dbdb/mongodb/restart.sh mongo4
-
-mysql.5.7.31.mysql5-foo is running.
-/path/to/dbdb/mysql/start.sh mysql5-foo
-/path/to/dbdb/mysql/stop.sh mysql5-foo
-/path/to/dbdb/mysql/restart.sh mysql5-foo
-
-...
+./dbdb.sh
```
### How to start a database server when my server booted?
@@ -184,6 +180,6 @@ mysql.5.7.31.mysql5-foo is running.
# Start mysql8 with port 13306
@reboot /path/to/dbdb/mysql/start.sh mysql8-bar
-# Try create, then start the server
+# Create and start
@reboot /path/to/dbdb/redis/create-start.sh redis1 6.0.10 6379
```
diff --git a/dbdb.sh b/dbdb.sh
index c9dfa68..b41948c 100755
--- a/dbdb.sh
+++ b/dbdb.sh
@@ -1,6 +1,15 @@
#!/bin/bash
set -eu
+getInstallDir() {
+ suffix=dbdb
+ if [ -z "${XDG_DATA_HOME+x}" ]; then
+ echo "$HOME/.local/share/$suffix"
+ else
+ echo "$XDG_DATA_HOME/$suffix"
+ fi
+}
+
# Get format option
format=""
while getopts ":f:" opt; do
@@ -25,34 +34,34 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
-# Get current directory
currentDir="$(
cd "$(dirname "$0")" >/dev/null 2>&1
pwd -P
)"
cd "$currentDir"
+installDir=$(getInstallDir)
normalOutputs=""
jsonOutputs=""
dbTypes=(mongodb mysql postgresql redis)
for dbType in "${dbTypes[@]}"; do
- for dbVersion in $(ls "$currentDir/$dbType/versions" 2>/dev/null); do
- if [ -d "$currentDir/$dbType/versions/$dbVersion" ]; then
- for dbServerName in $(ls "$currentDir/$dbType/versions/$dbVersion/datadir" 2>/dev/null); do
- if [ -d "$currentDir/$dbType/versions/$dbVersion/basedir" ]; then
- if [ -d "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName" ]; then
+ for dbVersion in $(ls "$installDir/$dbType/versions" 2>/dev/null); do
+ if [ -d "$installDir/$dbType/versions/$dbVersion" ]; then
+ for dbServerName in $(ls "$installDir/$dbType/versions/$dbVersion/datadir" 2>/dev/null); do
+ if [ -d "$installDir/$dbType/versions/$dbVersion/basedir" ]; then
+ if [ -d "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName" ]; then
# port
dbPort="{port}"
- if [ -f "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port" ]; then
- dbPort=$(cat "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port")
- elif [ -f "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.last" ]; then
- dbPort=$(cat "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.last")
- elif [ -f "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.init" ]; then
- dbPort=$(cat "$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.init")
+ if [ -f "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port" ]; then
+ dbPort=$(cat "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port")
+ elif [ -f "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.last" ]; then
+ dbPort=$(cat "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.last")
+ elif [ -f "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.init" ]; then
+ dbPort=$(cat "$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.port.init")
fi
# pid
- pidFile="$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.pid"
+ pidFile="$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$dbType.pid"
# status
if [ -f "$pidFile" ] && pgrep -F "$pidFile" >/dev/null; then
@@ -87,7 +96,17 @@ for dbType in "${dbTypes[@]}"; do
# jsonOutputs
availableCommands='["start.sh", "stop.sh", "restart.sh", "port.sh", "status.sh", "connect.sh", "delete.sh"]'
- jsonOutputs="$jsonOutputs{\"name\": \"$dbServerName\", \"type\": \"$dbType\", \"version\": \"$dbVersion\", \"port\": \"$dbPort\", \"status\": \"$status\", \"commandPath\": \"$currentDir/$dbType/\", \"availableCommands\": $availableCommands, \"dataDir\": \"$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName\", \"confPath\": \"$currentDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$confName\"},"
+ jsonOutputs="$jsonOutputs{
+ \"name\": \"$dbServerName\",
+ \"type\": \"$dbType\",
+ \"version\": \"$dbVersion\",
+ \"port\": \"$dbPort\",
+ \"status\": \"$status\",
+ \"commandPath\": \"$currentDir/$dbType/\",
+ \"availableCommands\": $availableCommands,
+ \"dataDir\": \"$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName\",
+ \"confPath\": \"$installDir/$dbType/versions/$dbVersion/datadir/$dbServerName/$confName\"
+ },"
fi
fi
done
diff --git a/lib/functions.sh b/lib/functions.sh
index 07577f9..ce24358 100755
--- a/lib/functions.sh
+++ b/lib/functions.sh
@@ -76,52 +76,52 @@ getUrlFileAs() {
extractFile() {
if [ ! -d $1/basedir ]; then
- echo "Extracting... $2" 1>&2
+ echo "Extracting..." 1>&2
mkdir -p $1/basedir
cd $1/basedir
- cp ../../../$2.tar.gz .
+ cp $1/$2.tar.gz .
tar zxf $2.tar.gz --strip-components 1
rm -f $2.tar.gz
fi
}
getCommands() {
- currentDir=$(getCurrentDir)
+ type=$(getType)
format="${4:-}"
if [ "$format" = "json" ]; then
jsonOutputs="{
- \"start\": \"$currentDir/start.sh $1\",
- \"stop\": \"$currentDir/stop.sh $1\",
- \"restart\": \"$currentDir/restart.sh $1\",
- \"port\": \"$currentDir/port.sh $1\",
- \"status\": \"$currentDir/status.sh $1\",
- \"connect\": \"$currentDir/connect.sh $1\",
- \"delete\": \"$currentDir/delete.sh $1\"
+ \"start\": \"./$type/start.sh $1\",
+ \"stop\": \"./$type/stop.sh $1\",
+ \"restart\": \"./$type/restart.sh $1\",
+ \"port\": \"./$type/port.sh $1\",
+ \"status\": \"./$type/status.sh $1\",
+ \"connect\": \"./$type/connect.sh $1\",
+ \"delete\": \"./$type/delete.sh $1\"
}"
echo -e $jsonOutputs
else
echo ""
echo "# Start"
- echo "$currentDir/start.sh $1"
+ echo "./$type/start.sh $1"
echo ""
echo "# Stop"
- echo "$currentDir/stop.sh $1"
+ echo "./$type/stop.sh $1"
echo ""
echo "# Restart"
- echo "$currentDir/restart.sh $1"
+ echo "./$type/restart.sh $1"
echo ""
echo "# Port"
- echo "$currentDir/port.sh $1"
+ echo "./$type/port.sh $1"
echo ""
echo "# Status"
- echo "$currentDir/status.sh $1"
+ echo "./$type/status.sh $1"
echo ""
echo "# Connect"
- echo "$currentDir/connect.sh $1"
+ echo "./$type/connect.sh $1"
echo ""
echo "# Delete"
- echo "$currentDir/delete.sh $1"
+ echo "./$type/delete.sh $1"
echo ""
fi
@@ -138,21 +138,21 @@ getRandomPort() {
# if $1 name is duplicated in this datastore, exit(1)
exitIfDuplicatedName() {
name=$1
- currentDir=$(getCurrentDir)
- found=$(find "$currentDir" -type d -name "$name" | wc -l | tr -d '[:space:]')
+ installDir=$(getInstallDir $(getType))
+ found=$(find "$installDir" -type d -name "$name" | wc -l | tr -d '[:space:]')
if [ "$found" = "0" ]; then
:
else
echo "The name '$name' is already in use." 1>&2
- #find "$currentDir" -type d -name "$name" | grep -E "datadir/$name$" 1>&2
+ #find "$installDir" -type d -name "$name" | grep -E "datadir/$name$" 1>&2
exit 1
fi
}
exitIfNotExistVersion() {
name=$1
- currentDir=$(getCurrentDir)
- version=$(find "$currentDir" -type d -name "$name" | grep -E "datadir/$name$" | awk -F "/datadir/" '{print $1}' | awk -F "/versions/" '{print $2}')
+ installDir=$(getInstallDir $(getType))
+ version=$(find "$installDir" -type d -name "$name" | grep -E "datadir/$name$" | awk -F "/datadir/" '{print $1}' | awk -F "/versions/" '{print $2}')
if [ "$version" = "" ]; then
echo "There is no version for the given '$name'." 1>&2
exit 1
@@ -161,36 +161,46 @@ exitIfNotExistVersion() {
getVersionByName() {
name=$1
- currentDir=$(getCurrentDir)
- version=$(find "$currentDir" -type d -name "$name" | grep -E "datadir/$name$" | awk -F "/datadir/" '{print $1}' | awk -F "/versions/" '{print $2}')
+ installDir=$(getInstallDir $(getType))
+ version=$(find "$installDir" -type d -name "$name" | grep -E "datadir/$name$" | awk -F "/datadir/" '{print $1}' | awk -F "/versions/" '{print $2}')
echo "$version"
}
exitIfNotExistPortFile() {
name=$1
version=$2
- currentDir=$(getCurrentDir)
- portFiles=$(find "$currentDir/versions/$version" -type f -name "*.port*" | grep -E "/datadir/$name/" || true)
+ installDir=$(getInstallDir $(getType))
+ portFiles=$(find "$installDir/versions/$version" -type f -name "*.port*" | grep -E "/datadir/$name/" || true)
if [ "$portFiles" = "" ]; then
echo "There are no port files for the given '$name'." 1>&2
exit 1
fi
}
-getService() {
- service=$(basename $(getCurrentDir))
- echo "$service"
+getType() {
+ if [[ "$(getCurrentDir)" == *"/dbdb/mongodb"* ]]; then
+ echo "mongodb"
+ elif [[ "$(getCurrentDir)" == *"/dbdb/mysql"* ]]; then
+ echo "mysql"
+ elif [[ "$(getCurrentDir)" == *"/dbdb/postgresql"* ]]; then
+ echo "postgresql"
+ elif [[ "$(getCurrentDir)" == *"/dbdb/redis"* ]]; then
+ echo "redis"
+ else
+ echo "unknown database type" 1>&2
+ exit 1
+ fi
}
getPortByName() {
- service=$(getService)
+ type=$(getType)
name=$1
version=$2
- currentDir=$(getCurrentDir)
+ installDir=$(getInstallDir $(getType))
- runningPort=$(cat "$currentDir/versions/$version/datadir/$name/$service.port" 2>/dev/null || true)
- lastPort=$(cat "$currentDir/versions/$version/datadir/$name/$service.port.last" 2>/dev/null || true)
- initPort=$(cat "$currentDir/versions/$version/datadir/$name/$service.port.init" 2>/dev/null || true)
+ runningPort=$(cat "$installDir/versions/$version/datadir/$name/$type.port" 2>/dev/null || true)
+ lastPort=$(cat "$installDir/versions/$version/datadir/$name/$type.port.last" 2>/dev/null || true)
+ initPort=$(cat "$installDir/versions/$version/datadir/$name/$type.port.init" 2>/dev/null || true)
if [ "$runningPort" ]; then
echo $runningPort
@@ -209,3 +219,12 @@ getOptPort() {
echo "$optPort"
fi
}
+
+getInstallDir() {
+ suffix=dbdb/$1
+ if [ -z "${XDG_DATA_HOME+x}" ]; then
+ echo "$HOME/.local/share/$suffix"
+ else
+ echo "$XDG_DATA_HOME/$suffix"
+ fi
+}
diff --git a/mongodb/connect.sh b/mongodb/connect.sh
index 99d3407..97323fc 100755
--- a/mongodb/connect.sh
+++ b/mongodb/connect.sh
@@ -13,7 +13,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/mongodb/create.sh b/mongodb/create.sh
index c85b9e0..e0c8a67 100755
--- a/mongodb/create.sh
+++ b/mongodb/create.sh
@@ -45,7 +45,11 @@ optPort=$(getOptPort $3)
optFileName=mongodb-${optVersion}-${os}
optUser=_dbdb_mongodb
optSocket=/tmp/dbdb_mongodb_$optPort.sock
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
+
+mkdir -p "$dir"
+cd $dir
exitIfDuplicatedName $optName
exitIfExistDir $dir/datadir/$optName
@@ -58,8 +62,6 @@ extractFile $dir $optFileName
echo $optPort >$dir/datadir/$optName/mongodb.port.init
echo "#mongod.conf" > $dir/datadir/$optName/mongod.conf
-
-cd $currentDir
commands=$(getCommands $optName $optVersion $optPort $format)
normalOutputs=""
diff --git a/mongodb/delete.sh b/mongodb/delete.sh
index e223adf..afe8d96 100755
--- a/mongodb/delete.sh
+++ b/mongodb/delete.sh
@@ -34,10 +34,10 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
./stop.sh -f "$format" $optName $optVersion $optPort > /dev/null
-sleep 1
set -eu
exitIfNotExistDir $dir/datadir/$optName
diff --git a/mongodb/restart.sh b/mongodb/restart.sh
index 8f65ada..4fb5d80 100755
--- a/mongodb/restart.sh
+++ b/mongodb/restart.sh
@@ -24,9 +24,7 @@ currentDir="$(
pwd -P
)"
cd $currentDir
-./stop.sh -f "$format" $1 > /dev/null
-
-sleep 1
+./stop.sh -f "$format" $1 > /dev/null
set -eu
./start.sh -f "$format" $1
diff --git a/mongodb/start.sh b/mongodb/start.sh
index 1241b27..77c7f40 100755
--- a/mongodb/start.sh
+++ b/mongodb/start.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfRunningPort $optPort
@@ -50,6 +51,8 @@ $dir/basedir/bin/mongod \
--fork 1>&2
echo $optPort > $dir/datadir/$optName/mongodb.port
+sleep 1
+
normalOutputs=""
normalOutputs="${normalOutputs}MongoDB Successfully started. $optName $optVersion $optPort\n"
normalOutputs="${normalOutputs}Your config file is located $dir/datadir/$optName/mongodb.conf"
diff --git a/mongodb/status.sh b/mongodb/status.sh
index ccc9747..c86c644 100755
--- a/mongodb/status.sh
+++ b/mongodb/status.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/mongodb/stop.sh b/mongodb/stop.sh
index 61f418f..aea8d2d 100755
--- a/mongodb/stop.sh
+++ b/mongodb/stop.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
@@ -43,6 +44,8 @@ exitIfNotRunningPort $optPort
[ -f "$dir/datadir/$optName/mongodb.port" ] && cp $dir/datadir/$optName/mongodb.port $dir/datadir/$optName/mongodb.port.last
[ -f "$dir/datadir/$optName/mongodb.port" ] && rm -f $dir/datadir/$optName/mongodb.port
+sleep 1
+
normalOutputs=""
normalOutputs="${normalOutputs}MongoDB Successfully stopped. $optName $optVersion $optPort"
diff --git a/mysql/connect.sh b/mysql/connect.sh
index d9b9422..bc7c655 100755
--- a/mysql/connect.sh
+++ b/mysql/connect.sh
@@ -14,7 +14,8 @@ exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
optSocket=/tmp/dbdb_mysql_$optPort.sock
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/mysql/create.sh b/mysql/create.sh
index 5f676fc..09938a9 100755
--- a/mysql/create.sh
+++ b/mysql/create.sh
@@ -45,7 +45,11 @@ optPort=$(getOptPort $3)
optFileName=mysql-${optVersion}-${os}
optUser=_dbdb_mysql
optSocket=/tmp/dbdb_mysql_$optPort.sock
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
+
+mkdir -p "$dir"
+cd $dir
exitIfDuplicatedName $optName
exitIfExistDir $dir/datadir/$optName
@@ -69,11 +73,10 @@ $dir/basedir/bin/mysqld \
echo $optPort >$dir/datadir/$optName/mysql.port.init
-echo "#my.cnf" >$dir/datadir/$optName/my.cnf
-echo "[mysqld]" >>$dir/datadir/$optName/my.cnf
-echo "bind-address = 127.0.0.1" >>$dir/datadir/$optName/my.cnf
+echo "#my.cnf" > $dir/datadir/$optName/my.cnf
+echo "[mysqld]" >> $dir/datadir/$optName/my.cnf
+echo "bind-address = 127.0.0.1" >> $dir/datadir/$optName/my.cnf
-cd $currentDir
commands=$(getCommands $optName $optVersion $optPort $format)
normalOutputs=""
diff --git a/mysql/delete.sh b/mysql/delete.sh
index 3aebf5e..89665dc 100755
--- a/mysql/delete.sh
+++ b/mysql/delete.sh
@@ -34,7 +34,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
./stop.sh -f "$format" $optName $optVersion $optPort > /dev/null
diff --git a/mysql/restart.sh b/mysql/restart.sh
index 51d83ad..4fb5d80 100755
--- a/mysql/restart.sh
+++ b/mysql/restart.sh
@@ -24,7 +24,7 @@ currentDir="$(
pwd -P
)"
cd $currentDir
-./stop.sh -f "$format" $1 > /dev/null
+./stop.sh -f "$format" $1 > /dev/null
set -eu
./start.sh -f "$format" $1
diff --git a/mysql/start.sh b/mysql/start.sh
index 8ca8205..f68e6b7 100755
--- a/mysql/start.sh
+++ b/mysql/start.sh
@@ -37,10 +37,12 @@ optPort=$(getPortByName "$optName" "$optVersion")
optUser=_dbdb_mysql
optSocket=/tmp/dbdb_mysql_$optPort.sock
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfRunningPort $optPort
+
$dir/basedir/bin/mysqld \
--defaults-file=$dir/datadir/$optName/my.cnf \
--daemonize \
@@ -52,7 +54,7 @@ $dir/basedir/bin/mysqld \
--datadir=$dir/datadir/$optName \
--log-error=$dir/datadir/$optName/mysqld.err \
--pid-file=$dir/datadir/$optName/mysql.pid
-echo $optPort >$dir/datadir/$optName/mysql.port
+echo $optPort > $dir/datadir/$optName/mysql.port
normalOutputs=""
normalOutputs="${normalOutputs}MySQL Successfully started. $optName $optVersion $optPort\n"
diff --git a/mysql/status.sh b/mysql/status.sh
index 0286609..9620da7 100755
--- a/mysql/status.sh
+++ b/mysql/status.sh
@@ -36,10 +36,12 @@ exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
optSocket=/tmp/dbdb_mysql_$optPort.sock
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
+
status=$($dir/basedir/bin/mysqladmin --user=root --host=localhost --port=$optPort --socket=$optSocket status)
normalOutputs=""
diff --git a/mysql/stop.sh b/mysql/stop.sh
index 698da5d..71cf300 100755
--- a/mysql/stop.sh
+++ b/mysql/stop.sh
@@ -36,7 +36,8 @@ exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
optSocket=/tmp/dbdb_mysql_$optPort.sock
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/postgresql/connect.sh b/postgresql/connect.sh
index 48c6ace..9c332d9 100755
--- a/postgresql/connect.sh
+++ b/postgresql/connect.sh
@@ -13,7 +13,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/postgresql/create.sh b/postgresql/create.sh
index 9030880..db3c2fe 100755
--- a/postgresql/create.sh
+++ b/postgresql/create.sh
@@ -44,7 +44,11 @@ optName=$1
optVersion=$2
optPort=$(getOptPort $3)
optFileName=postgresql-${optVersion}-${os}
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
+
+mkdir -p "$dir"
+cd $dir
exitIfDuplicatedName $optName
exitIfExistDir $dir/datadir/$optName
@@ -59,9 +63,9 @@ if [ ! -d $dir/basedir/bin ]; then
if [ $os = "linux" ]; then
echo "Installing..." 1>&2
cd $dir/basedir
- ./configure --prefix=$(pwd) 1>&2
- make 1>&2
- make install 1>&2
+ ./configure --prefix=$(pwd) > /dev/null 2>&1
+ make > /dev/null 2>&1
+ make install > /dev/null 2>&1
rm -fr config contrib doc src
fi
fi
@@ -72,9 +76,8 @@ $dir/basedir/bin/initdb \
--username=postgres \
--encoding=UTF-8 \
--locale=en_US.UTF-8 1>&2
-echo $optPort >$dir/datadir/$optName/postgresql.port.init
+echo $optPort > $dir/datadir/$optName/postgresql.port.init
-cd $currentDir
commands=$(getCommands $optName $optVersion $optPort $format)
normalOutputs=""
diff --git a/postgresql/delete.sh b/postgresql/delete.sh
index a5f3d17..4bc7770 100755
--- a/postgresql/delete.sh
+++ b/postgresql/delete.sh
@@ -34,7 +34,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
./stop.sh -f "$format" $optName $optVersion $optPort > /dev/null
diff --git a/postgresql/restart.sh b/postgresql/restart.sh
index 51d83ad..4fb5d80 100755
--- a/postgresql/restart.sh
+++ b/postgresql/restart.sh
@@ -24,7 +24,7 @@ currentDir="$(
pwd -P
)"
cd $currentDir
-./stop.sh -f "$format" $1 > /dev/null
+./stop.sh -f "$format" $1 > /dev/null
set -eu
./start.sh -f "$format" $1
diff --git a/postgresql/start.sh b/postgresql/start.sh
index 6e1e646..0b50ae1 100755
--- a/postgresql/start.sh
+++ b/postgresql/start.sh
@@ -35,10 +35,12 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfRunningPort $optPort
+
$dir/basedir/bin/pg_ctl \
--pgdata $dir/datadir/$optName \
--log $dir/datadir/$optName/postgres.log \
diff --git a/postgresql/status.sh b/postgresql/status.sh
index 7bf3d49..f98bd9d 100755
--- a/postgresql/status.sh
+++ b/postgresql/status.sh
@@ -35,10 +35,12 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
+
status=$($dir/basedir/bin/pg_ctl \
--pgdata $dir/datadir/$optName \
--log $dir/datadir/$optName/postgres.log \
diff --git a/postgresql/stop.sh b/postgresql/stop.sh
index 16abdbe..aee3767 100755
--- a/postgresql/stop.sh
+++ b/postgresql/stop.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/redis/connect.sh b/redis/connect.sh
index f29cdaf..af33813 100755
--- a/redis/connect.sh
+++ b/redis/connect.sh
@@ -13,7 +13,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/redis/create.sh b/redis/create.sh
index 0a94a32..f96f254 100755
--- a/redis/create.sh
+++ b/redis/create.sh
@@ -43,7 +43,11 @@ optName=$1
optVersion=$2
optPort=$(getOptPort $3)
optFileName=redis-${optVersion}-${os}
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
+
+mkdir -p "$dir"
+cd $dir
exitIfDuplicatedName $optName
exitIfExistDir $dir/datadir/$optName
@@ -55,7 +59,8 @@ extractFile $dir $optFileName
if [ ! -e $dir/basedir/src/redis-server ]; then
cd $dir/basedir
- make 1>&2
+ echo "Installing..." 1>&2
+ make > /dev/null 2>&1
fi
# create redis.conf
@@ -64,9 +69,8 @@ if [ ! -f $dir/datadir/$optName/redis.conf ]; then
cp $dir/basedir/redis.conf .
fi
-echo $optPort >$dir/datadir/$optName/redis.port.init
+echo $optPort > $dir/datadir/$optName/redis.port.init
-cd $currentDir
commands=$(getCommands $optName $optVersion $optPort $format)
normalOutputs=""
diff --git a/redis/delete.sh b/redis/delete.sh
index 7f6e185..453dfff 100755
--- a/redis/delete.sh
+++ b/redis/delete.sh
@@ -34,7 +34,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
./stop.sh -f "$format" $optName $optVersion $optPort > /dev/null
diff --git a/redis/restart.sh b/redis/restart.sh
index 6abcdb1..4fb5d80 100755
--- a/redis/restart.sh
+++ b/redis/restart.sh
@@ -26,6 +26,5 @@ currentDir="$(
cd $currentDir
./stop.sh -f "$format" $1 > /dev/null
-
set -eu
./start.sh -f "$format" $1
diff --git a/redis/start.sh b/redis/start.sh
index 9d18630..f7f1f6b 100755
--- a/redis/start.sh
+++ b/redis/start.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfRunningPort $optPort
@@ -70,4 +71,3 @@ if [ "$format" = "json" ]; then
else
echo -e "${normalOutputs}"
fi
-
diff --git a/redis/status.sh b/redis/status.sh
index 803e312..d80409a 100755
--- a/redis/status.sh
+++ b/redis/status.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/redis/stop.sh b/redis/stop.sh
index b1b1d47..26f6635 100755
--- a/redis/stop.sh
+++ b/redis/stop.sh
@@ -35,7 +35,8 @@ optVersion=$(getVersionByName "$optName")
exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")
-dir=$currentDir/versions/$optVersion
+installDir=$(getInstallDir $(getType))
+dir=$installDir/versions/$optVersion
exitIfNotExistDir $dir/datadir/$optName
exitIfNotRunningPort $optPort
diff --git a/tests/mongodb-test.sh b/tests/mongodb-4.4.10.sh
similarity index 57%
rename from tests/mongodb-test.sh
rename to tests/mongodb-4.4.10.sh
index 010d5d5..10f267d 100755
--- a/tests/mongodb-test.sh
+++ b/tests/mongodb-4.4.10.sh
@@ -1,52 +1,50 @@
#!/usr/bin/env bash
-set -aeuvx
+set -eu
. ../lib/functions.sh
type=mongodb
-oldVersion=4.4.10
-newVersion=5.0.3
+version=4.4.10
-cd ../$type
-rm -fr $type-*.tar.gz
-cd ..
+cd ../$type/..
date=$(date +%Y%m%d%H%M%S)
md5="md5"
[ "$(getOS)" = "linux" ] && md5="md5sum"
hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
-echo "Test create"
-./$type/create.sh dbdb-test-$hash $oldVersion random
-echo "Test port"
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
./$type/port.sh dbdb-test-$hash
-echo "Test start"
+echo "# Test start"
./$type/start.sh dbdb-test-$hash
-echo "Test status"
+echo "# Test status"
./$type/status.sh dbdb-test-$hash
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh dbdb-test-$hash
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh dbdb-test-$hash
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh dbdb-test-$hash
-echo "Test create"
-./$type/create.sh -f json dbdb-test-$hash $newVersion random | jq
-echo "Test port"
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
./$type/port.sh -f json dbdb-test-$hash | jq
-echo "Test start"
+echo "# Test start"
./$type/start.sh -f json dbdb-test-$hash | jq
-echo "Test status"
+echo "# Test status"
./$type/status.sh -f json dbdb-test-$hash | jq
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh -f json dbdb-test-$hash | jq
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh -f json dbdb-test-$hash | jq
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh -f json dbdb-test-$hash | jq
./dbdb.sh
-./$type/create-start.sh -f json dbdb-test-$hash $newVersion random | jq
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
./dbdb.sh -f json | jq
./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/mongodb-5.0.3.sh b/tests/mongodb-5.0.3.sh
new file mode 100755
index 0000000..44f5bad
--- /dev/null
+++ b/tests/mongodb-5.0.3.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -eu
+
+. ../lib/functions.sh
+
+type=mongodb
+version=5.0.3
+
+cd ../$type/..
+
+date=$(date +%Y%m%d%H%M%S)
+md5="md5"
+[ "$(getOS)" = "linux" ] && md5="md5sum"
+hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
+
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
+./$type/port.sh dbdb-test-$hash
+echo "# Test start"
+./$type/start.sh dbdb-test-$hash
+echo "# Test status"
+./$type/status.sh dbdb-test-$hash
+echo "# Test restart"
+./$type/restart.sh dbdb-test-$hash
+echo "# Test stop"
+./$type/stop.sh dbdb-test-$hash
+echo "# Test delete"
+./$type/delete.sh dbdb-test-$hash
+
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
+./$type/port.sh -f json dbdb-test-$hash | jq
+echo "# Test start"
+./$type/start.sh -f json dbdb-test-$hash | jq
+echo "# Test status"
+./$type/status.sh -f json dbdb-test-$hash | jq
+echo "# Test restart"
+./$type/restart.sh -f json dbdb-test-$hash | jq
+echo "# Test stop"
+./$type/stop.sh -f json dbdb-test-$hash | jq
+echo "# Test delete"
+./$type/delete.sh -f json dbdb-test-$hash | jq
+
+./dbdb.sh
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
+./dbdb.sh -f json | jq
+./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/mysql-test.sh b/tests/mysql-5.7.31.sh
similarity index 57%
rename from tests/mysql-test.sh
rename to tests/mysql-5.7.31.sh
index 12422f0..f13d524 100755
--- a/tests/mysql-test.sh
+++ b/tests/mysql-5.7.31.sh
@@ -1,52 +1,50 @@
#!/usr/bin/env bash
-set -aeuvx
+set -eu
. ../lib/functions.sh
type=mysql
-oldVersion=5.7.31
-newVersion=8.0.30
+version=5.7.31
-cd ../$type
-rm -fr $type-*.tar.gz
-cd ..
+cd ../$type/..
date=$(date +%Y%m%d%H%M%S)
md5="md5"
[ "$(getOS)" = "linux" ] && md5="md5sum"
hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
-echo "Test create"
-./$type/create.sh dbdb-test-$hash $oldVersion random
-echo "Test port"
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
./$type/port.sh dbdb-test-$hash
-echo "Test start"
+echo "# Test start"
./$type/start.sh dbdb-test-$hash
-echo "Test status"
+echo "# Test status"
./$type/status.sh dbdb-test-$hash
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh dbdb-test-$hash
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh dbdb-test-$hash
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh dbdb-test-$hash
-echo "Test create"
-./$type/create.sh -f json dbdb-test-$hash $newVersion random | jq
-echo "Test port"
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
./$type/port.sh -f json dbdb-test-$hash | jq
-echo "Test start"
+echo "# Test start"
./$type/start.sh -f json dbdb-test-$hash | jq
-echo "Test status"
+echo "# Test status"
./$type/status.sh -f json dbdb-test-$hash | jq
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh -f json dbdb-test-$hash | jq
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh -f json dbdb-test-$hash | jq
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh -f json dbdb-test-$hash | jq
./dbdb.sh
-./$type/create-start.sh -f json dbdb-test-$hash $newVersion random | jq
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
./dbdb.sh -f json | jq
./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/mysql-8.0.30.sh b/tests/mysql-8.0.30.sh
new file mode 100755
index 0000000..6178726
--- /dev/null
+++ b/tests/mysql-8.0.30.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -eu
+
+. ../lib/functions.sh
+
+type=mysql
+version=8.0.30
+
+cd ../$type/..
+
+date=$(date +%Y%m%d%H%M%S)
+md5="md5"
+[ "$(getOS)" = "linux" ] && md5="md5sum"
+hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
+
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
+./$type/port.sh dbdb-test-$hash
+echo "# Test start"
+./$type/start.sh dbdb-test-$hash
+echo "# Test status"
+./$type/status.sh dbdb-test-$hash
+echo "# Test restart"
+./$type/restart.sh dbdb-test-$hash
+echo "# Test stop"
+./$type/stop.sh dbdb-test-$hash
+echo "# Test delete"
+./$type/delete.sh dbdb-test-$hash
+
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
+./$type/port.sh -f json dbdb-test-$hash | jq
+echo "# Test start"
+./$type/start.sh -f json dbdb-test-$hash | jq
+echo "# Test status"
+./$type/status.sh -f json dbdb-test-$hash | jq
+echo "# Test restart"
+./$type/restart.sh -f json dbdb-test-$hash | jq
+echo "# Test stop"
+./$type/stop.sh -f json dbdb-test-$hash | jq
+echo "# Test delete"
+./$type/delete.sh -f json dbdb-test-$hash | jq
+
+./dbdb.sh
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
+./dbdb.sh -f json | jq
+./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/postgresql-test.sh b/tests/postgresql-12.4.sh
similarity index 58%
rename from tests/postgresql-test.sh
rename to tests/postgresql-12.4.sh
index c82990d..99af4a2 100755
--- a/tests/postgresql-test.sh
+++ b/tests/postgresql-12.4.sh
@@ -1,52 +1,50 @@
#!/usr/bin/env bash
-set -aeuvx
+set -eu
. ../lib/functions.sh
type=postgresql
-oldVersion=12.4
-newVersion=13.2
+version=12.4
-cd ../$type
-rm -fr $type-*.tar.gz
-cd ..
+cd ../$type/..
date=$(date +%Y%m%d%H%M%S)
md5="md5"
[ "$(getOS)" = "linux" ] && md5="md5sum"
hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
-echo "Test create"
-./$type/create.sh dbdb-test-$hash $oldVersion random
-echo "Test port"
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
./$type/port.sh dbdb-test-$hash
-echo "Test start"
+echo "# Test start"
./$type/start.sh dbdb-test-$hash
-echo "Test status"
+echo "# Test status"
./$type/status.sh dbdb-test-$hash
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh dbdb-test-$hash
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh dbdb-test-$hash
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh dbdb-test-$hash
-echo "Test create"
-./$type/create.sh -f json dbdb-test-$hash $newVersion random | jq
-echo "Test port"
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
./$type/port.sh -f json dbdb-test-$hash | jq
-echo "Test start"
+echo "# Test start"
./$type/start.sh -f json dbdb-test-$hash | jq
-echo "Test status"
+echo "# Test status"
./$type/status.sh -f json dbdb-test-$hash | jq
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh -f json dbdb-test-$hash | jq
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh -f json dbdb-test-$hash | jq
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh -f json dbdb-test-$hash | jq
./dbdb.sh
-./$type/create-start.sh -f json dbdb-test-$hash $newVersion random | jq
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
./dbdb.sh -f json | jq
./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/postgresql-13.2.sh b/tests/postgresql-13.2.sh
new file mode 100755
index 0000000..b68e341
--- /dev/null
+++ b/tests/postgresql-13.2.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -eu
+
+. ../lib/functions.sh
+
+type=postgresql
+version=13.2
+
+cd ../$type/..
+
+date=$(date +%Y%m%d%H%M%S)
+md5="md5"
+[ "$(getOS)" = "linux" ] && md5="md5sum"
+hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
+
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
+./$type/port.sh dbdb-test-$hash
+echo "# Test start"
+./$type/start.sh dbdb-test-$hash
+echo "# Test status"
+./$type/status.sh dbdb-test-$hash
+echo "# Test restart"
+./$type/restart.sh dbdb-test-$hash
+echo "# Test stop"
+./$type/stop.sh dbdb-test-$hash
+echo "# Test delete"
+./$type/delete.sh dbdb-test-$hash
+
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
+./$type/port.sh -f json dbdb-test-$hash | jq
+echo "# Test start"
+./$type/start.sh -f json dbdb-test-$hash | jq
+echo "# Test status"
+./$type/status.sh -f json dbdb-test-$hash | jq
+echo "# Test restart"
+./$type/restart.sh -f json dbdb-test-$hash | jq
+echo "# Test stop"
+./$type/stop.sh -f json dbdb-test-$hash | jq
+echo "# Test delete"
+./$type/delete.sh -f json dbdb-test-$hash | jq
+
+./dbdb.sh
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
+./dbdb.sh -f json | jq
+./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/redis-test.sh b/tests/redis-6.0.16.sh
similarity index 57%
rename from tests/redis-test.sh
rename to tests/redis-6.0.16.sh
index e7873a6..869874e 100755
--- a/tests/redis-test.sh
+++ b/tests/redis-6.0.16.sh
@@ -1,52 +1,50 @@
#!/usr/bin/env bash
-set -aeuvx
+set -eu
. ../lib/functions.sh
type=redis
-oldVersion=6.0.16
-newVersion=6.2.6
+version=6.0.16
-cd ../$type
-rm -fr $type-*.tar.gz
-cd ..
+cd ../$type/..
date=$(date +%Y%m%d%H%M%S)
md5="md5"
[ "$(getOS)" = "linux" ] && md5="md5sum"
hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
-echo "Test create"
-./$type/create.sh dbdb-test-$hash $oldVersion random
-echo "Test port"
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
./$type/port.sh dbdb-test-$hash
-echo "Test start"
+echo "# Test start"
./$type/start.sh dbdb-test-$hash
-echo "Test status"
+echo "# Test status"
./$type/status.sh dbdb-test-$hash
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh dbdb-test-$hash
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh dbdb-test-$hash
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh dbdb-test-$hash
-echo "Test create"
-./$type/create.sh -f json dbdb-test-$hash $newVersion random | jq
-echo "Test port"
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
./$type/port.sh -f json dbdb-test-$hash | jq
-echo "Test start"
+echo "# Test start"
./$type/start.sh -f json dbdb-test-$hash | jq
-echo "Test status"
+echo "# Test status"
./$type/status.sh -f json dbdb-test-$hash | jq
-echo "Test restart"
+echo "# Test restart"
./$type/restart.sh -f json dbdb-test-$hash | jq
-echo "Test stop"
+echo "# Test stop"
./$type/stop.sh -f json dbdb-test-$hash | jq
-echo "Test delete"
+echo "# Test delete"
./$type/delete.sh -f json dbdb-test-$hash | jq
./dbdb.sh
-./$type/create-start.sh -f json dbdb-test-$hash $newVersion random | jq
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
./dbdb.sh -f json | jq
./$type/delete.sh dbdb-test-$hash
+./dbdb.sh
diff --git a/tests/redis-6.2.6.sh b/tests/redis-6.2.6.sh
new file mode 100755
index 0000000..4f17307
--- /dev/null
+++ b/tests/redis-6.2.6.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -eu
+
+. ../lib/functions.sh
+
+type=redis
+version=6.2.6
+
+cd ../$type/..
+
+date=$(date +%Y%m%d%H%M%S)
+md5="md5"
+[ "$(getOS)" = "linux" ] && md5="md5sum"
+hash=$(echo "dbdb-$date" | $md5 | cut -d ' ' -f 1)
+
+echo "# Test create"
+./$type/create.sh dbdb-test-$hash $version random
+echo "# Test port"
+./$type/port.sh dbdb-test-$hash
+echo "# Test start"
+./$type/start.sh dbdb-test-$hash
+echo "# Test status"
+./$type/status.sh dbdb-test-$hash
+echo "# Test restart"
+./$type/restart.sh dbdb-test-$hash
+echo "# Test stop"
+./$type/stop.sh dbdb-test-$hash
+echo "# Test delete"
+./$type/delete.sh dbdb-test-$hash
+
+echo "# Test create"
+./$type/create.sh -f json dbdb-test-$hash $version random | jq
+echo "# Test port"
+./$type/port.sh -f json dbdb-test-$hash | jq
+echo "# Test start"
+./$type/start.sh -f json dbdb-test-$hash | jq
+echo "# Test status"
+./$type/status.sh -f json dbdb-test-$hash | jq
+echo "# Test restart"
+./$type/restart.sh -f json dbdb-test-$hash | jq
+echo "# Test stop"
+./$type/stop.sh -f json dbdb-test-$hash | jq
+echo "# Test delete"
+./$type/delete.sh -f json dbdb-test-$hash | jq
+
+./dbdb.sh
+./$type/create-start.sh -f json dbdb-test-$hash $version random | jq
+./dbdb.sh -f json | jq
+./$type/delete.sh dbdb-test-$hash
+./dbdb.sh