Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -1,6 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MONGO_DBPATH="${MONGO_DBPATH:-$SCRIPT_DIR/data/db}"
|
||||
MONGO_LOGPATH="${MONGO_LOGPATH:-$SCRIPT_DIR/data/mongod.log}"
|
||||
|
||||
start_mongodb_if_needed() {
|
||||
if ! command -v mongod >/dev/null 2>&1; then
|
||||
echo "Error: mongod not found. Install MongoDB first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if pgrep -x mongod >/dev/null 2>&1; then
|
||||
echo "MongoDB already running."
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p "$MONGO_DBPATH"
|
||||
echo "Starting MongoDB with dbPath: $MONGO_DBPATH"
|
||||
mongod --dbpath "$MONGO_DBPATH" --bind_ip 127.0.0.1 --port 27017 --fork --logpath "$MONGO_LOGPATH"
|
||||
}
|
||||
|
||||
start_mongodb_if_needed
|
||||
|
||||
# Clean up any existing MongoDB repos to avoid conflicts
|
||||
echo "=== Cleaning up existing MongoDB repositories ==="
|
||||
sudo rm -f /etc/apt/sources.list.d/mongodb*.list
|
||||
@@ -73,6 +95,7 @@ if ! command -v patchelf >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pip install --upgrade pip
|
||||
pip install -U nuitka ordered-set zstandard flask flask-jwt-extended cryptography pyotp qrcode bleach
|
||||
|
||||
python -m nuitka --standalone --follow-imports --include-data-dir=templates=templates --include-data-dir=static=static --include-data-dir=data=data --assume-yes-for-downloads --output-dir=build --remove-output main.py
|
||||
|
||||
Reference in New Issue
Block a user