-
Notifications
You must be signed in to change notification settings - Fork 4
/
install-opsign.sh
executable file
·106 lines (92 loc) · 3.53 KB
/
install-opsign.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
#!/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;"
# 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/polangres/opsign ) : " GIT_ADDRESS;
if [ -z "${GIT_ADDRESS}" ]
then
GIT_ADDRESS="https://github.com/polangres/opsign"
fi
# Clone the git repository and run the env-create.sh script
git clone ${GIT_ADDRESS};
cd opsign;
bash ./env-create.sh;
# 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 opsign;
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
# 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/polangres/opsign ) : " GIT_ADDRESS;
if [ -z "${GIT_ADDRESS}" ]
then
GIT_ADDRESS="https://github.com/polangres/opsign"
fi
cd opsign;
sg docker -c "docker compose stop";
git remote remove origin;
git remote add origin ${GIT_ADDRESS};
git fetch origin --force;
git reset --hard origin/main;
git pull --rebase origin main;
bash ./env-update.sh;
sg docker -c "docker compose up --build -d"
fi
fi
fi