diff --git a/convertfromos.sh b/convertfromos.sh index d249b3c..5bb2277 100644 --- a/convertfromos.sh +++ b/convertfromos.sh @@ -87,27 +87,38 @@ 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 +then 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 + if cp -f /opt/rustdesk/id_* "$RUSTDESK_INSTALL_DIR/" + then + # 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 + 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: