-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
105 lines (92 loc) · 2.64 KB
/
install.sh
File metadata and controls
105 lines (92 loc) · 2.64 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Default ports
POSTGRES_PORT=10001
REDIS_PORT=10002
MONGO_PORT=10003
SPRINGBOOT_PORT=10004
ANGULAR_PORT=10005
# Parse parameters
while [[ $# -gt 0 ]]; do
case $1 in
-u)
DATABASE_USERNAME="$2"
shift 2
;;
-p)
DATABASE_PASSWORD="$2"
shift 2
;;
-pp)
POSTGRES_PORT="$2"
shift 2
;;
-rp)
REDIS_PORT="$2"
shift 2
;;
-mp)
MONGO_PORT="$2"
shift 2
;;
-sp)
SPRINGBOOT_PORT="$2"
shift 2
;;
-ap)
ANGULAR_PORT="$2"
shift 2
;;
*)
echo "Unknown parameter: $1" >&2
exit 1
;;
esac
done
# Check required parameters
if [ -z "$DATABASE_USERNAME" ] || [ -z "$DATABASE_PASSWORD" ]; then
echo "Error: You must provide -u <username> and -p <password> as parameters." >&2
exit 1000
fi
# Export variables for child scripts
export DATABASE_USERNAME
export DATABASE_PASSWORD
export SMART_SHELL_POSTGRES_PORT="$POSTGRES_PORT"
export SMART_SHELL_REDIS_PORT="$REDIS_PORT"
export SMART_SHELL_MONGO_PORT="$MONGO_PORT"
export SMART_SHELL_SPRINGBOOT_PORT="$SPRINGBOOT_PORT"
export SMART_SHELL_ANGULAR_PORT="$ANGULAR_PORT"
# Verify if the network exists
if ! sudo docker network inspect smart-shell-net &>/dev/null; then
sudo docker network create --driver bridge smart-shell-net
else
echo "La red 'smart-shell-net' ya existe."
fi
# Create directory deployments and volumes
if [ ! -d "/var/www/smart-shell/deployments" ]; then
sudo mkdir -p /var/www/smart-shell/deployments
git config --global --add safe.directory "/var/www/smart-shell/deployments"
fi
if [ ! -d "/var/www/smart-shell/volumes" ]; then
sudo mkdir -p /var/www/smart-shell/volumes
fi
if [ ! -d "/var/www/smart-shell/backups" ]; then
sudo mkdir -p /var/www/smart-shell/backups
fi
sudo chown -R $USER:$USER /var/www/smart-shell
# Chmod scripts
sudo chmod +x ./scripts/install/postgres.sh
sudo chmod +x ./scripts/install/redis.sh
sudo chmod +x ./scripts/install/mongo.sh
sudo chmod +x ./scripts/install/java.sh
sudo chmod +x ./scripts/install/angular.sh
sudo chmod +x ./scripts/deploy/postgres.sh
sudo chmod +x ./scripts/deploy/redis.sh
sudo chmod +x ./scripts/deploy/mongo.sh
sudo chmod +x ./scripts/deploy/java.sh
sudo chmod +x ./scripts/deploy/angular.sh
# Execute installation scripts
bash ./scripts/install/postgres.sh &&
bash ./scripts/install/redis.sh &&
bash ./scripts/install/mongo.sh &&
bash ./scripts/install/java.sh &&
bash ./scripts/install/angular.sh