A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
fix: don't require credentials input on re-install with data preserved on linux installation
towfiqidee87c24cb0d
diff --git a/installers/linux-server/install.sh b/installers/linux-server/install.shindex 5605a9a..ed4e0bc 100644--- a/installers/linux-server/install.sh+++ b/installers/linux-server/install.sh@@ -291,10 +291,26 @@ check_root() {fi}+# Detect leftover data from a previous installation, even when the service+# and config dir have been removed (e.g. user uninstalled pluton but kept data).+check_leftover_data() {+ if [ -d "${DATA_DIR}" ] && \+ { [ -f "${DATA_DIR}/keys.json" ] || \+ [ -f "${DATA_DIR}/config/config.json" ] || \+ [ -f "${DATA_DIR}/pluton.enc.env" ] || \+ [ -d "${DATA_DIR}/db" ]; }; then+ return 0+ fi+ return 1+}+# Check if this is an upgradecheck_existing_installation() {- if systemctl is-active --quiet pluton 2>/dev/null || [ -f "${ENV_FILE}" ]; then- return 0 # Existing installation found+ if systemctl is-active --quiet pluton 2>/dev/null \+ || [ -f "${ENV_FILE}" ] \+ || [ -f "${SERVICE_FILE}" ] \+ || check_leftover_data; then+ return 0 # Existing installation or leftover data foundfireturn 1 # No existing installation}@@ -735,11 +751,18 @@ firm -rf "${INSTALL_DIR}"rm -f "/usr/bin/pluton-helper"rm -f /usr/local/bin/prclone /usr/local/bin/prestic-rm -rf "${CONFIG_DIR}"-[ "$REMOVE_DATA" = true ] && rm -rf "${DATA_DIR}"+# Preserve ${CONFIG_DIR} (encryption key + admin credentials) along with ${DATA_DIR}+# unless --remove-data was passed, so a future install --upgrade can reuse them.+if [ "$REMOVE_DATA" = true ]; then+ rm -rf "${CONFIG_DIR}"+ rm -rf "${DATA_DIR}"+fiecho -e "${GREEN}Pluton uninstalled successfully!${NC}"-[ "$REMOVE_DATA" = false ] && echo "Data preserved at: ${DATA_DIR}"+if [ "$REMOVE_DATA" = false ]; then+ echo "Credentials preserved at: ${CONFIG_DIR}"+ echo "Data preserved at: ${DATA_DIR}"+fiecho "System user 'pluton' was preserved."UNINSTALL_EOFchmod +x "${INSTALL_DIR}/uninstall.sh"@@ -814,9 +837,22 @@ main() {local is_upgrade=falseif check_existing_installation; then- if [ "$CLI_UPGRADE" = true ]; then+ local has_active_install=false+ if systemctl is-active --quiet pluton 2>/dev/null || [ -f "${SERVICE_FILE}" ]; then+ has_active_install=true+ fi++ if [ "$CLI_UPGRADE" = true ] || [ "$has_active_install" = false ]; then+ # Either --upgrade was passed, or there is only leftover data from a+ # previous install (no active service / service file). Auto-load the+ # existing credentials and configuration so the user is not prompted+ # again.is_upgrade=true- echo -e "${YELLOW}Upgrade mode: Preserving existing configuration and data.${NC}"+ if [ "$has_active_install" = false ]; then+ echo -e "${YELLOW}Found existing data at ${DATA_DIR}; reusing previous configuration and credentials.${NC}"+ else+ echo -e "${YELLOW}Upgrade mode: Preserving existing configuration and data.${NC}"+ fiload_existing_credentialselseecho -e "${YELLOW}${PRODUCT_NAME} is already installed.${NC}"@@ -831,6 +867,11 @@ main() {echo "Installation cancelled."exit 0fi+ # Reinstall preserves existing data/credentials so the user does not+ # lose them when reinstalling to fix a corrupt binary.+ is_upgrade=true+ echo -e "${YELLOW}Reinstalling: Preserving existing configuration and data.${NC}"+ load_existing_credentialsfistop_existing_servicefidiff --git a/installers/linux-server/install_dev.sh b/installers/linux-server/install_dev.shindex d5982ee..4b59f38 100644--- a/installers/linux-server/install_dev.sh+++ b/installers/linux-server/install_dev.sh@@ -292,9 +292,25 @@ check_root() {fi}+# Detect leftover data from a previous installation, even when the service+# and config dir have been removed (e.g. user uninstalled pluton but kept data).+check_leftover_data() {+ if [ -d "${DATA_DIR}" ] && \+ { [ -f "${DATA_DIR}/keys.json" ] || \+ [ -f "${DATA_DIR}/config/config.json" ] || \+ [ -f "${DATA_DIR}/pluton.enc.env" ] || \+ [ -d "${DATA_DIR}/db" ]; }; then+ return 0+ fi+ return 1+}+# Check if this is an upgradecheck_existing_installation() {- if systemctl is-active --quiet pluton 2>/dev/null || [ -f "${ENV_FILE}" ]; then+ if systemctl is-active --quiet pluton 2>/dev/null \+ || [ -f "${ENV_FILE}" ] \+ || [ -f "${SERVICE_FILE}" ] \+ || check_leftover_data; thenreturn 0fireturn 1@@ -737,11 +753,18 @@ firm -rf "${INSTALL_DIR}"rm -f "/usr/bin/pluton-helper"rm -f /usr/local/bin/prclone /usr/local/bin/prestic-rm -rf "${CONFIG_DIR}"-[ "$REMOVE_DATA" = true ] && rm -rf "${DATA_DIR}"+# Preserve ${CONFIG_DIR} (encryption key + admin credentials) along with ${DATA_DIR}+# unless --remove-data was passed, so a future install --upgrade can reuse them.+if [ "$REMOVE_DATA" = true ]; then+ rm -rf "${CONFIG_DIR}"+ rm -rf "${DATA_DIR}"+fiecho -e "${GREEN}Pluton uninstalled successfully!${NC}"-[ "$REMOVE_DATA" = false ] && echo "Data preserved at: ${DATA_DIR}"+if [ "$REMOVE_DATA" = false ]; then+ echo "Credentials preserved at: ${CONFIG_DIR}"+ echo "Data preserved at: ${DATA_DIR}"+fiecho "System user 'pluton' was preserved."UNINSTALL_EOFchmod +x "${INSTALL_DIR}/uninstall.sh"@@ -816,9 +839,18 @@ main() {local is_upgrade=falseif check_existing_installation; then- if [ "$CLI_UPGRADE" = true ]; then+ local has_active_install=false+ if systemctl is-active --quiet pluton 2>/dev/null || [ -f "${SERVICE_FILE}" ]; then+ has_active_install=true+ fi++ if [ "$CLI_UPGRADE" = true ] || [ "$has_active_install" = false ]; thenis_upgrade=true- echo -e "${YELLOW}Upgrade mode: Preserving existing configuration and data.${NC}"+ if [ "$has_active_install" = false ]; then+ echo -e "${YELLOW}Found existing data at ${DATA_DIR}; reusing previous configuration and credentials.${NC}"+ else+ echo -e "${YELLOW}Upgrade mode: Preserving existing configuration and data.${NC}"+ fiload_existing_credentialselseecho -e "${YELLOW}${PRODUCT_NAME} is already installed.${NC}"@@ -833,6 +865,9 @@ main() {echo "Installation cancelled."exit 0fi+ is_upgrade=true+ echo -e "${YELLOW}Reinstalling: Preserving existing configuration and data.${NC}"+ load_existing_credentialsfistop_existing_servicefidiff --git a/installers/linux-server/uninstall.sh b/installers/linux-server/uninstall.shindex 1bdc951..3b2dada 100644--- a/installers/linux-server/uninstall.sh+++ b/installers/linux-server/uninstall.sh@@ -154,19 +154,21 @@ main() {echo "Removing wrapper commands..."rm -f /usr/local/bin/prclone /usr/local/bin/prestic- # Remove credentials directory- if [ -d "${CONFIG_DIR}" ]; then- echo "Removing credentials directory: ${CONFIG_DIR}"- rm -rf "${CONFIG_DIR}"- fi-- # Remove data directory if requested+ # Remove data + credentials only when --remove-data is set. Preserving the+ # credentials directory (${CONFIG_DIR}) along with the data directory lets+ # a future ${PRODUCT_NAME} or Pluton PRO install --upgrade pick up the+ # existing encryption key and admin credentials automatically.if [ "$REMOVE_DATA" = true ]; then+ if [ -d "${CONFIG_DIR}" ]; then+ echo "Removing credentials directory: ${CONFIG_DIR}"+ rm -rf "${CONFIG_DIR}"+ fiif [ -d "${DATA_DIR}" ]; thenecho "Removing data directory: ${DATA_DIR}"rm -rf "${DATA_DIR}"fielse+ echo -e "${BLUE}Keeping credentials directory: ${CONFIG_DIR}${NC}"echo -e "${BLUE}Keeping data directory: ${DATA_DIR}${NC}"fidiff --git a/installers/linux/AppDir/usr/share/pluton/install.sh b/installers/linux/AppDir/usr/share/pluton/install.shindex eb702d3..a9bef87 100644--- a/installers/linux/AppDir/usr/share/pluton/install.sh+++ b/installers/linux/AppDir/usr/share/pluton/install.sh@@ -172,27 +172,50 @@ if [ -z "$APPDIR" ]; thenAPPDIR="$(dirname "$(readlink -f "$0")")/.."fi+# Detect leftover data from a previous installation (e.g. user uninstalled+# Pluton but kept the data directory). Treated as an implicit upgrade so the+# existing port/concurrency configuration is reused without re-prompting.+check_leftover_data() {+ if [ -d "${DATA_DIR}" ] && \+ { [ -f "${DATA_DIR}/keys.json" ] || \+ [ -f "${DATA_DIR}/config/config.json" ] || \+ [ -f "${DATA_DIR}/pluton.enc.env" ] || \+ [ -d "${DATA_DIR}/db" ]; }; then+ return 0+ fi+ return 1+}++IS_UPGRADE=false+if systemctl is-active --quiet pluton 2>/dev/null \+ || [ -f "${SERVICE_FILE}" ] \+ || check_leftover_data; then+ IS_UPGRADE=true+fi+# Check if already installedif systemctl is-active --quiet pluton 2>/dev/null; then- echo -e "${YELLOW}Pluton service is already running.${NC}"- read -p "Do you want to reinstall? This will stop the current service. [y/N] " -n 1 -r- echo- if [[ ! $REPLY =~ ^[Yy]$ ]]; then- echo "Installation cancelled."- exit 0- fi+ echo -e "${YELLOW}Pluton service is already running. Reinstalling and preserving data...${NC}"echo "Stopping existing service..."systemctl stop plutonsystemctl disable pluton+elif [ "$IS_UPGRADE" = true ]; then+ echo -e "${YELLOW}Found existing Pluton data at ${DATA_DIR}. Reusing previous configuration.${NC}"fi-# Configuration: Check for config file or prompt user+# Configuration: Check for config file or reuse existing config when presentCONFIG_FILE="${APPDIR}/pluton-config.env"if [ -f "$CONFIG_FILE" ]; thenecho -e "${GREEN}Found configuration file: ${CONFIG_FILE}${NC}"source "$CONFIG_FILE"SERVER_PORT="${SERVER_PORT:-$DEFAULT_PORT}"MAX_CONCURRENT_BACKUPS="${MAX_CONCURRENT_BACKUPS:-$DEFAULT_MAX_CONCURRENT}"+elif [ "$IS_UPGRADE" = true ] && [ -f "${DATA_DIR}/config/config.json" ]; then+ echo -e "${BLUE}Reusing existing configuration from ${DATA_DIR}/config/config.json${NC}"+ SERVER_PORT=$(grep -o '"SERVER_PORT"[[:space:]]*:[[:space:]]*[0-9]*' "${DATA_DIR}/config/config.json" 2>/dev/null | grep -o '[0-9]*' | head -1)+ MAX_CONCURRENT_BACKUPS=$(grep -o '"MAX_CONCURRENT_BACKUPS"[[:space:]]*:[[:space:]]*[0-9]*' "${DATA_DIR}/config/config.json" 2>/dev/null | grep -o '[0-9]*' | head -1)+ SERVER_PORT="${SERVER_PORT:-$DEFAULT_PORT}"+ MAX_CONCURRENT_BACKUPS="${MAX_CONCURRENT_BACKUPS:-$DEFAULT_MAX_CONCURRENT}"elseecho -e "${BLUE}Configuration Setup${NC}"echo "Press Enter to accept default values."@@ -268,30 +291,43 @@ find "${INSTALL_DIR}/binaries" -type f -exec chmod 755 {} \; 2>/dev/null || truecreate_tool_wrappers "${ARCH}"install_pluton_helper "${ARCH}"-# Write configuration file-echo " Writing configuration..."-cat > "${DATA_DIR}/config/config.json" << EOF+# Write configuration file (preserve on upgrade)+if [ "$IS_UPGRADE" = false ] || [ ! -f "${DATA_DIR}/config/config.json" ]; then+ echo " Writing configuration..."+ cat > "${DATA_DIR}/config/config.json" << EOF{"SERVER_PORT": ${SERVER_PORT},"MAX_CONCURRENT_BACKUPS": ${MAX_CONCURRENT_BACKUPS}}EOF+else+ echo " Preserving existing configuration at ${DATA_DIR}/config/config.json"+fichown "${PLUTON_USER}:${PLUTON_GROUP}" "${DATA_DIR}/config/config.json"chmod 600 "${DATA_DIR}/config/config.json"-echo " Writing environment placeholders..."-{- printf '# Pluton credentials\n'- printf 'PLUTON_USER_NAME=%s\n' "${PLUTON_USER_NAME:-}"- printf 'PLUTON_USER_PASSWORD=%s\n' "${PLUTON_USER_PASSWORD:-}"-} > "${ENV_FILE}"+# Write credential env file. On upgrade, preserve any existing non-empty file+# instead of overwriting it with empty placeholders so the admin credentials+# carried over from the previous installation stay intact.+if [ "$IS_UPGRADE" = false ] || [ ! -s "${ENV_FILE}" ]; then+ echo " Writing environment placeholders..."+ {+ printf '# Pluton credentials\n'+ printf 'PLUTON_USER_NAME=%s\n' "${PLUTON_USER_NAME:-}"+ printf 'PLUTON_USER_PASSWORD=%s\n' "${PLUTON_USER_PASSWORD:-}"+ } > "${ENV_FILE}"+else+ echo " Preserving existing credentials at ${ENV_FILE}"+fichmod 600 "${ENV_FILE}"-if [ ! -f "${ENC_ENV_FILE}" ]; then+if [ ! -f "${ENC_ENV_FILE}" ] || [ ! -s "${ENC_ENV_FILE}" ]; then{printf '# Pluton Encryption Key - setup wizard may populate this file\n'printf 'PLUTON_ENCRYPTION_KEY=%s\n' "${PLUTON_ENCRYPTION_KEY:-}"} > "${ENC_ENV_FILE}"+else+ echo " Preserving existing encryption key at ${ENC_ENV_FILE}"fichown "${PLUTON_USER}:${PLUTON_GROUP}" "${ENV_FILE}" "${ENC_ENV_FILE}"chmod 600 "${ENV_FILE}" "${ENC_ENV_FILE}"diff --git a/installers/linux/AppDir/usr/share/pluton/uninstall.sh b/installers/linux/AppDir/usr/share/pluton/uninstall.shindex 2675d75..9d3b3b2 100644--- a/installers/linux/AppDir/usr/share/pluton/uninstall.sh+++ b/installers/linux/AppDir/usr/share/pluton/uninstall.sh@@ -14,6 +14,7 @@ NC='\033[0m' # No Color# Installation pathsINSTALL_DIR="/opt/pluton"DATA_DIR="/var/lib/pluton"+CONFIG_DIR="/etc/pluton"SERVICE_FILE="/etc/systemd/system/pluton.service"DESKTOP_FILE="/usr/share/applications/pluton.desktop"ICON_FILE="/usr/share/icons/hicolor/256x256/apps/pluton.png"@@ -105,13 +106,20 @@ if command -v update-desktop-database &> /dev/null; thenupdate-desktop-database /usr/share/applications 2>/dev/null || truefi-# Remove data directory if requested+# Remove data directory if requested. ${CONFIG_DIR} (encryption key + admin+# credentials) is preserved together with ${DATA_DIR} so that a future Pluton+# or Pluton PRO install can pick the credentials up automatically.if [ "$REMOVE_DATA" = true ]; then+ if [ -d "${CONFIG_DIR}" ]; then+ echo "Removing credentials directory: ${CONFIG_DIR}"+ rm -rf "${CONFIG_DIR}"+ fiif [ -d "${DATA_DIR}" ]; thenecho "Removing data directory: ${DATA_DIR}"rm -rf "${DATA_DIR}"fielse+ [ -d "${CONFIG_DIR}" ] && echo -e "${BLUE}Keeping credentials directory: ${CONFIG_DIR}${NC}"echo -e "${BLUE}Keeping data directory: ${DATA_DIR}${NC}"fidiff --git a/installers/macos/uninstall.sh b/installers/macos/uninstall.shindex 3b7d8a8..0dbe49d 100644--- a/installers/macos/uninstall.sh+++ b/installers/macos/uninstall.sh@@ -119,13 +119,23 @@ if security show-keychain-info "${KEYCHAIN_PATH}" &>/dev/null; thensecurity delete-keychain "${KEYCHAIN_PATH}" 2>/dev/null || truefi-# Remove data directory if requested+# Remove credentials directory only when --remove-data is set. Preserving+# /etc/pluton keeps the encryption key and admin credentials available so+# that a future Pluton or Pluton PRO install can pick them up automatically.+CONFIG_DIR="/etc/pluton"++# Remove data + credentials if requestedif [ "$REMOVE_DATA" = true ]; then+ if [ -d "${CONFIG_DIR}" ]; then+ echo "Removing credentials directory: ${CONFIG_DIR}"+ rm -rf "${CONFIG_DIR}"+ fiif [ -d "${DATA_DIR}" ]; thenecho "Removing data directory: ${DATA_DIR}"rm -rf "${DATA_DIR}"fielse+ [ -d "${CONFIG_DIR}" ] && echo -e "${BLUE}Keeping credentials directory: ${CONFIG_DIR}${NC}"echo -e "${BLUE}Keeping data directory: ${DATA_DIR}${NC}"fi