Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions backend/src/routes/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,36 @@ pub async fn install_update(
}

// Find the update script - try multiple locations
let mut possible_paths: Vec<std::path::PathBuf> =
vec![std::path::PathBuf::from("/opt/csf-core/scripts/update.sh")];
let mut possible_paths: Vec<std::path::PathBuf> = vec![
// Production path (daemon service)
std::path::PathBuf::from("/opt/csf-core/scripts/update.sh"),
];

// Development paths
if let Ok(dir) = std::env::current_dir() {
// When running from /opt/csf-core/backend
possible_paths.push(dir.join("../scripts/update.sh"));
// When running from project root
possible_paths.push(dir.join("scripts/update.sh"));
// When running from backend directory
possible_paths.push(dir.join("../../scripts/update.sh"));
}

tracing::debug!("Searching for update script in: {:?}", possible_paths);

let script_path = possible_paths
.iter()
.find(|&p: &&std::path::PathBuf| p.exists())
.ok_or_else(|| {
let script_path = match possible_paths.iter().find(|&p| p.exists()) {
Some(path) => path.clone(),
None => {
let error_msg = format!(
"Update script not found in any expected location. Searched paths: {:?}",
"Update script not found in any expected location. Searched paths: {:?}. Note: Updates can only be performed in production installations, not during local development.",
possible_paths
);
tracing::error!("{}", error_msg);
AppError::InternalError(error_msg)
})?
.clone();
return Err(AppError::InternalError(
"Update functionality is only available in production installations. The update script was not found on this system.".to_string()
));
}
};

tracing::info!("Found update script at: {:?}", script_path);

Expand Down
24 changes: 24 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,18 @@ download_release() {
return
fi

# Download update script
local update_script_url="https://raw.githubusercontent.com/${GITHUB_REPO}/main/scripts/update.sh"
print_step "Download Update Script..."

mkdir -p "$INSTALL_DIR/scripts"
if curl -L -f "$update_script_url" -o "$INSTALL_DIR/scripts/update.sh" 2>/dev/null; then
chmod +x "$INSTALL_DIR/scripts/update.sh"
print_success "Update Script heruntergeladen"
else
print_warning "Update Script konnte nicht heruntergeladen werden"
fi

cd - > /dev/null
rm -rf "$temp_dir"

Expand Down Expand Up @@ -635,6 +647,18 @@ EOF
return
fi

# Copy update script
cd "$temp_dir/csf-core"
print_step "Kopiere Update Script..."
mkdir -p "$INSTALL_DIR/scripts"
if [ -f "scripts/update.sh" ]; then
cp scripts/update.sh "$INSTALL_DIR/scripts/"
chmod +x "$INSTALL_DIR/scripts/update.sh"
print_success "Update Script kopiert"
else
print_warning "Update Script nicht gefunden"
fi

cd - > /dev/null
rm -rf "$temp_dir"

Expand Down
Loading