-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall-eFNC2.sh
executable file
·174 lines (140 loc) · 5.65 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
# Get the github user and the podman from the argument
GITHUB_USER=$1
PODMAN=$2
echo "github user: ${GITHUB_USER}"
echo "podman: ${PODMAN}"
# 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
sudo yum install -y git yum-utils;
# If the user answered yes, we install the app
if [ "${ANSWER}" == "yes" ]; then
# Ask the user for the git repository address either in ssh or http
read -p "Address of the git repository (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;
if [ "${PODMAN}" == "no" ]; then
# Function to check for uppercase characters
contains_uppercase() {
[[ "$1" =~ [A-Z] ]]
}
# Install git and PlasticOmnium docker repo
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;
# Connect to the github docker registry
# docker login ghcr.io -u $GITHUB_USER -p $GITHUB_TOKEN;
# 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;"
bash ./env_create_docker.sh ${GITHUB_USER};
# Build the docker containers
sg docker -c "docker compose up --build -d"
else
bash ./env_create_podman.sh ${GITHUB_USER};
podman play kube --replace ./efnc.yml;
fi
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;
if [ "${PODMAN}" == "no" ]; then
sg docker -c "docker compose up -d"
else
podman play kube --replace ./efnc.yml;
fi
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 the git repository address either in ssh or http
read -p "Address of the git repository (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;
if [ "${PODMAN}" == "no" ]; then
sg docker -c "docker compose stop";
sg docker -c "docker system prune -fa";
else
podman play kube --down ./efnc.yml;
podman system prune -fa;
fi
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;
if [ "${PODMAN}" == "no" ]; then
bash ./env_update_docker.sh ${GITHUB_USER};
sg docker -c "docker compose up --build -d"
# Wait until the webpack compiled successfully
until docker compose logs --since 10s --tail 10 web 2>&1 | grep -q "webpack compiled successfully"; do
echo "Waiting for the app to be updated"
sleep 10
done
echo "EFNC updated successfully";
else
bash ./env_update_podman.sh ${GITHUB_USER};
podman play kube --replace ./efnc.yml;
# Wait until the webpack compiled successfully
until podman logs --since 10s --tail 10 web-docauposte 2>&1 | grep -q "webpack compiled successfully"; do
echo "Waiting for the app to be updated"
sleep 10
done
echo "EFNC updated successfully";
fi
fi
fi
fi