Skip to content

Commit

Permalink
feat: one line install
Browse files Browse the repository at this point in the history
  • Loading branch information
malletgaetan committed Dec 29, 2024
1 parent 08892e9 commit bf29171
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Build from source:
make
```

Or download pre-built binaries (coming soon):
Or install using pre-built binaries:
```bash
// TODO
curl -fsSL https://raw.githubusercontent.com/malletgaetan/dockermon/main/install.sh | sudo bash
```

### Basic Usage
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- [x] Resilience on events listening fail
- [x] Add more tests
- [x] CI/CD Pipeline, no push on main (tests, fmt and static analysis)
- [ ] One file installer
- [x] One line installer

- [ ] Event Type wildcard
- [ ] Windows compatibility
71 changes: 71 additions & 0 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

# Function to get latest release tag from GitHub API
get_latest_tag() {
local repo=$1
curl -s "https://api.github.com/repos/$repo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
}

# Function to detect OS and architecture
detect_platform() {
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

case "$ARCH" in
x86_64)
ARCH="amd64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac

case "$OS" in
linux|darwin)
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
}

# Main installation function
install_dockermon() {
# Replace with your GitHub username/repo
REPO="malletgaetan/dockermon"
INSTALL_DIR="/usr/local/bin"

echo "Detecting platform..."
detect_platform

echo "Getting latest release..."
TAG=$(get_latest_tag "$REPO")
if [ -z "$TAG" ]; then
echo "Failed to get latest release tag"
exit 1
fi

BINARY_NAME="dockermon-$OS-$ARCH"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$TAG/$BINARY_NAME"

echo "Downloading $BINARY_NAME..."
if ! curl -L -o "$INSTALL_DIR/dockermon" "$DOWNLOAD_URL"; then
echo "Failed to download binary"
exit 1
fi

echo "Setting executable permissions..."
chmod +x "$INSTALL_DIR/dockermon"

echo "Installation complete! dockermon has been installed to $INSTALL_DIR/dockermon"
echo "You can now run 'dockermon' from anywhere"
}

if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root (sudo)"
exit 1
fi

install_dockermon
1 change: 0 additions & 1 deletion internal/config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type parser struct {
pos Position
}

// TODO: fix
func keys[T any](m map[string]T) []string {
arr := make([]string, len(m))
i := 0
Expand Down

0 comments on commit bf29171

Please sign in to comment.