handle custom certs in backup/restore
This commit is contained in:
parent
84c858b878
commit
fa19538c9d
18
backup.sh
18
backup.sh
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_VERSION="27"
|
||||
SCRIPT_VERSION="28"
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
|
@ -89,7 +89,19 @@ fi
|
|||
|
||||
tar -czvf ${tmp_dir}/meshcentral/mesh.tar.gz --exclude=/meshcentral/node_modules /meshcentral
|
||||
|
||||
sudo tar -czvf ${tmp_dir}/certs/etc-letsencrypt.tar.gz -C /etc/letsencrypt .
|
||||
if [ -d /etc/letsencrypt ]; then
|
||||
sudo tar -czvf ${tmp_dir}/certs/etc-letsencrypt.tar.gz -C /etc/letsencrypt .
|
||||
fi
|
||||
|
||||
local_settings='/rmm/api/tacticalrmm/tacticalrmm/local_settings.py'
|
||||
|
||||
if grep -q CERT_FILE "$local_settings"; then
|
||||
mkdir -p ${tmp_dir}/certs/custom
|
||||
CERT_FILE=$(grep "^CERT_FILE" "$local_settings" | awk -F'[= "]' '{print $5}')
|
||||
KEY_FILE=$(grep "^KEY_FILE" "$local_settings" | awk -F'[= "]' '{print $5}')
|
||||
cp -p $CERT_FILE ${tmp_dir}/certs/custom/cert
|
||||
cp -p $KEY_FILE ${tmp_dir}/certs/custom/key
|
||||
fi
|
||||
|
||||
for i in rmm frontend meshcentral; do
|
||||
sudo cp /etc/nginx/sites-available/${i}.conf ${tmp_dir}/nginx/
|
||||
|
@ -99,7 +111,7 @@ sudo tar -czvf ${tmp_dir}/confd/etc-confd.tar.gz -C /etc/conf.d .
|
|||
|
||||
sudo cp ${sysd}/rmm.service ${sysd}/celery.service ${sysd}/celerybeat.service ${sysd}/meshcentral.service ${sysd}/nats.service ${sysd}/daphne.service ${sysd}/nats-api.service ${tmp_dir}/systemd/
|
||||
|
||||
cp /rmm/api/tacticalrmm/tacticalrmm/local_settings.py ${tmp_dir}/rmm/
|
||||
cp $local_settings ${tmp_dir}/rmm/
|
||||
|
||||
if [[ $* == *--auto* ]]; then
|
||||
|
||||
|
|
24
restore.sh
24
restore.sh
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_VERSION="49"
|
||||
SCRIPT_VERSION="50"
|
||||
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/restore.sh'
|
||||
|
||||
sudo apt update
|
||||
|
@ -193,10 +193,24 @@ sudo apt install -y certbot openssl
|
|||
|
||||
print_green 'Restoring certs'
|
||||
|
||||
sudo rm -rf /etc/letsencrypt
|
||||
sudo mkdir /etc/letsencrypt
|
||||
sudo tar -xzf $tmp_dir/certs/etc-letsencrypt.tar.gz -C /etc/letsencrypt
|
||||
sudo chown ${USER}:${USER} -R /etc/letsencrypt
|
||||
if [ -f "$tmp_dir/certs/etc-letsencrypt.tar.gz" ]; then
|
||||
sudo rm -rf /etc/letsencrypt
|
||||
sudo mkdir /etc/letsencrypt
|
||||
sudo tar -xzf $tmp_dir/certs/etc-letsencrypt.tar.gz -C /etc/letsencrypt
|
||||
sudo chown ${USER}:${USER} -R /etc/letsencrypt
|
||||
fi
|
||||
|
||||
if [ -d "${tmp_dir}/certs/custom" ]; then
|
||||
CERT_FILE=$(grep "^CERT_FILE" "$tmp_dir/rmm/local_settings.py" | awk -F'[= "]' '{print $5}')
|
||||
KEY_FILE=$(grep "^KEY_FILE" "$tmp_dir/rmm/local_settings.py" | awk -F'[= "]' '{print $5}')
|
||||
|
||||
sudo mkdir -p $(dirname $CERT_FILE) $(dirname $KEY_FILE)
|
||||
sudo chown ${USER}:${USER} $(dirname $CERT_FILE) $(dirname $KEY_FILE)
|
||||
|
||||
cp -p ${tmp_dir}/certs/custom/cert $CERT_FILE
|
||||
cp -p ${tmp_dir}/certs/custom/key $KEY_FILE
|
||||
|
||||
fi
|
||||
|
||||
print_green 'Restoring celery configs'
|
||||
|
||||
|
|
Loading…
Reference in New Issue