Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Lucksi
GitHub Repository: Lucksi/Mr.Holmes
Path: blob/master/Core/update.sh
1071 views
1
#!/bin/bash
2
# ORIGINAL CREATOR: Luca Garofalo (Lucksi)
3
# AUTHOR: Luca Garofalo (Lucksi)
4
# Copyright (C) 2021-2023 Lucksi <[email protected]>
5
# License: GNU General Public License v3.0
6
7
GREEN=$(tput setaf 2)
8
LIGHTBLUE=$(tput setaf 6)
9
WHITE=$(tput setaf 15)
10
11
function check {
12
attempts=5;
13
Password=$(sed -nr "/^\[Settings\]/ { :l /^password[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" <Configuration/Configuration.ini)
14
printf "${LIGHTBLUE}\nINSERT YOUR UPDATE PASSWORD YOU HAVE $attempts ATTEMPTS\n\n"
15
while [[ $attempts>0 ]];
16
do
17
read -sp "$GREEN[#MR.HOLMES#]$WHITE-->" pass
18
while [[ $pass == "" ]]
19
do
20
printf "${LIGHTBLUE}\n\nINSERT YOUR UPDATE PASSWORD YOU HAVE $attempts ATTEMPTS\n\n"
21
read -sp "$GREEN[#MR.HOLMES#]$WHITE-->" pass
22
done
23
if [ "$pass" == "$Password" ];
24
then
25
printf "${LIGHTBLUE}\n\nPASSWORD CORRECT!\n"
26
update
27
fi
28
((attempts=attempts-1))
29
printf "$LIGHTBLUE\n\nWRONG PASSWORD REMAINING: $attempts ATTEMPTS\n\n"
30
done
31
printf "${WHITE}\n\nYOU HAVE: $attempts PRESS ENTER TO EXIT"
32
read -p
33
exit 1
34
}
35
36
function update {
37
Update_path=$(sed -nr "/^\[Settings\]/ { :l /^path[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" <Configuration/Configuration.ini)
38
cd $Update_path
39
mv Mr.Holmes Mr.Holmes2 &>/dev/null
40
git clone https://github.com/Lucksi/Mr.Holmes &>/dev/null | printf "$WHITE\nUPDATING MR.HOLMES..\n"
41
42
if [ $? -eq 0 ];
43
then
44
cd $Update_path
45
printf "${WHITE}\nWOULD YOU LIKE TO DELETE THE OLD FILES?(1)YES(2)NO\n\n"
46
read -p "$GREEN[#MR.HOLMES#]$WHITE-->" conf
47
if [ $conf = 1 ];
48
then
49
rm -r Mr.Holmes2 &>/dev/null | printf "${LIGHTBLUE}\nDELETING OLD MR.HOLMES FILES"
50
else
51
printf "${LIGHTBLUE}\nKEEPING OLD MR.HOLMES FILES"
52
fi
53
sleep 2
54
printf "${WHITE}\n\nMR.HOLMES UPDATED CORRECTLY\n\n"
55
read -p "$GREEN[#MR.HOLMES#]$WHITE-->" confvar
56
printf "${WHITE}\nPRESS ENTER TO EXIT"
57
read -p
58
exit 1
59
60
fi
61
printf "${LIGHTBLUE}\n\nMR.HOLMES NOT INSTALLED HAVE YOU CHECKED YOUR INTERNET CONNECTION?\n\n"
62
mv Mr.Holmes2 Mr.Holmes
63
exit 1
64
}
65
check
66
67