forked from kylemclaren/claude-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·203 lines (170 loc) Β· 5.43 KB
/
install.sh
File metadata and controls
executable file
Β·203 lines (170 loc) Β· 5.43 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
set -e
# claude-tasks installer
# Usage: curl -fsSL https://raw.githubusercontent.com/ASRagab/claude-tasks/main/install.sh | bash
REPO="ASRagab/claude-tasks"
INSTALL_DIR="${CLAUDE_TASKS_INSTALL_DIR:-$HOME/.local/bin}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
# Detect OS and architecture
detect_platform() {
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
linux)
OS="linux"
;;
darwin)
OS="darwin"
;;
mingw*|msys*|cygwin*)
OS="windows"
;;
*)
error "Unsupported operating system: $OS"
;;
esac
case "$ARCH" in
x86_64|amd64)
ARCH="amd64"
;;
aarch64|arm64)
ARCH="arm64"
;;
*)
error "Unsupported architecture: $ARCH"
;;
esac
PLATFORM="${OS}-${ARCH}"
info "Detected platform: $PLATFORM"
}
# Get latest release version
get_latest_version() {
LATEST_VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_VERSION" ]; then
error "Failed to get latest version. No releases found yet?"
fi
info "Latest version: $LATEST_VERSION"
}
# Download and install
install() {
BINARY_NAME="claude-tasks-${PLATFORM}"
if [ "$OS" = "windows" ]; then
BINARY_NAME="${BINARY_NAME}.exe"
TARGET_NAME="claude-tasks.exe"
else
TARGET_NAME="claude-tasks"
fi
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST_VERSION}/${BINARY_NAME}"
info "Creating install directory: $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
info "Downloading binary..."
if ! curl -fsSL "$DOWNLOAD_URL" -o "$INSTALL_DIR/$TARGET_NAME"; then
error "Download failed. Check if release exists for $PLATFORM"
fi
chmod +x "$INSTALL_DIR/$TARGET_NAME"
# On macOS, remove quarantine attribute
if [ "$OS" = "darwin" ]; then
info "Removing macOS quarantine..."
xattr -cr "$INSTALL_DIR/$TARGET_NAME" 2>/dev/null || true
fi
info "Binary installed: $INSTALL_DIR/$TARGET_NAME"
}
# Check if install dir is in PATH and add if needed
check_path() {
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
return 0
fi
# Determine shell config file
local shell_rc=""
if [ -n "$ZSH_VERSION" ] || [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ]; then
shell_rc="$HOME/.zshrc"
else
shell_rc="$HOME/.bashrc"
fi
local path_line="export PATH=\"\$PATH:$INSTALL_DIR\""
# Check if already in config (maybe PATH just not reloaded)
if [ -f "$shell_rc" ] && grep -q "$INSTALL_DIR" "$shell_rc" 2>/dev/null; then
info "$INSTALL_DIR already in $shell_rc (restart shell to apply)"
return 0
fi
# Add to shell config
echo "" >> "$shell_rc"
echo "# Added by claude-tasks installer" >> "$shell_rc"
echo "$path_line" >> "$shell_rc"
info "Added $INSTALL_DIR to PATH in $shell_rc"
# Also export for current session
export PATH="$PATH:$INSTALL_DIR"
}
# Setup Sprite service (if running on Sprite)
setup_sprite_service() {
if ! command -v sprite-env &> /dev/null; then
return 0
fi
info "Sprite environment detected, setting up daemon service..."
# Ensure jq is installed (needed by sprite-env)
if ! command -v jq &> /dev/null; then
info "Installing jq..."
sudo apt-get update -qq && sudo apt-get install -y -qq jq
fi
# Stop and remove existing service if present (ignore errors)
sprite-env services stop claude-tasks-daemon >/dev/null 2>&1 || true
sprite-env services delete claude-tasks-daemon >/dev/null 2>&1 || true
# Create the daemon service
if sprite-env services create claude-tasks-daemon \
--cmd "$INSTALL_DIR/$TARGET_NAME" \
--args daemon \
--no-stream >/dev/null 2>&1; then
info "Daemon service created and started"
else
warn "Failed to create daemon service (you can run 'claude-tasks daemon' manually)"
fi
echo ""
echo -e "${CYAN}Sprite service commands:${NC}"
echo " sprite-env services list # List all services"
echo " sprite-env services stop claude-tasks-daemon # Stop daemon"
echo " sprite-env services start claude-tasks-daemon # Start daemon"
echo ""
}
# Verify installation
verify() {
echo ""
echo -e "${GREEN}β Installation successful!${NC}"
echo ""
echo "Run the TUI:"
echo -e " ${CYAN}claude-tasks${NC}"
echo ""
echo "Run scheduler as daemon:"
echo -e " ${CYAN}claude-tasks daemon${NC}"
echo ""
echo "Data stored in: ~/.claude-tasks/"
echo ""
}
main() {
echo ""
echo "βββββββββββββββββββββββββββββββββββββββββββββ"
echo "β claude-tasks installer β"
echo "βββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
detect_platform
get_latest_version
install
check_path
setup_sprite_service
verify
}
main