-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathactivate.sh
More file actions
125 lines (104 loc) · 3.4 KB
/
Copy pathactivate.sh
File metadata and controls
125 lines (104 loc) · 3.4 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
#!/bin/bash
# LogWhisperer License Activation Script
set -euo pipefail
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Functions
success() { echo -e "${GREEN}✓${NC} $*"; }
error() { echo -e "${RED}✗${NC} $*" >&2; }
info() { echo -e "${BLUE}ℹ${NC} $*"; }
warning() { echo -e "${YELLOW}⚠${NC} $*"; }
echo "╔══════════════════════════════════════════╗"
echo "║ LogWhisperer License Activation ║"
echo "╚══════════════════════════════════════════╝"
echo
# Check if LogWhisperer is installed
if ! command -v logwhisperer >/dev/null 2>&1; then
error "LogWhisperer is not installed or not in PATH"
echo "Please install LogWhisperer first using install.sh"
exit 1
fi
# Check current license status
echo "Checking current license status..."
if logwhisperer --check-license >/dev/null 2>&1; then
success "License is already activated!"
logwhisperer --check-license
exit 0
fi
# Prompt for license key
echo
echo "Enter your Gumroad license key:"
echo "(Get one at: https://gumroad.com/l/logwhisperer)"
echo
read -p "License key: " LICENSE_KEY
if [[ -z "$LICENSE_KEY" ]]; then
error "No license key provided"
exit 1
fi
# Validate the license
echo
echo "Validating license..."
export LOGWHISPERER_LICENSE_KEY="$LICENSE_KEY"
if logwhisperer --check-license; then
success "License validated successfully!"
# Ask about saving the license
echo
read -p "Save license key to your shell profile? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Detect shell
SHELL_RC=""
if [[ -n "${BASH_VERSION:-}" ]]; then
SHELL_RC="$HOME/.bashrc"
elif [[ -n "${ZSH_VERSION:-}" ]]; then
SHELL_RC="$HOME/.zshrc"
else
SHELL_RC="$HOME/.profile"
fi
# Add to shell profile
echo "" >> "$SHELL_RC"
echo "# LogWhisperer License" >> "$SHELL_RC"
echo "export LOGWHISPERER_LICENSE_KEY='$LICENSE_KEY'" >> "$SHELL_RC"
success "License key saved to $SHELL_RC"
info "Run 'source $SHELL_RC' or restart your terminal"
fi
# Create systemd service file if requested
if [[ -d /etc/systemd/system ]] && [[ $EUID -eq 0 ]]; then
read -p "Create systemd service with license? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
cat > /etc/systemd/system/logwhisperer.service << EOF
[Unit]
Description=LogWhisperer Log Monitor
After=network.target
[Service]
Type=simple
User=logwhisperer
Group=logwhisperer
Environment="LOGWHISPERER_LICENSE_KEY=$LICENSE_KEY"
ExecStart=/usr/local/bin/logwhisperer monitor
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
success "Systemd service created"
info "Start with: systemctl start logwhisperer"
fi
fi
echo
success "LogWhisperer is now activated!"
echo
echo "You can now use:"
echo " logwhisperer summarize - Summarize recent logs"
echo " logwhisperer monitor - Start real-time monitoring"
echo " logwhisperer --help - See all options"
else
error "License validation failed"
exit 1
fi