-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-eFNC2.sh
executable file
·148 lines (129 loc) · 5.03 KB
/
install-eFNC2.sh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# Ask the user if they have already run the app
while true; do
read -p "Are you running the app for the first Time ? (yes/no) " ANSWER;
# Check if the user answered yes or no
if [ "${ANSWER}" == "yes" ] || [ "${ANSWER}" == "no" ]; then
break
else
echo "Please answer by yes or no";
fi
done
# If the user answered yes, we install the app
if [ "${ANSWER}" == "yes" ]
then
# Install git and PlasticOmnium docker repo
sudo yum install -y git yum-utils;
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo;
# Remove old docker version and install docker-ce
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
podman \
runc;
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y;
# Add the user to the docker group
sudo groupadd docker;
sudo usermod -aG docker $USER;
# Start docker and enable it inside a prompt with the docker group
sg docker -c "
sudo systemctl start docker;
sudo systemctl start containerd.service;
sudo systemctl enable docker.service;
sudo systemctl enable containerd.service;"
# Function to check for uppercase characters
contains_uppercase() {
[[ "$1" =~ [A-Z] ]]
}
# Ask the user for name of its github user
while true; do
read -p "Name of your github user (example: polangres) : " GITHUB_USER
if contains_uppercase "$GITHUB_USER"; then
echo "The github user name should not contain uppercase characters. Please try again."
else
break
fi
if [ -z "${GITHUB_USER}" ]
then
echo "The github user name should not be empty. Please try again."
fi
done
# Ask the user for the git repository address either in ssh or http
read -p "Address of the git repository (ssh or http // default: https://github.com/${GITHUB_USER}/efnc ) : " GIT_ADDRESS;
if [ -z "${GIT_ADDRESS}" ]
then
GIT_ADDRESS="https://github.com/${GITHUB_USER}/efnc"
fi
# Clone the git repository and run the env_create.sh script
git clone ${GIT_ADDRESS};
cd efnc;
bash ./env_create.sh ${GITHUB_USER};
# Build the docker containers
sg docker -c "docker compose up --build -d"
else
# If the user answered no, we will ask if he wants to launch the app or if he wants to update it
while true; do
read -p "Do you wish to launch the app ? (yes/no) " LAUNCH_ANSWER;
if [ "${LAUNCH_ANSWER}" == "yes" ] || [ "${LAUNCH_ANSWER}" == "no" ]; then
break
else
echo "Please answer by yes or no";
fi
done
# If the user answered yes, we launch the app
if [ "${LAUNCH_ANSWER}" == "yes" ]; then
cd efnc;
sg docker -c "docker compose up -d"
else
while true; do
read -p "Do you wish to update the app ? (yes/no) " UPDATE_ANSWER;
if [ "${UPDATE_ANSWER}" == "yes" ] || [ "${UPDATE_ANSWER}" == "no" ]; then
break
else
echo "Please answer by yes or no";
fi
done
if [ "${UPDATE_ANSWER}" == "yes" ]; then
# Function to check for uppercase characters
contains_uppercase() {
[[ "$1" =~ [A-Z] ]]
}
# Ask the user for name of its github user
while true; do
read -p "Name of your github user (example: polangres) : " GITHUB_USER
if contains_uppercase "$GITHUB_USER"; then
echo "The github user name should not contain uppercase characters. Please try again."
else
break
fi
if [ -z "${GITHUB_USER}" ]
then
echo "The github user name should not be empty. Please try again."
fi
done
# Ask the user for the git repository address either in ssh or http
read -p "Address of the git repository (ssh or http // default: https://github.com/${GITHUB_USER}/efnc ) : " GIT_ADDRESS;
if [ -z "${GIT_ADDRESS}" ]
then
GIT_ADDRESS="https://github.com/${GITHUB_USER}/efnc"
fi
cd efnc;
sg docker -c "docker compose stop";
sg docker -c "docker system prune -fa";
git remote remove origin;
# Remove everything before https in the GIT_ADDRESS
GIT_ADDRESS=$(echo ${GIT_ADDRESS} | sed 's|.*\(https\)|\1|')
git remote add origin ${GIT_ADDRESS};
git fetch origin --force;
git reset --hard origin/main;
git pull --rebase origin main;
bash ./env_update.sh ${GITHUB_USER};
sg docker -c "docker compose up --build -d"
fi
fi
fi