From ef86fcaf95058d49fc9161075876b6cd3b812b82 Mon Sep 17 00:00:00 2001 From: abdulhade Date: Mon, 10 Mar 2025 17:23:35 +0300 Subject: [PATCH] Added bash scripts as placeholders --- scripts/install.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/manager.sh | 1 + 2 files changed, 53 insertions(+) create mode 100755 scripts/install.sh create mode 100755 scripts/manager.sh diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..4c8e6ef --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,52 @@ + +#!/bin/bash + +# Directory for the code +APP_DIR="$HOME/.db-middleware" +CODE_DIR="$HOME/.db-middleware/code" + +# Git repository URL +REPO_URL="https://gitea.abdulhade.com/abdulhade/db-middleware.git" + +# Check if the code directory exists +if [[ ! -d "$CODE_DIR" ]]; then + echo "Creating code directory at $CODE_DIR..." +fi + +mkdir -p ~/.db-middleware/{code,configs,scripts} + +# Navigate to the code directory +cd "$CODE_DIR" || { echo "Failed to navigate to $CODE_DIR"; exit 1; } + +# Check if the directory is empty +if [[ -z "$(ls -A $CODE_DIR)" ]]; then + echo "Directory is empty. Cloning repository..." + git clone "$REPO_URL" . +else + # Check if the directory contains a Git repository + if [[ -d ".git" ]]; then + echo "Directory contains a Git repository. Pulling latest changes..." + git pull "$REPO_URL" + else + echo "Directory is not empty and does not contain a Git repository." + echo "Please ensure the directory is empty or contains a valid Git repository." + exit 1 + fi +fi + +# Check if the operation was successful +if [[ $? -eq 0 ]]; then + echo "Repository setup completed successfully." +else + echo "Failed to set up the repository." + exit 1 +fi + +# Copy scripts from the code directory to the app directory +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 +"$APP_DIR/scripts/manager.sh" install \ No newline at end of file diff --git a/scripts/manager.sh b/scripts/manager.sh new file mode 100755 index 0000000..79f1bc6 --- /dev/null +++ b/scripts/manager.sh @@ -0,0 +1 @@ +docker build -t db-middleware . \ No newline at end of file