From 81f97d46e89e94aa00eff9c376c779f248a3e08a Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 6 Oct 2023 08:07:30 +0200 Subject: [PATCH 1/3] do a safer migration --- convertfromos.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/convertfromos.sh b/convertfromos.sh index d249b3c..a2d7917 100644 --- a/convertfromos.sh +++ b/convertfromos.sh @@ -87,27 +87,33 @@ sudo rm -f /etc/systemd/system/gohttpserver.service sudo rm -f /etc/systemd/system/rustdesksignal.service sudo rm -f /etc/systemd/system/rustdeskrelay.service -# We need to create the new install dir before the migration task, otherwise mv will fail -mkdir -p "$RUSTDESK_INSTALL_DIR" - -# Migration tasks -if [ -d /opt/rustdesk ] -then - mv /opt/rustdesk/id_* "$RUSTDESK_INSTALL_DIR/" - rm -rf /opt/rustdesk -fi - # Install Rustdesk again # It won't install RustDesk again since there's a check in the install script which checks for the installation folder, but services and everything else will be created # Would it be possible to move L93-98 after the installation? if ! curl -fSLO --retry 3 https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/install.sh msg_box "Sorry, we couldn't fetch the install script, please try again. -Your old installation now lives in $RUSTDESK_INSTALL_DIR" +Your old installation still lives in /opt/rustdesk" exit else - if sudo bash install.sh + if sudo bash -x install.sh then rm -f install.sh + # Migration tasks + if [ -d /opt/rustdesk ] + then + # First remove the keys generated by the installation script + rm -f "$RUSTDESK_INSTALL_DIR"/id_* + # Then copy over the old keys to the new install dir + # Only remove the old dir if the copy was succesful + if cp -f /opt/rustdesk/id_* "$RUSTDESK_INSTALL_DIR/" + then + rm -rf /opt/rustdesk + else + msg_box "Sorry, but it seems that something went wrong with copying your old keys to the new install dir. Please try again" + exit 1 + fi + fi +fi msg_box "Conversion from OS seems to have been OK!" else msg_box "Sorry, but something seems to have gone wrong, please report this to: From b5801a9bfade519d6734df51cbfc93c041e4dc5b Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 6 Oct 2023 08:11:37 +0200 Subject: [PATCH 2/3] Fix SC --- convertfromos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convertfromos.sh b/convertfromos.sh index a2d7917..1b487d9 100644 --- a/convertfromos.sh +++ b/convertfromos.sh @@ -91,6 +91,7 @@ sudo rm -f /etc/systemd/system/rustdeskrelay.service # It won't install RustDesk again since there's a check in the install script which checks for the installation folder, but services and everything else will be created # Would it be possible to move L93-98 after the installation? if ! curl -fSLO --retry 3 https://raw.githubusercontent.com/rustdesk/rustdesk-server-pro/main/install.sh +then msg_box "Sorry, we couldn't fetch the install script, please try again. Your old installation still lives in /opt/rustdesk" exit @@ -113,7 +114,6 @@ else exit 1 fi fi -fi msg_box "Conversion from OS seems to have been OK!" else msg_box "Sorry, but something seems to have gone wrong, please report this to: From 66e8be41764b4b13c5ec6b40f444884dd93991e0 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 6 Oct 2023 08:18:28 +0200 Subject: [PATCH 3/3] be extra careful --- convertfromos.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/convertfromos.sh b/convertfromos.sh index 1b487d9..5bb2277 100644 --- a/convertfromos.sh +++ b/convertfromos.sh @@ -105,10 +105,15 @@ else # First remove the keys generated by the installation script rm -f "$RUSTDESK_INSTALL_DIR"/id_* # Then copy over the old keys to the new install dir - # Only remove the old dir if the copy was succesful if cp -f /opt/rustdesk/id_* "$RUSTDESK_INSTALL_DIR/" then - rm -rf /opt/rustdesk + # Make sure to really protect the old keys by checking that the new service actually restarts with 0 status before removing the old keys. + if systemctl restart rustdesk-hbbr.service && systemctl restart rustdesk-hbbs.service + then + rm -rf /opt/rustdesk + else + msg_box "Sorry, couldn't restart the new services. Please send your output to https://github.com/rustdesk/rustdesk-server-pro in a new issue." + fi else msg_box "Sorry, but it seems that something went wrong with copying your old keys to the new install dir. Please try again" exit 1