From c909d5b20a01f9edf8242595114cad199e0303ca Mon Sep 17 00:00:00 2001 From: abdulhade Date: Tue, 11 Mar 2025 22:01:23 +0300 Subject: [PATCH] Added `app.conf` file --- scripts/app.conf | 8 ++++++++ scripts/manager.sh | 47 +++++++++++++++++++++++++++++++++++++++++----- scripts/setup.sh | 9 +++++---- 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 scripts/app.conf diff --git a/scripts/app.conf b/scripts/app.conf new file mode 100644 index 0000000..f79d12d --- /dev/null +++ b/scripts/app.conf @@ -0,0 +1,8 @@ + + +# Application settings +APP_NAME="Database Middleware" +APP_PORT=8080 + +# DatabaseS settings +DBS_PORTS=3306 diff --git a/scripts/manager.sh b/scripts/manager.sh index 8985b35..0aa8911 100755 --- a/scripts/manager.sh +++ b/scripts/manager.sh @@ -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 : -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 "$@" diff --git a/scripts/setup.sh b/scripts/setup.sh index 96ebd08..e49de17 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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 \ No newline at end of file