Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefMarlin committed Aug 11, 2023
1 parent 6d49cdd commit e493b93
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

Badger is a lightweight alternative to systemd, it runs your scripts and manages your daemons at startup.


### Features
* Live reload of the daemons file allows your to add and remove daemons and scripts while system is running live
* Automatically restarts failed daemons and stops removed daemons
Expand Down Expand Up @@ -61,3 +60,8 @@ Then run:
systemctl enable badger
systemctl start badger
```
## Installing
```bash
repo="badger"; name="badger"; os=$(uname | tr '[:upper:]' '[:lower:]'); arch=$(uname -m); case $arch in x86_64) arch="amd64" ;; arm64) arch="arm64" ;; esac; url="https://github.com/8ff/${repo}/releases/download/latest/${name}.${os}.${arch}"; curl -L $url -o ${name} && chmod +x ${name}
```
25 changes: 20 additions & 5 deletions badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
"os"
"os/exec"
"os/signal"
"runtime"
"strings"
"syscall"
"time"

"github.com/8ff/tuna"
)

var Version string
Expand All @@ -24,6 +27,11 @@ func tlog(logType string, logData string) {
}

if logFile != "" {
// Check if log file exists, if not create it along with the path
if _, err := os.Stat(logFile); os.IsNotExist(err) {
os.MkdirAll(logFile, 0755)
}

f, err := os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
tlog("error", fmt.Sprintf("%s", err))
Expand Down Expand Up @@ -175,11 +183,18 @@ func handleArgs() {
for i := 0; i < len(args); i++ {
switch args[i] {
case "update":
// e := tuna.SelfUpdate("https://releases/badger")
// if e != nil {
// tlog("error", e.Error())
// }
// tlog("info", "Updated to latest version!")
// Determine OS and ARCH
osRelease := runtime.GOOS
arch := runtime.GOARCH

// Build URL
e := tuna.SelfUpdate(fmt.Sprintf("https://github.com/8ff/badger/releases/download/latest/badger.%s.%s", osRelease, arch))
if e != nil {
fmt.Println(e)
os.Exit(1)
}

fmt.Println("Updated!")
os.Exit(0)

case "version", "-v", "--version":
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/8ff/badger

go 1.20

require github.com/8ff/tuna v0.0.0-20230811173825-52af88c52674
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/8ff/tuna v0.0.0-20230811173825-52af88c52674 h1:9L0K8szFUXJ0V71/I5YJeCmOXVhgU0+v0+9nf8mHqG0=
github.com/8ff/tuna v0.0.0-20230811173825-52af88c52674/go.mod h1:brULTDkAKe2Ut39W20RPVcc0M6MhaHLTS/oGJiC5tVs=

0 comments on commit e493b93

Please sign in to comment.