Skip to content

Commit 7380417

Browse files
committed
feat: add logs, image support
1 parent 5658387 commit 7380417

1 file changed

Lines changed: 0 additions & 40 deletions

File tree

main.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ var initCmd = &cobra.Command{
7777
os.Exit(1)
7878
}
7979

80-
if runtime.GOOS != "windows" && os.Geteuid() != 0 {
81-
fmt.Println("Error: This command requires root privileges on Linux.")
82-
fmt.Println("Please run: sudo updatectl init")
83-
os.Exit(1)
84-
}
85-
8680
var configDir, configPath string
8781
if runtime.GOOS == "windows" {
8882
configDir = filepath.Join(os.Getenv("USERPROFILE"), "updatectl")
@@ -91,10 +85,6 @@ var initCmd = &cobra.Command{
9185
}
9286
configPath = filepath.Join(configDir, "updatectl.yaml")
9387

94-
if err := os.MkdirAll(configDir, 0755); err != nil {
95-
fmt.Printf("Failed to create config directory: %v\n", err)
96-
os.Exit(1)
97-
}
9888
if err := os.MkdirAll(configDir, 0755); err != nil {
9989
fmt.Printf("Failed to create config directory: %v\n", err)
10090
os.Exit(1)
@@ -126,10 +116,6 @@ projects:
126116
port: "3000:80"
127117
containerName: my-dashboard
128118
`)
129-
if err := os.WriteFile(configPath, defaultConfig, 0644); err != nil {
130-
fmt.Printf("Failed to write config file: %v\n", err)
131-
os.Exit(1)
132-
}
133119
if err := os.WriteFile(configPath, defaultConfig, 0644); err != nil {
134120
fmt.Printf("Failed to write config file: %v\n", err)
135121
os.Exit(1)
@@ -152,7 +138,6 @@ start "" /b "%s" watch
152138
return
153139
}
154140
taskRun := batScriptPath
155-
createCmd := exec.Command(
156141
createCmd := exec.Command(
157142
"schtasks",
158143
"/Create",
@@ -163,7 +148,6 @@ start "" /b "%s" watch
163148
"/F",
164149
)
165150
output, err := createCmd.CombinedOutput()
166-
output, err := createCmd.CombinedOutput()
167151
if err != nil {
168152
fmt.Printf("Failed to create scheduled task: %v\nOutput: %s\n", err, output)
169153
return
@@ -181,7 +165,6 @@ start "" /b "%s" watch
181165
scanner := bufio.NewScanner(os.Stdin)
182166
scanner.Scan()
183167
user := strings.TrimSpace(scanner.Text())
184-
user := strings.TrimSpace(scanner.Text())
185168
if user == "" {
186169
user = "root"
187170
}
@@ -212,24 +195,6 @@ WantedBy=multi-user.target
212195
}
213196
fmt.Println("Reloaded systemd daemon")
214197

215-
enableCmd := exec.Command("systemctl", "enable", "--now", "updatectl")
216-
if output, err := enableCmd.CombinedOutput(); err != nil {
217-
fmt.Printf("Failed to enable and start service: %v\nOutput: %s\n", err, output)
218-
os.Exit(1)
219-
}
220-
if err := os.WriteFile(servicePath, []byte(service), 0644); err != nil {
221-
fmt.Printf("Failed to write systemd service file: %v\n", err)
222-
os.Exit(1)
223-
}
224-
fmt.Println("Created systemd service file at", servicePath)
225-
226-
reloadCmd := exec.Command("systemctl", "daemon-reload")
227-
if err := reloadCmd.Run(); err != nil {
228-
fmt.Printf("Failed to reload systemd daemon: %v\n", err)
229-
os.Exit(1)
230-
}
231-
fmt.Println("Reloaded systemd daemon")
232-
233198
enableCmd := exec.Command("systemctl", "enable", "--now", "updatectl")
234199
if output, err := enableCmd.CombinedOutput(); err != nil {
235200
fmt.Printf("Failed to enable and start service: %v\nOutput: %s\n", err, output)
@@ -238,8 +203,6 @@ WantedBy=multi-user.target
238203
fmt.Println("Systemd service installed and started.")
239204
fmt.Println("\nCheck status with: sudo systemctl status updatectl")
240205
fmt.Println("View logs with: sudo journalctl -u updatectl -f")
241-
fmt.Println("\nCheck status with: sudo systemctl status updatectl")
242-
fmt.Println("View logs with: sudo journalctl -u updatectl -f")
243206
}
244207
},
245208
}
@@ -504,7 +467,6 @@ if p.Type == "image" {
504467
}
505468

506469
if _, err := os.Stat(p.Path); os.IsNotExist(err) {
507-
fmt.Println("✘ Path not found:", p.Path)
508470
fmt.Println("✘ Path not found:", p.Path)
509471
return
510472
}
@@ -513,14 +475,12 @@ if p.Type == "image" {
513475
gitPull := exec.Command("git", "-C", p.Path, "pull")
514476
output, err := gitPull.CombinedOutput()
515477
if err != nil {
516-
fmt.Println("✘ Git pull failed:", err)
517478
fmt.Println("✘ Git pull failed:", err)
518479
return
519480
}
520481
fmt.Print(string(output))
521482

522483
if strings.Contains(string(output), "Already up to date.") {
523-
fmt.Println("● No new commits for", p.Name)
524484
fmt.Println("● No new commits for", p.Name)
525485
return
526486
}

0 commit comments

Comments
 (0)