Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·67 lines (55 loc) · 1.96 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·67 lines (55 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Exit script on error
set -e
echo "🔄 Setting up the project..."
# Ensure Homebrew is installed (for macOS users)
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v brew &> /dev/null; then
echo "⚠️ Homebrew not found. Please install it from https://brew.sh/"
exit 1
fi
fi
# Install pipenv if not installed
if ! command -v pipenv &> /dev/null; then
echo "📦 pipenv not found. Installing pipenv..."
pip3 install --user pipenv
fi
# Install MongoDB (for macOS users)
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "🛠 Checking and installing MongoDB..."
if ! command -v mongosh &> /dev/null; then
brew tap mongodb/brew
brew install mongodb-community@7.0
fi
echo "🚀 Starting MongoDB service..."
brew services start mongodb-community@7.0
fi
# Verify MongoDB is running
echo "🛠 Checking if MongoDB is running..."
if ! pgrep -x "mongod" > /dev/null; then
echo "⚠️ MongoDB is not running. Please start it manually: mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db"
exit 1
fi
# Verify MongoDB connection
if command -v mongosh &> /dev/null; then
echo "✅ MongoDB installation verified. Connecting..."
mongosh --eval "db.runCommand({ connectionStatus: 1 })"
else
echo "❌ MongoDB shell (mongosh) not found. Ensure MongoDB is properly installed."
exit 1
fi
# Install project dependencies
echo "📦 Installing dependencies using pipenv..."
pipenv install
# Create MongoDB database and collection
echo "🛠 Setting up MongoDB database and collection..."
mongosh <<EOF
use apartmentsdb
db.createCollection("apartments")
print("✅ MongoDB setup complete: Database 'apartmentsdb' and collection 'apartments' created.")
use yad2db
db.createCollection("apartments")
print("✅ MongoDB setup complete: Database 'yad2db' and collection 'apartments' created.")
EOF
echo "🎉 Setup completed successfully!"
echo "ℹ️ To activate the virtual environment, run: pipenv shell"