2020-11-26 09:03:24 +01:00
|
|
|
# Checking rights.
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "The update must be run as root. Type in 'sudo bash $0' to run it as root."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-29 09:19:12 +01:00
|
|
|
if [ $PWD = "/usr/share/tinycheck" ]; then
|
|
|
|
echo "[+] Cloning the current repository to /tmp/"
|
|
|
|
rm -rf /tmp/tinycheck/ &> /dev/null
|
2021-02-19 16:40:52 +01:00
|
|
|
cd /tmp/ && git clone https://github.com/KasperskyLab/tinycheck
|
2020-12-29 09:19:12 +01:00
|
|
|
cd /tmp/tinycheck && bash update.sh
|
|
|
|
elif [ $PWD = "/tmp/tinycheck" ]; then
|
|
|
|
|
|
|
|
echo "[+] Saving current backend's SSL configuration in /tmp/"
|
|
|
|
mv /usr/share/tinycheck/server/backend/*.pem /tmp/
|
|
|
|
|
|
|
|
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
|
2020-12-29 11:00:18 +01:00
|
|
|
rm /usr/share/tinycheck/uninstall.sh
|
2020-12-29 09:19:12 +01:00
|
|
|
|
|
|
|
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
|
2020-12-29 11:00:18 +01:00
|
|
|
cp uninstall.sh /usr/share/tinycheck/uninstall.sh
|
2020-12-29 09:19:12 +01:00
|
|
|
|
|
|
|
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..."
|
2021-04-24 22:46:23 +02:00
|
|
|
cd /usr/share/tinycheck/app/frontend/ && npm install && npm audit fix && npm run build
|
2021-04-25 11:09:35 +02:00
|
|
|
cd /usr/share/tinycheck/app/backend/ && npm install && npm audit fix && npm run build
|
2020-12-29 09:19:12 +01:00
|
|
|
|
2021-02-17 20:16:39 +01:00
|
|
|
echo "[+] Updating current configuration with new values."
|
2021-01-11 13:42:29 +01:00
|
|
|
if ! grep -q reboot_option /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i 's/frontend:/frontend:\n reboot_option: true/g' /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
2021-02-09 08:51:55 +01:00
|
|
|
|
|
|
|
if ! grep -q user_lang /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i 's/frontend:/frontend:\n user_lang: en/g' /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
|
|
|
|
2021-01-11 13:42:29 +01:00
|
|
|
if ! grep -q shutdown_option /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i 's/frontend:/frontend:\n shutdown_option: true/g' /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q quit_option /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i 's/frontend:/frontend:\n quit_option: true/g' /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
|
|
|
|
2021-02-16 18:57:10 +01:00
|
|
|
if ! grep -q active /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i 's/analysis:/analysis:\n active: true/g' /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
|
|
|
|
2021-02-18 22:53:49 +01:00
|
|
|
if ! grep -q update /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i 's/frontend:/frontend:\n update: true/g' /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
|
|
|
|
2021-01-20 20:18:01 +01:00
|
|
|
if ! grep -q "CN=R3,O=Let's Encrypt,C=US" /usr/share/tinycheck/config.yaml; then
|
|
|
|
sed -i "s/free_issuers:/free_issuers:\n - CN=R3,O=Let's Encrypt,C=US/g" /usr/share/tinycheck/config.yaml
|
|
|
|
fi
|
|
|
|
|
2021-02-17 20:16:39 +01:00
|
|
|
echo "[+] Restarting services"
|
|
|
|
service tinycheck-backend restart
|
|
|
|
service tinycheck-frontend restart
|
|
|
|
service tinycheck-watchers restart
|
|
|
|
|
|
|
|
echo "[+] Updating the TinyCheck version"
|
2021-02-19 10:46:29 +01:00
|
|
|
cd /tmp/tinycheck && git tag | tail -n 1 | xargs echo -n > /usr/share/tinycheck/VERSION
|
2021-02-17 20:16:39 +01:00
|
|
|
|
2020-12-29 09:19:12 +01:00
|
|
|
echo "[+] TinyCheck updated!"
|
2021-04-24 22:46:23 +02:00
|
|
|
fi
|