Skip to content

Commit

Permalink
Merge pull request #39 from pj8/show-port
Browse files Browse the repository at this point in the history
Show port number
  • Loading branch information
yuki777 authored Feb 26, 2023
2 parents 95b08dc + 33a1ac3 commit db51d12
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 51 deletions.
104 changes: 54 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# DBDB

```
-----------------------------------------------
----------------------------------------------
< DBDB, What a great database version manager! >
-----------------------------------------------
----------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
Expand All @@ -20,10 +20,10 @@ cd dbdb

## MySQL

### Create/Start/Stop/Restart/Status/Connect/Delete MySQL Server on localhost
### Manage MySQL Server on localhost

```
./mysql/{create|start|stop|restart|status|connect|delete}.sh {name} {mysqlVersion} {port}
./mysql/{create|start|stop|restart|port|status|connect|delete}.sh {name} {mysqlVersion} {port}
# e.g. Create MySQL server.
./mysql/create.sh mysql1 5.7.31 3306
Expand All @@ -32,12 +32,13 @@ cd dbdb
./mysql/create.sh mysql2 8.0.30 13306
# e.g.
./mysql/start.sh mysql1 5.7.31 3306
./mysql/stop.sh mysql1 5.7.31 3306
./mysql/restart.sh mysql1 5.7.31 3306
./mysql/status.sh mysql1 5.7.31 3306
./mysql/connect.sh mysql1 5.7.31 3306
./mysql/delete.sh mysql1 5.7.31 3306
./mysql/start.sh mysql1
./mysql/stop.sh mysql1
./mysql/restart.sh mysql1
./mysql/port.sh mysql1
./mysql/status.sh mysql1
./mysql/connect.sh mysql1
./mysql/delete.sh mysql1
# e.g. Create with random port.
./mysql/create.sh mysql1 5.7.31 random
Expand All @@ -56,19 +57,20 @@ cd dbdb

## PostgreSQL

### Create/Start/Stop/Restart/Status/Connect/Delete PostgreSQL Server on localhost
### Manage PostgreSQL Server on localhost

```
./postgresql/{create|start|stop|restart|status|connect|delete}.sh {name} {postgresqlVersion} {port}
./postgresql/{create|start|stop|restart|port|status|connect|delete}.sh {name} {postgresqlVersion} {port}
# e.g.
./postgresql/create.sh pg1 12.4 5432
./postgresql/start.sh pg1 12.4 5432
./postgresql/stop.sh pg1 12.4 5432
./postgresql/restart.sh pg1 12.4 5432
./postgresql/status.sh pg1 12.4 5432
./postgresql/connect.sh pg1 12.4 5432
./postgresql/delete.sh pg1 12.4 5432
./postgresql/start.sh pg1
./postgresql/stop.sh pg1
./postgresql/restart.sh pg1
./postgresql/port.sh pg1
./postgresql/status.sh pg1
./postgresql/connect.sh pg1
./postgresql/delete.sh pg1
```

### Supported PostgreSQL Versions
Expand All @@ -81,44 +83,46 @@ cd dbdb

## Redis

### Create/Start/Stop/Restart/Status/Connect/Delete Redis Server on localhost
### Manage Redis Server on localhost

```
./redis/{create|start|stop|restart|status|connect|delete}.sh {name} {redisVersion} {port}
./redis/{create|start|stop|restart|port|status|connect|delete}.sh {name} {redisVersion} {port}
# e.g.
./redis/create.sh redis1 6.0.10 6379
./redis/start.sh redis1 6.0.10 6379
./redis/stop.sh redis1 6.0.10 6379
./redis/restart.sh redis1 6.0.10 6379
./redis/status.sh redis1 6.0.10 6379
./redis/connect.sh redis1 6.0.10 6379
./redis/delete.sh redis1 6.0.10 6379
./redis/start.sh redis1
./redis/stop.sh redis1
./redis/restart.sh redis1
./redis/port.sh redis1
./redis/status.sh redis1
./redis/connect.sh redis1
./redis/delete.sh redis1
```

### Supported Redis Versions

