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
|
#!/bin/bash
|
||||||
|
|
||||||
APP_DIR="$HOME/.db-middleware"
|
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() {
|
install() {
|
||||||
echo
|
echo
|
||||||
@@ -12,13 +32,17 @@ install() {
|
|||||||
|
|
||||||
cd "$CODE_DIR"
|
cd "$CODE_DIR"
|
||||||
|
|
||||||
docker build -t db-middleware .
|
# docker build -t db-middleware .
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "+----------------------------------------+"
|
echo "+----------------------------------------+"
|
||||||
echo "| Installed the Middleware Successfully. |"
|
echo "| Installed the Middleware Successfully! |"
|
||||||
echo "+----------------------------------------+"
|
echo "+----------------------------------------+"
|
||||||
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
|
# Function for the "upgrade" command
|
||||||
@@ -30,13 +54,17 @@ upgrade() {
|
|||||||
# Function for the "status" command
|
# Function for the "status" command
|
||||||
status() {
|
status() {
|
||||||
echo "Running the 'status' function."
|
echo "Running the 'status' function."
|
||||||
|
docker
|
||||||
# Add your status-checking logic here
|
# Add your status-checking logic here
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function for the "start" command
|
# Function for the "start" command
|
||||||
start() {
|
start() {
|
||||||
echo "Running the 'start' function."
|
echo "+---------------------------+"
|
||||||
# Add your start logic here
|
echo "| Starting the Container... |"
|
||||||
|
echo "+---------------------------+"
|
||||||
|
echo
|
||||||
|
docker run db-middleware
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function for the "stop" command
|
# Function for the "stop" command
|
||||||
@@ -64,15 +92,23 @@ main() {
|
|||||||
install
|
install
|
||||||
;;
|
;;
|
||||||
upgrade)
|
upgrade)
|
||||||
|
load_config
|
||||||
upgrade
|
upgrade
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
|
load_config
|
||||||
status
|
status
|
||||||
;;
|
;;
|
||||||
start)
|
start)
|
||||||
|
load_config
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
show_config)
|
||||||
|
load_config
|
||||||
|
show_config
|
||||||
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
load_config
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -83,4 +119,5 @@ main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Run the script with the provided arguments
|
# Run the script with the provided arguments
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -48,9 +48,10 @@ cp "$CODE_DIR/scripts/"* "$APP_DIR/scripts/"
|
|||||||
# Give execution permission to all scripts
|
# Give execution permission to all scripts
|
||||||
chmod +x "$APP_DIR/scripts/"*
|
chmod +x "$APP_DIR/scripts/"*
|
||||||
|
|
||||||
# Run the manager.sh script with the "install" argument
|
mkdir -p "$HOME/.local/bin"
|
||||||
echo
|
ln -s "$APP_DIR/scripts/manager.sh" "$HOME/.local/bin/db-middleware"
|
||||||
echo "--------------------"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
echo
|
source ~/.bashrc
|
||||||
|
|
||||||
|
# Run the manager.sh script with the "install" argument
|
||||||
"$APP_DIR/scripts/manager.sh" install
|
"$APP_DIR/scripts/manager.sh" install
|
||||||
Reference in New Issue
Block a user