Skip to content

Commit

Permalink
feat: add --apply flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gerblesh committed Feb 10, 2025
1 parent 044da54 commit ae8e303
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func init() {
rootCmd.Flags().Bool("ci", false, "Makes some modifications to behavior if is running in CI")
isTerminal := term.IsTerminal(int(os.Stdout.Fd()))
rootCmd.Flags().Bool("disable-osc-progress", !isTerminal, "Disable the GUI progress indicator")
rootCmd.Flags().Bool("apply", false, "Reboot if there's an update to the image")
rootCmd.PersistentFlags().BoolVar(&fLogJson, "json", false, "Print logs as json (used for testing)")
rootCmd.PersistentFlags().StringVar(&fLogFile, "log-file", "-", "File where user-facing logs will be written to")
rootCmd.PersistentFlags().StringVar(&fLogLevel, "log-level", "info", "Log level for user-facing logs")
Expand Down
11 changes: 11 additions & 0 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log/slog"
"os"
"os/exec"

"github.com/spf13/cobra"
"github.com/ublue-os/uupd/checks"
Expand Down Expand Up @@ -55,6 +56,11 @@ func Update(cmd *cobra.Command, args []string) {
slog.Error("Failed to get disable-osc-progress flag", "error", err)
return
}
applySystem, err := cmd.Flags().GetBool("apply")
if err != nil {
slog.Error("Failed to get apply flag", "error", err)
return
}

if hwCheck {
err := checks.RunHwChecks()
Expand Down Expand Up @@ -207,4 +213,9 @@ func Update(cmd *cobra.Command, args []string) {
}

slog.Info("Updates Completed Successfully")
if applySystem && mainSystemDriverConfig.Enabled {
slog.Info("Applying System Update")
cmd := exec.Command("/usr/bin/systemctl", "reboot")
cmd.Start()

Check failure on line 219 in cmd/update.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `cmd.Start` is not checked (errcheck)

Check failure on line 219 in cmd/update.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `cmd.Start` is not checked (errcheck)
}
}

0 comments on commit ae8e303

Please sign in to comment.