-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·113 lines (89 loc) · 2.6 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·113 lines (89 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
set -euo pipefail
REPO="missuo/mailclaw"
BINARY="mailclaw"
INSTALL_DIR="/usr/local/bin"
info() { printf '\033[1;34m%s\033[0m\n' "$*"; }
error() { printf '\033[1;31mError: %s\033[0m\n' "$*" >&2; exit 1; }
detect_platform() {
local os arch
os="$(uname -s)"
arch="$(uname -m)"
case "$os" in
Darwin) OS="darwin" ;;
Linux) OS="linux" ;;
*) error "Unsupported OS: $os" ;;
esac
case "$arch" in
x86_64|amd64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="aarch64" ;;
*) error "Unsupported architecture: $arch" ;;
esac
}
install_macos() {
info "Detected macOS — installing via Homebrew..."
if ! command -v brew &>/dev/null; then
error "Homebrew is not installed. Install it from https://brew.sh"
fi
brew tap owo-network/brew
brew install owo-network/brew/mailclaw
info "Installed successfully via Homebrew."
}
install_linux() {
info "Detected Linux ($ARCH) — installing from GitHub Releases..."
local target
case "$ARCH" in
x86_64) target="x86_64-unknown-linux-gnu" ;;
aarch64) target="aarch64-unknown-linux-gnu" ;;
esac
# Fetch latest release tag
local tag
tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' | head -1 | cut -d '"' -f 4)"
if [ -z "$tag" ]; then
error "Failed to determine the latest release version."
fi
info "Latest version: $tag"
local url="https://github.com/${REPO}/releases/download/${tag}/${BINARY}-${tag}-${target}"
local tmpfile
tmpfile="$(mktemp)"
info "Downloading ${BINARY}-${tag}-${target}..."
curl -fsSL -o "$tmpfile" "$url" || error "Download failed. URL: $url"
chmod +x "$tmpfile"
# Install to INSTALL_DIR (may need sudo)
if [ -w "$INSTALL_DIR" ]; then
mv "$tmpfile" "${INSTALL_DIR}/${BINARY}"
else
info "Writing to ${INSTALL_DIR} requires elevated permissions."
sudo mv "$tmpfile" "${INSTALL_DIR}/${BINARY}"
fi
info "Installed ${BINARY} ${tag} to ${INSTALL_DIR}/${BINARY}"
}
prompt_configure() {
printf '\n'
info "Would you like to configure MailClaw now? [y/N] "
read -r answer
case "$answer" in
[yY]|[yY][eE][sS])
printf 'Enter your MailClaw host (e.g. https://mailclaw.example.com): '
read -r host
printf 'Enter your API token: '
read -r token
"${INSTALL_DIR}/${BINARY}" config set --host "$host" --api-token "$token"
info "Configuration saved."
;;
*)
info "Skipped. You can configure later with: ${BINARY} config set --host <HOST> --api-token <TOKEN>"
;;
esac
}
main() {
detect_platform
case "$OS" in
darwin) install_macos ;;
linux) install_linux ;;
esac
info "Run '${BINARY} --help' to get started."
prompt_configure
}
main