-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
216 lines (198 loc) · 6.36 KB
/
install.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
WHITE='\033[0;37m'
BLUE='\033[0;36m'
GREEN='\033[0;32m'
RED='\033[0;31m'
BWhite='\033[1;37m'
NC='\033[0m'
set -e
packages_ubuntu=(
gcc
libbsd-dev
libncurses-dev
valgrind
python3-pip
git
)
#which clang
packages_arch=(
gcc
clang
postgresql
libbsd
ncurses
valgrind
python-pip
git
)
## check if
check=1
cd
if [ -z "${INSTALL_DIR}" ]; then
INSTALL_DIR=$HOME
read -p "Install Directory (default: $INSTALL_DIR): " user_input
INSTALL_DIR=${user_input:-$INSTALL_DIR}
fi
export INSTALL_DIR
if [ "$(uname)" != "Darwin" ]; then
case $(lsb_release -is) in
"Ubuntu")
for package in "${packages_ubuntu[@]}"; do
if dpkg -s "$package" &> /dev/null; then
echo "✔️ $package is installed."
else
echo "❌ $package is not installed."
check=0
fi
done
;;
"Debian")
for package in "${packages_ubuntu[@]}"; do
if dpkg -s "$package" &> /dev/null; then
echo "✔️ $package is installed."
else
echo "❌ $package is not installed."
check=0
fi
done
;;
"Arch")
for package in "${packages_arch[@]}"; do
if pacman -Qi "$package" &> /dev/null; then
echo "✔️ $package is installed."
else
echo "❌ $package is not installed."
check=0
fi
done
;;
"EndeavourOS")
for package in "${packages_arch[@]}"; do
if pacman -Qi "$package" &> /dev/null; then
echo "✔️ $package is installed."
else
echo "❌ $package is not installed."
check=0
fi
done
;;
*)
check=0
;;
esac
else
check=0
fi
if [ "$check" -eq 1 ]; then
rm -rf $INSTALL_DIR/.tmp_francinette
echo -e "${BLUE} [Francinette] The francinette-image is useless!${RESET}"
read -p "Do you want to force the installation of francinette-image? (y/N) " answer
if [ -z "$answer" ]; then
answer="n"
fi
if [[ "$answer" =~ ^[Yy]$ ]]; then
check=0;
else
if ! ls -l $INSTALL_DIR | grep "francinette-image" &> /dev/null; then
mkdir -p "$INSTALL_DIR/.tmp_francinette-image"
git clone https://github.com/WaRtr0/francinette-image.git "$INSTALL_DIR/.tmp_francinette/francinette-image"
source "$INSTALL_DIR/.tmp_francinette/francinette-image/utils/remove_docker.sh"
source "$INSTALL_DIR/.tmp_francinette/francinette-image/utils/remove_zshrc.sh"
rm -rf "$INSTALL_DIR/francinette-image" "$INSTALL_DIR/.tmp_francinette-image"
echo -e "${BLUE}Francinette-image${GREEB} Uninstalled OK${RESET}"
fi
if ls -l $INSTALL_DIR | grep "francinette" &> /dev/null; then
rm -rf $INSTALL_DIR/francinette
echo -e "${BLUE}Francinette${GREEB} Uninstalled OK${RESET}"
fi
echo -e "${GREEN} Installation of the original francinette in progress${RESET}"
git clone --recursive https://github.com/xicodomingues/francinette.git "$INSTALL_DIR/francinette"
cd $INSTALL_DIR/francinette
if pip install -r requirements.txt ; then
sed -i '/^source/d' tester.sh
RC_FILE="$INSTALL_DIR/.zshrc"
if ! which python &>/dev/null; then
if which python3 &>/dev/null; then
sed -i 's/python/python3/g' tester.sh
else
echo -e "${RED} Python No Found${RESET}"
check=0
fi
fi
if ! grep -q "alias paco=" "$RC_FILE"; then
echo "alias paco='$INSTALL_DIR/francinette/tester.sh'" >> "$RC_FILE"
fi
else
if which pip &>/dev/null; then
echo "${RED}Installation of python packages interrupted"
echo "${YELLOW}Your operating system encourages installing Python packages in an isolated environment."
read -p "Do you want to force installation in the system environment ? (y/N) " answer
if [ -z "$answer" ]; then
answer="n"
fi
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "Forcing installation in the system environment...${RESET}"
if pip install --break-system-packages -r requirements.txt ; then
sed -i '/^source/d' tester.sh
RC_FILE="$INSTALL_DIR/.zshrc"
if ! which python &>/dev/null; then
if which python3 &>/dev/null; then
sed -i 's/python/python3/g' tester.sh
else
echo -e "${RED} Python No Found${RESET}"
check=0
fi
fi
if ! grep -q "alias paco=" "$RC_FILE"; then
echo "alias paco='$INSTALL_DIR/francinette/tester.sh'" >> "$RC_FILE"
fi
fi
else
read -p "Would you like to install the francinette-image instead? (Y/n) " answer
if [ -z "$answer" ]; then
answer="y"
fi
if [[ "$answer" =~ ^[Yy]$ ]]; then
check=0;
else
echo -e "${RED}Francinette installation failed${RESET}"
exit ;
fi
fi
else
check=0;
fi
fi
fi
fi
if [ "$check" -eq 0 ]; then
rm -rf $INSTALL_DIR/.tmp_francinette
echo -e "${GREEN} Installation of the francinette-image in progress${RESET}"
if ls -l $INSTALL_DIR | grep "francinette" &> /dev/null; then
rm -rf $INSTALL_DIR/francinette
echo -e "${BLUE}Francinette${GREEB} Uninstalled OK${RESET}"
fi
if ! ls -l $INSTALL_DIR | grep "francinette-image" &> /dev/null; then
git clone https://github.com/WaRtr0/francinette-image.git $INSTALL_DIR/francinette-image
fi
chmod +x $INSTALL_DIR/francinette-image/run.sh
if ! ls -l $INSTALL_DIR/francinette-image | grep "francinette.tar" &> /dev/null; then
if hostname | grep "42lyon.fr" &> /dev/null; then
if ls -l /sgoinfre/goinfre/Perso/mmorot/share | grep "francinette.tar" &> /dev/null; then
echo -e "${BLUE}[Francinette] ${WHITE}Copy of francinette.tar (${BWhite}/sgoinfre/goinfre/Perso/mmorot/share${WHITE})${RESET}"
cp /sgoinfre/goinfre/Perso/mmorot/share/francinette.tar $INSTALL_DIR/francinette-image/
echo -e "${BLUE}[Francinette] ${WHITE}Copy ${GREEN}OK${RESET}"
fi
fi
fi
if ! ls -l $INSTALL_DIR/francinette-image | grep "francinette.tar" &> /dev/null; then
docker build -t francinette-image $INSTALL_DIR/francinette-image
docker image save francinette-image > $INSTALL_DIR/francinette-image/francinette.tar
fi
if ls -l $INSTALL_DIR/francinette-image | grep "francinette.tar" &> /dev/null; then
docker load < $INSTALL_DIR/francinette-image/francinette.tar
fi
source $INSTALL_DIR/francinette-image/utils/install_zshrc.sh
fi
echo -e "${BLUE}[Francinette] ${GREEN}Installation completed!\n${WHITE}Use the ${BWhite}paco${WHITE} or ${BWhite}francinette${WHITE} commands in your project folder.${RESET}"
exec "$SHELL"