- 5.0.14 (Error `make` on M1 Mac.)
- 5.0.14 (`make` causes an error on M1 Mac.)
- 6.0.16
- 6.2.6

---

## MongoDB

### Create/Start/Stop/Restart/Status/Connect/Delete MongoDB Server on localhost
### Manage MongoDB Server on localhost

```
./mongodb/{create|start|stop|restart|status|connect|delete}.sh {name} {mongodbVersion} {port}
./mongodb/{create|start|stop|restart|port|status|connect|delete}.sh {name} {mongodbVersion} {port}
# e.g.
./mongodb/create.sh mongo1 4.4.3 27017
./mongodb/start.sh mongo1 4.4.3 27017
./mongodb/stop.sh mongo1 4.4.3 27017
./mongodb/restart.sh mongo1 4.4.3 27017
./mongodb/status.sh mongo1 4.4.3 27017
./mongodb/connect.sh mongo1 4.4.3 27017
./mongodb/delete.sh mongo1 4.4.3 27017
./mongodb/start.sh mongo1
./mongodb/stop.sh mongo1
./mongodb/restart.sh mongo1
./mongodb/port.sh mongo1
./mongodb/status.sh mongo1
./mongodb/connect.sh mongo1
./mongodb/delete.sh mongo1
```

### Supported MongoDB Versions
Expand All @@ -136,6 +140,12 @@ cd dbdb
/path/to/dbdb/mysql/create.sh mysql5-foo 5.7.31 random
```

### Show port number.

```
/path/to/dbdb/mysql/port.sh mysql5-foo
```

### Start by creating the database server if it does not exist.

```
Expand All @@ -151,20 +161,14 @@ cd dbdb
/path/to/dbdb/dbdb.sh
mongodb.4.4.3.mongo4 is stopped.
/path/to/dbdb/mongodb/start.sh mongo4 4.4.3 27017
/path/to/dbdb/mongodb/stop.sh mongo4 4.4.3 27017
/path/to/dbdb/mongodb/restart.sh mongo4 4.4.3 27017
/path/to/dbdb/mongodb/status.sh mongo4 4.4.3 27017
/path/to/dbdb/mongodb/connect.sh mongo4 4.4.3 27017
/path/to/dbdb/mongodb/delete.sh mongo4 4.4.3 27017
/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 5.7.31 3306
/path/to/dbdb/mysql/stop.sh mysql5-foo 5.7.31 3306
/path/to/dbdb/mysql/restart.sh mysql5-foo 5.7.31 3306
/path/to/dbdb/mysql/status.sh mysql5-foo 5.7.31 3306
/path/to/dbdb/mysql/connect.sh mysql5-foo 5.7.31 3306
/path/to/dbdb/mysql/delete.sh mysql5-foo 5.7.31 3306
/path/to/dbdb/mysql/start.sh mysql5-foo
/path/to/dbdb/mysql/stop.sh mysql5-foo
/path/to/dbdb/mysql/restart.sh mysql5-foo
...
```
Expand All @@ -175,11 +179,11 @@ mysql.5.7.31.mysql5-foo is running.

```
# Start mysql5
@reboot /path/to/dbdb/mysql/start.sh mysql5-foo 5.7.31 3306
@reboot /path/to/dbdb/mysql/start.sh mysql5-foo
# Start mysql8 with port 13306
@reboot /path/to/dbdb/mysql/start.sh mysql8-bar 8.0.30 13306
@reboot /path/to/dbdb/mysql/start.sh mysql8-bar
# Try create, then start the server
@reboot /path/to/dbdb/redis/create-start.sh redis1 6.0.10 6379
@reboot /path/to/dbdb/redis/create-start.sh redis1 6.0.10 6379
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.0
v1.2.0
1 change: 1 addition & 0 deletions dbdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ do
echo "$currentDir/$dbType/start.sh $dbServerName"
echo "$currentDir/$dbType/stop.sh $dbServerName"
echo "$currentDir/$dbType/restart.sh $dbServerName"
# echo "$currentDir/$dbType/port.sh $dbServerName"
# echo "$currentDir/$dbType/status.sh $dbServerName"
# echo "$currentDir/$dbType/connect.sh $dbServerName"
# echo "$currentDir/$dbType/delete.sh $dbServerName"
Expand Down
3 changes: 3 additions & 0 deletions lib/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ printDebug(){
echo "# Restart"
echo "$currentDir/restart.sh $1"
echo ""
echo "# Port"
echo "$currentDir/port.sh $1"
echo ""
echo "# Status"
echo "$currentDir/status.sh $1"
echo ""
Expand Down
24 changes: 24 additions & 0 deletions mongodb/port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -eu

currentDir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd $currentDir
. functions.sh

if [ $# -eq 0 ]; then
cat <<_EOT_
usage : $currentDir/port.sh {Name}
e.g. : $currentDir/port.sh database-foo
_EOT_
exit 1
fi

optName=$1

exitIfNotExistVersion "$optName"
optVersion=$(getVersionByName "$optName")

exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")

echo "$optPort"
24 changes: 24 additions & 0 deletions mysql/port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -eu

currentDir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd $currentDir
. functions.sh

if [ $# -eq 0 ]; then
cat <<_EOT_
usage : $currentDir/port.sh {Name}
e.g. : $currentDir/port.sh database-foo
_EOT_
exit 1
fi

optName=$1

exitIfNotExistVersion "$optName"
optVersion=$(getVersionByName "$optName")

exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")

echo "$optPort"
24 changes: 24 additions & 0 deletions postgresql/port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -eu

currentDir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd $currentDir
. functions.sh

if [ $# -eq 0 ]; then
cat <<_EOT_
usage : $currentDir/port.sh {Name}
e.g. : $currentDir/port.sh database-foo
_EOT_
exit 1
fi

optName=$1

exitIfNotExistVersion "$optName"
optVersion=$(getVersionByName "$optName")

exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")

echo "$optPort"
24 changes: 24 additions & 0 deletions redis/port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -eu

currentDir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd $currentDir
. functions.sh

if [ $# -eq 0 ]; then
cat <<_EOT_
usage : $currentDir/port.sh {Name}
e.g. : $currentDir/port.sh database-foo
_EOT_
exit 1
fi

optName=$1

exitIfNotExistVersion "$optName"
optVersion=$(getVersionByName "$optName")

exitIfNotExistPortFile "$optName" "$optVersion"
optPort=$(getPortByName "$optName" "$optVersion")

echo "$optPort"
4 changes: 4 additions & 0 deletions tests/mongodb-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ hash=$(echo "dbdb-$date"|$md5|cut -d ' ' -f 1)
# 4.4.10
echo "Test create..."
./create.sh dbdb-test-$hash 4.4.10 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand All @@ -26,6 +28,8 @@ echo "Test delete..."
# 5.0.3
echo "Test create..."
./create.sh dbdb-test-$hash 5.0.3 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand Down
6 changes: 6 additions & 0 deletions tests/mysql-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ hash=$(echo "dbdb-$date"|$md5|cut -d ' ' -f 1)
# 5.7.31
echo "Test create..."
./create.sh dbdb-test-$hash 5.7.31 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand All @@ -26,6 +28,8 @@ echo "Test delete..."
# 8.0.23
echo "Test create..."
./create.sh dbdb-test-$hash 8.0.23 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand All @@ -38,6 +42,8 @@ echo "Test delete..."
# 8.0.30
echo "Test create..."
./create.sh dbdb-test-$hash 8.0.30 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand Down
6 changes: 6 additions & 0 deletions tests/postgresql-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ hash=$(echo "dbdb-$date"|$md5|cut -d ' ' -f 1)
# 12.4
echo "Test create..."
./create.sh dbdb-test-$hash 12.4 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand All @@ -26,6 +28,8 @@ echo "Test delete..."
# 12.6
echo "Test create..."
./create.sh dbdb-test-$hash 12.6 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand All @@ -38,6 +42,8 @@ echo "Test delete..."
# 13.2
echo "Test create..."
./create.sh dbdb-test-$hash 13.2 random
echo "Test port..."
./port.sh dbdb-test-$hash
echo "Test start..."
./start.sh dbdb-test-$hash
echo "Test status..."
Expand Down
Loading

0 comments on commit db51d12

Please sign in to comment.