-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
166 lines (148 loc) · 3.78 KB
/
Copy pathinstall.sh
File metadata and controls
166 lines (148 loc) · 3.78 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
#!/bin/bash
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}OSA Installer${NC}"
echo "=================="
echo ""
# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
darwin)
OS="macos"
;;
mingw*|msys*|cygwin*)
OS="windows"
EXE_EXT=".exe"
;;
linux)
OS="linux"
;;
*)
echo -e "${RED}Unsupported OS: $OS${NC}"
exit 1
;;
esac
case "$ARCH" in
x86_64|amd64)
ARCH="x86_64"
;;
arm64|aarch64)
ARCH="arm64"
;;
*)
echo -e "${RED}Unsupported architecture: $ARCH${NC}"
exit 1
;;
esac
echo -e "Detected: ${YELLOW}${OS}-${ARCH}${NC}"
echo ""
# Determine binary name
if [ "$OS" = "windows" ]; then
BINARY_NAME="osagent-${OS}-${ARCH}.exe"
else
BINARY_NAME="osagent-${OS}-${ARCH}"
fi
# Download URL
REPO="${REPO:-osagent/osagent}"
VERSION="${VERSION:-latest}"
if [ "$VERSION" = "latest" ]; then
URL="https://github.com/${REPO}/releases/latest/download/${BINARY_NAME}"
else
URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY_NAME}"
fi
# Download binary
echo -e "${YELLOW}Downloading OSA...${NC}"
if command -v curl &> /dev/null; then
curl -fsSL "$URL" -o osagent
elif command -v wget &> /dev/null; then
wget -q "$URL" -O osagent
else
echo -e "${RED}Error: Neither curl nor wget found${NC}"
exit 1
fi
# Make executable (Unix-like systems)
if [ "$OS" != "windows" ]; then
chmod +x osagent
fi
# Move to installation directory
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
echo -e "${YELLOW}Installing to ${INSTALL_DIR}...${NC}"
if [ -w "$INSTALL_DIR" ]; then
mv osagent "${INSTALL_DIR}/osagent"
else
echo -e "${YELLOW}Need sudo to install to ${INSTALL_DIR}${NC}"
sudo mv osagent "${INSTALL_DIR}/osagent"
fi
echo ""
echo -e "${GREEN}✓ OSA installed successfully!${NC}"
echo ""
# Run setup wizard
read -p "Run setup wizard now? [Y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Nn]$ ]]; then
"${INSTALL_DIR}/osagent" setup
fi
# Optional: Install as service
echo ""
read -p "Install as system service? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ "$OS" = "linux" ]; then
echo -e "${YELLOW}Installing systemd service...${NC}"
cat <<EOF | sudo tee /etc/systemd/system/osagent.service > /dev/null
[Unit]
Description=OSA AI Assistant
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=${INSTALL_DIR}/osagent start
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable osagent
echo -e "${GREEN}✓ Service installed. Run 'sudo systemctl start osagent' to start.${NC}"
elif [ "$OS" = "macos" ]; then
echo -e "${YELLOW}Installing launchd service...${NC}"
cat <<EOF > ~/Library/LaunchAgents/com.osagent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.osagent</string>
<key>ProgramArguments</key>
<array>
<string>${INSTALL_DIR}/osagent</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/com.osagent.plist
echo -e "${GREEN}✓ Service installed and started.${NC}"
elif [ "$OS" = "windows" ]; then
echo -e "${YELLOW}For Windows, use Task Scheduler or NSSM to install as service.${NC}"
echo "See: https://nssm.cc/"
fi
fi
echo ""
echo -e "${GREEN}Installation complete!${NC}"
echo ""
echo "Next steps:"
echo " 1. Edit config: ${INSTALL_DIR}/osagent config edit"
echo " 2. Start agent: ${INSTALL_DIR}/osagent start"
echo " 3. Open http://localhost:8765 in your browser"
echo ""