Added app.conf file
This commit is contained in:
8
scripts/app.conf
Normal file
8
scripts/app.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
# Application settings
|
||||
APP_NAME="Database Middleware"
|
||||
APP_PORT=8080
|
||||
|
||||
# DatabaseS settings
|
||||
DBS_PORTS=3306
|
||||
@@ -1,7 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
APP_DIR="$HOME/.db-middleware"
|
||||
CODE_DIR="$HOME/.db-middleware/code"
|
||||
CODE_DIR="$APP_DIR/code"
|
||||
CONFIG_DIR="$APP_DIR/config"
|
||||
CONFIG_FILE="$CONFIG_DIR/app.conf"
|
||||
|
||||
# Function to load the config file
|
||||
load_config() {
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
source "$CONFIG_FILE"
|
||||
else
|
||||
echo "Config file not found: $CONFIG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
show_config() {
|
||||
echo "Current Config:"
|
||||
echo "CONTAINER_NAME: $CONTAINER_NAME"
|
||||
echo "APP_PORT: $APP_PORT"
|
||||
echo "DBS_PORTS: $DBS_PORTS"
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
echo
|
||||
@@ -12,13 +32,17 @@ install() {
|
||||
|
||||
cd "$CODE_DIR"
|
||||
|
||||
docker build -t db-middleware .
|
||||
# docker build -t db-middleware .
|
||||
|
||||
echo
|
||||
echo "+----------------------------------------+"
|
||||
echo "| Installed the Middleware Successfully. |"
|
||||
echo "| Installed the Middleware Successfully! |"
|
||||
echo "+----------------------------------------+"
|
||||
echo
|
||||
echo "- You can run the middleware simply using the manager:"
|
||||
echo " >>> db-middleware start"
|
||||
echo "- Or directly by running the docker container:"
|
||||
echo " >>> docker run db-middleware -p <port>:<port> -v /path/to/app/directory/"
|
||||
}
|
||||
|
||||
# Function for the "upgrade" command
|
||||
@@ -30,13 +54,17 @@ upgrade() {
|
||||
# Function for the "status" command
|
||||
status() {
|
||||
echo "Running the 'status' function."
|
||||
docker
|
||||
# Add your status-checking logic here
|
||||
}
|
||||
|
||||
# Function for the "start" command
|
||||
start() {
|
||||
echo "Running the 'start' function."
|
||||
# Add your start logic here
|
||||
echo "+---------------------------+"
|
||||
echo "| Starting the Container... |"
|
||||
echo "+---------------------------+"
|
||||
echo
|
||||
docker run db-middleware
|
||||
}
|
||||
|
||||
# Function for the "stop" command
|
||||
@@ -64,15 +92,23 @@ main() {
|
||||
install
|
||||
;;
|
||||
upgrade)
|
||||
load_config
|
||||
upgrade
|
||||
;;
|
||||
status)
|
||||
load_config
|
||||
status
|
||||
;;
|
||||
start)
|
||||
load_config
|
||||
start
|
||||
;;
|
||||
show_config)
|
||||
load_config
|
||||
show_config
|
||||
;;
|
||||
stop)
|
||||
load_config
|
||||
stop
|
||||
;;
|
||||
*)
|
||||
@@ -83,4 +119,5 @@ main() {
|
||||
}
|
||||
|
||||
# Run the script with the provided arguments
|
||||
|
||||
main "$@"
|
||||
|
||||
@@ -48,9 +48,10 @@ cp "$CODE_DIR/scripts/"* "$APP_DIR/scripts/"
|
||||
# Give execution permission to all scripts
|
||||
chmod +x "$APP_DIR/scripts/"*
|
||||
|
||||
# Run the manager.sh script with the "install" argument
|
||||
echo
|
||||
echo "--------------------"
|
||||
echo
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
ln -s "$APP_DIR/scripts/manager.sh" "$HOME/.local/bin/db-middleware"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
source ~/.bashrc
|
||||
|
||||
# Run the manager.sh script with the "install" argument
|
||||
"$APP_DIR/scripts/manager.sh" install
|
||||
Reference in New Issue
Block a user