now upgradeCmd is being used, message when downloading, and upgrade need to run as root

This commit is contained in:
2025-10-11 18:50:45 -03:00
parent 4cee062889
commit 7c4fba5c86
2 changed files with 7 additions and 0 deletions

View File

@@ -480,6 +480,10 @@ var upgradeCmd = &cobra.Command{
Short: "upgrade all installed packages", Short: "upgrade all installed packages",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if os.Getuid() != 0 {
log.Fatal("you must run this command as root")
}
cfg, err := configs.GetConfigTOML() cfg, err := configs.GetConfigTOML()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@@ -523,6 +527,7 @@ func main() {
rootCmd.AddCommand(syncCmd) rootCmd.AddCommand(syncCmd)
rootCmd.AddCommand(listCmd) rootCmd.AddCommand(listCmd)
rootCmd.AddCommand(searchCmd) rootCmd.AddCommand(searchCmd)
rootCmd.AddCommand(upgradeCmd)
rootCmd.Execute() rootCmd.Execute()
} }

View File

@@ -446,6 +446,7 @@ func GetPackage(id string) (Package, error) {
} }
if len(peers) == 0 { if len(peers) == 0 {
fmt.Printf(":: Pulling from %s\n", packageUrl)
this.PackageF, err = GetFileHTTP(packageUrl) this.PackageF, err = GetFileHTTP(packageUrl)
if err != nil { if err != nil {
return Package{}, err return Package{}, err
@@ -453,6 +454,7 @@ func GetPackage(id string) (Package, error) {
} else { } else {
var totalerrors int = 0 var totalerrors int = 0
for _, peer := range peers { for _, peer := range peers {
fmt.Printf(":: Pulling from local network (%s)\n", peer.IP)
this.PackageF, err = GetFileHTTP(fmt.Sprintf("http://%s:%d/%s", peer.IP, peer.Port, filename)) this.PackageF, err = GetFileHTTP(fmt.Sprintf("http://%s:%d/%s", peer.IP, peer.Port, filename))
if err == nil { if err == nil {
break break