Skip to content

Commit 463f37a

Browse files
committed
Add version file and update CLI installation script for background execution
1 parent 00a66ab commit 463f37a

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

utils/helm.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,27 +319,35 @@ func DownloadAndReplaceCLI(version string) error {
319319
f.Close()
320320

321321
// Create update.sh script
322-
exePath, err := os.Executable()
323-
if err != nil {
324-
return err
325-
}
326322
updateScriptPath := filepath.Join(netsocsDir, "update.sh")
327-
updateScript := fmt.Sprintf(`#!/bin/bash\nset -e\nNEWBIN=\"%s\"\nTARGET=\"%s\"\necho \"Updating CLI...\"\nchmod +x \"$NEWBIN\"\nmv \"$NEWBIN\" \"$TARGET\"\necho \"Update complete!\"\n`, newBinPath, exePath)
323+
updateScript := fmt.Sprintf(`#!/bin/bash
324+
set -e
325+
echo "Updating CLI..."
326+
sudo rm /usr/local/bin/netsocs
327+
sudo cp "%s" /usr/local/bin/netsocs
328+
sudo chmod +x /usr/local/bin/netsocs
329+
echo "Update complete!"
330+
`, newBinPath)
328331
if err := os.WriteFile(updateScriptPath, []byte(updateScript), 0755); err != nil {
329332
return err
330333
}
331334

332335
pterm.Info.Println("Nuevo binario descargado en:", newBinPath)
333-
pterm.Info.Println("Ejecutando script de actualización:", updateScriptPath)
336+
pterm.Info.Println("Ejecutando script de actualización en segundo plano:", updateScriptPath)
334337

335-
// Ejecutar el script
338+
// Ejecutar el script de forma asíncrona
336339
cmd := exec.Command("bash", updateScriptPath)
337340
cmd.Stdout = os.Stdout
338341
cmd.Stderr = os.Stderr
339-
if err := cmd.Run(); err != nil {
340-
return fmt.Errorf("error ejecutando el script de actualización: %w", err)
342+
343+
// Iniciar el comando en segundo plano sin esperar
344+
if err := cmd.Start(); err != nil {
345+
return fmt.Errorf("error iniciando el script de actualización: %w", err)
341346
}
342347

348+
// No esperar a que termine, solo informar que se inició
349+
pterm.Success.Println("Actualización iniciada en segundo plano. El CLI se actualizará automáticamente.")
350+
343351
return nil
344352
}
345353

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.0.0

0 commit comments

Comments
 (0)