2019-12-15 05:37:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-08-25 18:09:45 +00:00
|
|
|
SCRIPT_VERSION="6"
|
2020-08-12 09:00:40 +00:00
|
|
|
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/develop/update.sh'
|
|
|
|
YELLOW='\033[1;33m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
NC='\033[0m'
|
|
|
|
|
|
|
|
TMP_FILE=$(mktemp -p "" "rmmupdate_XXXXXXXXXX")
|
|
|
|
curl -s -L "${SCRIPT_URL}" > ${TMP_FILE}
|
|
|
|
NEW_VER=$(grep "^SCRIPT_VERSION" "$TMP_FILE" | awk -F'[="]' '{print $3}')
|
|
|
|
|
|
|
|
if [ "${SCRIPT_VERSION}" \< "${NEW_VER}" ]; then
|
|
|
|
printf >&2 "${YELLOW}A newer version of this update script is available.${NC}\n"
|
|
|
|
printf >&2 "${YELLOW}Please download the latest version from ${GREEN}${SCRIPT_URL}${YELLOW} and re-run.${NC}\n"
|
|
|
|
rm -f $TMP_FILE
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f $TMP_FILE
|
|
|
|
|
2020-08-19 20:15:17 +00:00
|
|
|
if [ $EUID -eq 0 ]; then
|
|
|
|
echo -ne "\033[0;31mDo NOT run this script as root. Exiting.\e[0m\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-07-05 00:59:55 +00:00
|
|
|
for i in celery celerybeat rmm nginx
|
2019-12-16 22:45:18 +00:00
|
|
|
do
|
|
|
|
sudo systemctl stop ${i}
|
|
|
|
done
|
|
|
|
|
2020-08-25 18:09:45 +00:00
|
|
|
|
2020-08-25 00:38:23 +00:00
|
|
|
sudo chown ${USER}:${USER} -R /rmm
|
|
|
|
sudo chown ${USER}:${USER} /var/log/celery
|
|
|
|
sudo chown ${USER}:${USER} -R /srv/salt/
|
|
|
|
sudo chown ${USER}:www-data /srv/salt/scripts/userdefined
|
|
|
|
sudo chown -R $USER:$GROUP /home/${USER}/.npm
|
|
|
|
sudo chown -R $USER:$GROUP /home/${USER}/.config
|
2020-08-25 18:09:45 +00:00
|
|
|
sudo chown -R $USER:$GROUP /home/${USER}/.cache
|
2020-08-25 00:38:23 +00:00
|
|
|
sudo chmod 750 /srv/salt/scripts/userdefined
|
|
|
|
|
2020-06-28 05:18:31 +00:00
|
|
|
cd /rmm
|
2020-01-15 20:59:45 +00:00
|
|
|
git fetch origin develop
|
|
|
|
git reset --hard FETCH_HEAD
|
|
|
|
git clean -df
|
2020-06-28 05:18:31 +00:00
|
|
|
cp /rmm/_modules/* /srv/salt/_modules/
|
|
|
|
cp /rmm/scripts/* /srv/salt/scripts/
|
|
|
|
rm -rf /rmm/api/env
|
|
|
|
cd /rmm/api
|
|
|
|
python3 -m venv env
|
|
|
|
source /rmm/api/env/bin/activate
|
|
|
|
cd /rmm/api/tacticalrmm
|
2020-05-11 20:32:37 +00:00
|
|
|
pip install --no-cache-dir --upgrade pip
|
2020-08-16 21:08:32 +00:00
|
|
|
pip install --no-cache-dir setuptools==49.6.0 wheel==0.35.1
|
2020-05-11 20:32:37 +00:00
|
|
|
pip install --no-cache-dir -r requirements.txt
|
2020-08-13 01:53:24 +00:00
|
|
|
python manage.py pre_update_tasks
|
2019-12-15 05:37:47 +00:00
|
|
|
python manage.py migrate
|
2020-02-02 09:30:50 +00:00
|
|
|
python manage.py delete_tokens
|
2020-07-19 10:45:34 +00:00
|
|
|
python manage.py fix_salt_key
|
2020-08-10 20:29:42 +00:00
|
|
|
python manage.py collectstatic --no-input
|
2020-08-13 01:53:24 +00:00
|
|
|
python manage.py post_update_tasks
|
2019-12-15 05:37:47 +00:00
|
|
|
deactivate
|
|
|
|
|
|
|
|
|
2020-06-28 05:18:31 +00:00
|
|
|
rm -rf /rmm/web/node_modules
|
|
|
|
rm -rf /rmm/web/dist
|
|
|
|
cd /rmm/web
|
2019-12-15 05:37:47 +00:00
|
|
|
npm install
|
|
|
|
npm run build
|
|
|
|
sudo rm -rf /var/www/rmm/dist
|
2020-06-28 05:18:31 +00:00
|
|
|
sudo cp -pvr /rmm/web/dist /var/www/rmm/
|
2019-12-15 05:37:47 +00:00
|
|
|
sudo chown www-data:www-data -R /var/www/rmm/dist
|
|
|
|
|
2020-07-05 00:59:55 +00:00
|
|
|
for i in celery celerybeat rmm nginx
|
2019-12-16 22:45:18 +00:00
|
|
|
do
|
|
|
|
sudo systemctl start ${i}
|
|
|
|
done
|
2020-06-14 19:52:20 +00:00
|
|
|
|
|
|
|
sudo systemctl stop meshcentral
|
2020-08-25 00:38:23 +00:00
|
|
|
sudo chown ${USER}:${USER} -R /meshcentral
|
2020-06-14 19:52:20 +00:00
|
|
|
cd /meshcentral
|
|
|
|
rm -rf node_modules/
|
|
|
|
npm install meshcentral@latest
|
|
|
|
sudo systemctl start meshcentral
|
2020-08-12 09:00:40 +00:00
|
|
|
sleep 10
|
|
|
|
|
|
|
|
printf >&2 "${GREEN}Update finished!${NC}\n"
|