Prepare, configure, and manage Firecracker microVMs in seconds!
virtualization linux microvm firecracker

Merge pull request #17 from tsirysndr/fix/tailscale-alpine

refactor: enhance Tailscale setup for Alpine compatibility and streamline service management

authored by tsiry-sandratraina.com and committed by

GitHub d552fcd3 58328b6b

+28 -11
+28 -11
crates/firecracker-vm/src/tailscale.rs
··· 22 22 23 23 let guest_ip = format!("{}.firecracker", name); 24 24 run_ssh_command(&key_path, &guest_ip, "rm -f /etc/security/namespace.init")?; 25 + 26 + if config.alpine.unwrap_or(false) { 27 + run_ssh_command(&key_path, &guest_ip, "apk add openrc")?; 28 + } 29 + 25 30 run_ssh_command( 26 31 &key_path, 27 32 &guest_ip, 28 33 "type tailscaled || curl -fsSL https://tailscale.com/install.sh | sh", 29 34 )?; 30 - run_ssh_command( 31 - &key_path, 32 - &guest_ip, 33 - "systemctl enable tailscaled && systemctl start tailscaled || true", 34 - )?; 35 - run_ssh_command( 36 - &key_path, 37 - &guest_ip, 38 - &format!("tailscale up --auth-key {} --hostname {}", auth_key, name), 39 - )?; 40 - run_ssh_command(&key_path, &guest_ip, "systemctl status tailscaled || true")?; 35 + 36 + if config.alpine.unwrap_or(false) { 37 + run_ssh_command( 38 + &key_path, 39 + &guest_ip, 40 + &format!("tailscale up --auth-key {} --hostname {}", auth_key, name), 41 + )?; 42 + run_ssh_command(&key_path, &guest_ip, "rc-status")?; 43 + } else { 44 + run_ssh_command( 45 + &key_path, 46 + &guest_ip, 47 + "systemctl enable tailscaled && systemctl start tailscaled || true", 48 + )?; 49 + run_ssh_command( 50 + &key_path, 51 + &guest_ip, 52 + &format!("tailscale up --auth-key {} --hostname {}", auth_key, name), 53 + )?; 54 + run_ssh_command(&key_path, &guest_ip, "systemctl status tailscaled || true")?; 55 + } 56 + 41 57 run_ssh_command(&key_path, &guest_ip, "tailscale status || true")?; 58 + 42 59 println!("[+] Tailscale setup completed."); 43 60 return Ok(()); 44 61 }