ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat: Add branch switching support to serverkit CLI
Juan Denisbb2159f4e6c5
diff --git a/serverkit b/serverkitindex 24737525..5b3a76d7 100644--- a/serverkit+++ b/serverkit@@ -152,7 +152,10 @@ cmd_help() {echo " restart Restart all services"echo " status Show service status"echo " logs [service] View logs (backend, frontend, or all)"- echo " update [--force] Update to latest version (--force skips version check)"+ echo " update [options] Update ServerKit"+ echo " --branch <name> Switch to specific branch (e.g., dev)"+ echo " --force Skip version check"+ echo " branch Show current branch"echo " uninstall Uninstall ServerKit"echo ""echo "User Management:"@@ -325,11 +328,45 @@ cmd_logs() {esac}+cmd_branch() {+ check_installed+ cd "$INSTALL_DIR"++ local current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")+ local current_commit=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")++ echo ""+ echo " Current branch: $current_branch"+ echo " Current commit: $current_commit"+ echo " Version: $(get_local_version)"+ echo ""++ # Show available remote branches+ print_info "Available branches:"+ git branch -r 2>/dev/null | grep -v HEAD | sed 's/origin\// /' | head -10+ echo ""+}+cmd_update() {local force_update=false- if [ "$1" = "--force" ] || [ "$1" = "-f" ]; then- force_update=true- fi+ local target_branch=""++ # Parse arguments+ while [[ $# -gt 0 ]]; do+ case $1 in+ --force|-f)+ force_update=true+ shift+ ;;+ --branch|-b)+ target_branch="$2"+ shift 2+ ;;+ *)+ shift+ ;;+ esac+ donecheck_rootcheck_installed@@ -338,15 +375,33 @@ cmd_update() {cd "$INSTALL_DIR"+ # Get current branch+ local current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")++ # If no branch specified, use current branch (or main if detached)+ if [ -z "$target_branch" ]; then+ target_branch="$current_branch"+ if [ "$target_branch" = "HEAD" ]; then+ target_branch="main"+ fi+ fi+# Get versionsCURRENT_VERSION=$(get_local_version)- REMOTE_VERSION=$(get_remote_version)- echo " Installed version: $CURRENT_VERSION"- echo " Latest version: $REMOTE_VERSION"- echo ""+ # For non-main branches, skip version comparison+ if [ "$target_branch" != "main" ]; then+ force_update=true+ print_warning "Updating to branch: $target_branch (dev mode)"+ echo ""+ else+ REMOTE_VERSION=$(get_remote_version)+ echo " Installed version: $CURRENT_VERSION"+ echo " Latest version: $REMOTE_VERSION"+ echo ""+ fi- # Check if update is needed (skip if --force)+ # Check if update is needed (skip if --force or non-main branch)if [ "$force_update" = false ] && [ "$REMOTE_VERSION" != "unknown" ]; thenset +e # Temporarily disable exit on errorcompare_versions "$CURRENT_VERSION" "$REMOTE_VERSION"@@ -363,17 +418,21 @@ cmd_update() {fifi- print_info "Updating ServerKit..."+ print_info "Updating ServerKit to branch: $target_branch..."# Stop servicesprint_info "Stopping services..."systemctl stop $BACKEND_SERVICE || truedocker compose down || true- # Pull latest changes- print_info "Pulling latest changes..."- git fetch origin- git reset --hard origin/main+ # Fetch all branches and pull changes+ print_info "Fetching latest changes..."+ git fetch origin --prune++ # Checkout target branch+ print_info "Switching to branch: $target_branch..."+ git checkout "$target_branch" 2>/dev/null || git checkout -b "$target_branch" "origin/$target_branch"+ git reset --hard "origin/$target_branch"# Restore executable permissionschmod +x "$INSTALL_DIR/serverkit"@@ -381,6 +440,7 @@ cmd_update() {# Get new version from VERSION fileNEW_VERSION=$(get_local_version)+ NEW_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")# Update Python dependenciesprint_info "Updating Python dependencies..."@@ -414,9 +474,15 @@ cmd_update() {echo ""print_success "ServerKit updated!"- echo " Previous version: $CURRENT_VERSION"- echo " Current version: $NEW_VERSION"+ echo " Branch: $target_branch"+ echo " Commit: $NEW_COMMIT"+ echo " Version: $NEW_VERSION"echo ""++ if [ "$target_branch" != "main" ]; then+ print_warning "Running on '$target_branch' branch. Use 'serverkit update --branch main' to return to stable."+ fi+cmd_status_brief}@@ -857,7 +923,11 @@ case "${1:-help}" incmd_logs "$2";;update)- cmd_update "$2"+ shift+ cmd_update "$@"+ ;;+ branch)+ cmd_branch;;version|--version|-v)cmd_version