Update the update.sh script regarding the issue #29

This commit is contained in:
Félix Aime 2020-12-29 09:19:12 +01:00
parent c89fa5508e
commit 42727f5eec

View File

@ -4,28 +4,44 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# Clone the current repo.
echo "[+] Cloning the current repository to /tmp/"
cd /tmp/ && git clone https://github.com/KasperskyLab/TinyCheck
if [ $PWD = "/usr/share/tinycheck" ]; then
echo "[+] Cloning the current repository to /tmp/"
rm -rf /tmp/tinycheck/ &> /dev/null
cd /tmp/ && git clone https://github.com/KasperskyLab/tinycheck
cd /tmp/tinycheck && bash update.sh
elif [ $PWD = "/tmp/tinycheck" ]; then
# Deleteing the current folders.
echo "[+] Deleting the current TinyCheck folders"
rm -rf /usr/share/tinycheck/app/
rm -rf /usr/share/tinycheck/server/
rm -rf /usr/share/tinycheck/analysis/
echo "[+] Saving current backend's SSL configuration in /tmp/"
mv /usr/share/tinycheck/server/backend/*.pem /tmp/
# Copying the folders.
echo "[+] Copying the new version"
cd /tmp/TinyCheck && cp -R app/ /usr/share/tinycheck/app/
cd /tmp/TinyCheck && cp -R server/ /usr/share/tinycheck/server/
cd /tmp/TinyCheck && cp -R analysis/ /usr/share/tinycheck/analysis/
echo "[+] Deleting the current TinyCheck folders and files."
rm -rf /usr/share/tinycheck/app/
rm -rf /usr/share/tinycheck/server/
rm -rf /usr/share/tinycheck/analysis/
rm /usr/share/tinycheck/update.sh
rm /usr/share/tinycheck/kiosk.sh
# Installing possible new dependencies.
echo "[+] Checking new Python dependencies"
cd /tmp/TinyCheck && python3 -m pip install -r assets/requirements.txt
echo "[+] Copying the new TinyCheck version"
cp -R app/ /usr/share/tinycheck/app/
cp -R server/ /usr/share/tinycheck/server/
cp -R analysis/ /usr/share/tinycheck/analysis/
cp update.sh /usr/share/tinycheck/update.sh
cp kiosk.sh /usr/share/tinycheck/kiosk.sh
# Back to the VueJS projects and reinstalling all the stuff
echo "[+] Building new interfaces..."
cd /usr/share/tinycheck/app/frontend/ && npm install && npm run build
cd /usr/share/tinycheck/app/backend/ && npm install && npm run build
echo "[+] TinyCheck updated!"
echo "[+] Retoring the backend's SSL configuration from /tmp/"
mv /tmp/*.pem /usr/share/tinycheck/server/backend/
echo "[+] Checking possible new Python dependencies"
python3 -m pip install -r assets/requirements.txt
echo "[+] Building new interfaces..."
cd /usr/share/tinycheck/app/frontend/ && npm install && npm run build
cd /usr/share/tinycheck/app/backend/ && npm install && npm run build
echo "[+] Restarting services"
service tinycheck-backend restart
service tinycheck-frontend restart
service tinycheck-watchers restart
echo "[+] TinyCheck updated!"
fi