This commit is contained in:
2025-08-28 14:03:29 +02:00
parent 76efe0438a
commit 3f9844fd93
3 changed files with 12 additions and 11 deletions

View File

@@ -39,9 +39,9 @@ mut cl := hetznermanager.get(name:'main')!
// println(cl.servers_list()!)
mut serverinfo := cl.server_info_get(name: 'kristof2')!
// mut serverinfo := cl.server_info_get(name: 'kristof2')!
println(serverinfo)
// println(serverinfo)
// cl.server_reset(name:"kristof2",wait:true)!
@@ -61,4 +61,5 @@ println(serverinfo)
// n.shell("")!
cl.ubuntu_install(name:"kristof2",wait:true, hero_install:true,sshkey_name:"kristof")!
cl.ubuntu_install(name:"kristof20",wait:true, hero_install:true,sshkey_name:"kristof")!

View File

@@ -17,7 +17,7 @@ pub enum PingResult {
pub struct PingArgs {
pub mut:
address string @[required]
count u8 = 1 // the ping is successful if it got count amount of replies from the other side
count u8 = 2 // the ping is successful if it got count amount of replies from the other side
timeout u16 = 1 // the time in which the other side should respond in seconds
retry u8
}
@@ -75,7 +75,7 @@ pub fn ping(args PingArgs) !PingResult {
pub struct RebootWaitArgs {
pub mut:
address string @[required] // 192.168.8.8
timeout_down i64 = 2 // total time in seconds to wait till its down
timeout_down i64 = 60 // total time in seconds to wait till its down
timeout_up i64 = 60 * 5
}
@@ -86,11 +86,11 @@ pub mut:
// timeout u16 = 2000 // total time in milliseconds to keep on trying
//```
pub fn reboot_wait(args RebootWaitArgs) ! {
start_time := time.now().unix_milli()
start_time := time.now().unix()
mut run_time := 0.0
for true {
console.print_debug("Waiting for server to go down...")
run_time = time.now().unix_milli()
run_time = time.now().unix()
if run_time > start_time + args.timeout_down {
return error("timeout in waiting for server down")
}
@@ -101,11 +101,11 @@ pub fn reboot_wait(args RebootWaitArgs) ! {
}
for true {
console.print_debug("Waiting for server to come back up...")
run_time = time.now().unix_milli()
run_time = time.now().unix()
if run_time > start_time + args.timeout_up {
return error("timeout in waiting for server up")
}
if ping(address:args.address)! == .ok {
if ping(address:args.address)! != .ok {
break
}
time.sleep(1)

View File

@@ -43,7 +43,7 @@ pub fn (mut h HetznerManager) server_rescue(args_ ServerRescueArgs) !ServerInfoD
mut b := builder.new()!
mut n := b.node_new(ipaddr: serverinfo.server_ip)!
res:=n.exec(cmd:"ls /root/.oldroot/nfs/install/installimage") or {
res:=n.exec(cmd:"ls /root/.oldroot/nfs/install/installimage",stdout:false) or {
"ERROR"
}
if res.contains("nfs/install/installimage"){
@@ -138,10 +138,10 @@ pub fn (mut h HetznerManager) ubuntu_install(args ServerInstallArgs) !&builder.N
rstr="-r yes -l 1 "
}
n.exec_interactive('
n.exec(cmd:'
set -ex
echo "go into install mode, try to install ubuntu 24.04"
/root/.oldroot/nfs/install/installimage -a -n kristof2 ${rstr} -i /root/.oldroot/nfs/images/Ubuntu-2404-noble-amd64-base.tar.gz -f yes -t yes swap:swap:4G,/boot:ext3:1024M,/:btrfs:all
/root/.oldroot/nfs/install/installimage -a -n kristof2 ${rstr} -i /root/.oldroot/nfs/images/Ubuntu-2404-noble-amd64-base.tar.gz -f yes -t yes -p swap:swap:4G,/boot:ext3:1024M,/:btrfs:all
reboot')!
os.execute_opt("ssh-keygen -R ${serverinfo.server_ip}")!