-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall.sh
More file actions
212 lines (183 loc) · 8.04 KB
/
install.sh
File metadata and controls
212 lines (183 loc) · 8.04 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
204
205
206
207
208
209
210
211
212
#!/bin/bash
# Colors for pretty output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
BOLD='\033[1m'
# Banner
echo -e "${CYAN}${BOLD}"
echo "╔═══════════════════════════════════════════╗"
echo "║ ║"
echo "║ 🤖 MOLTRON INSTALLER 🤖 ║"
echo "║ ║"
echo "║ Self-Evolving OpenClaw Skill ║"
echo "╚═══════════════════════════════════════════╝"
echo -e "${NC}"
echo ""
# GitHub repository details
GITHUB_USER="${GITHUB_USER:-adridder}" # Can be overridden with env var
GITHUB_REPO="${GITHUB_REPO:-moltron}" # Can be overridden with env var
GITHUB_BRANCH="${GITHUB_BRANCH:-main}" # Can be overridden with env var
# Determine the target directory
TARGET_DIR="$HOME/.openclaw/workspace/skills"
echo -e "${BLUE}📍 Target installation directory:${NC}"
echo -e " ${MAGENTA}$TARGET_DIR${NC}"
echo ""
# Check if the target directory exists, if not create it
if [ ! -d "$TARGET_DIR" ]; then
echo -e "${YELLOW}⚠️ Target directory does not exist. Creating...${NC}"
mkdir -p "$TARGET_DIR"
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Successfully created directory!${NC}"
else
echo -e "${RED}❌ Failed to create directory. Please check permissions.${NC}"
exit 1
fi
else
echo -e "${GREEN}✅ Target directory exists!${NC}"
fi
echo ""
# Check if running from local repo or need to download
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="$SCRIPT_DIR/moltron-skill-creator"
# Check if we're running from within the target directory (piped install from wrong location)
if [[ "$SCRIPT_DIR" == "$TARGET_DIR"* ]]; then
# Running from target directory, force remote mode
INSTALL_MODE="remote"
elif [ -d "$SOURCE_DIR" ] && [ -f "$SCRIPT_DIR/install.sh" ]; then
# Local installation (repo is cloned and install.sh exists alongside moltron-skill-creator)
echo -e "${BLUE}📦 Installing from local repository...${NC}"
INSTALL_MODE="local"
else
INSTALL_MODE="remote"
fi
if [ "$INSTALL_MODE" = "remote" ]; then
# Remote installation (download from GitHub)
echo -e "${BLUE}🌐 Downloading from GitHub...${NC}"
# Create temporary directory
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
# Download the repository archive
ARCHIVE_URL="https://github.com/${GITHUB_USER}/${GITHUB_REPO}/archive/refs/heads/${GITHUB_BRANCH}.tar.gz"
echo -e "${BLUE} Downloading from: ${MAGENTA}$ARCHIVE_URL${NC}"
if command -v curl &> /dev/null; then
curl -sL "$ARCHIVE_URL" -o "$TEMP_DIR/repo.tar.gz"
elif command -v wget &> /dev/null; then
wget -q "$ARCHIVE_URL" -O "$TEMP_DIR/repo.tar.gz"
else
echo -e "${RED}❌ Error: Neither curl nor wget found. Please install one of them.${NC}"
exit 1
fi
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to download repository!${NC}"
echo -e "${YELLOW} Please check your internet connection and repository URL.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Download complete!${NC}"
echo ""
# Extract the archive
echo -e "${BLUE}📂 Extracting files...${NC}"
tar -xzf "$TEMP_DIR/repo.tar.gz" -C "$TEMP_DIR"
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to extract archive!${NC}"
exit 1
fi
# Find the moltron-skill-creator folder in the extracted archive
SOURCE_DIR=$(find "$TEMP_DIR" -type d -name "moltron-skill-creator" -not -path "*/\.*" | head -n 1)
if [ -z "$SOURCE_DIR" ] || [ ! -d "$SOURCE_DIR" ]; then
echo -e "${RED}❌ Error: 'moltron-skill-creator' folder not found in the downloaded repository!${NC}"
exit 1
fi
echo -e "${GREEN}✅ Files extracted!${NC}"
echo ""
fi
# Check if moltron-skill-creator already exists in target
if [ -d "$TARGET_DIR/moltron-skill-creator" ]; then
echo -e "${YELLOW}╔═══════════════════════════════════════════╗${NC}"
echo -e "${YELLOW}║ ⚠️ UPDATE DETECTED ⚠️ ║${NC}"
echo -e "${YELLOW}╚═══════════════════════════════════════════╝${NC}"
echo ""
echo -e "${YELLOW}${BOLD}Moltron Skill Creator is already installed${NC}"
echo -e "${YELLOW}Location: ${MAGENTA}$TARGET_DIR/moltron-skill-creator${NC}"
echo ""
echo -e "${RED}${BOLD}⚠️ WARNING:${NC}"
echo -e "${RED} Proceeding will ${BOLD}PERMANENTLY OVERWRITE${NC}${RED} the existing installation.${NC}"
echo -e "${RED} All local modifications and data will be ${BOLD}LOST${NC}${RED}.${NC}"
echo ""
echo -e "${CYAN}💡 ${BOLD}Recommendation:${NC}"
echo -e "${CYAN} If you have made custom changes, cancel now (press N)${NC}"
echo -e "${CYAN} and create a backup first:${NC}"
echo -e "${BLUE} cp -r $TARGET_DIR/moltron-skill-creator ~/moltron/backups/moltron-skill-creator.backup${NC}"
echo ""
# Auto-yes mode for non-interactive installs
if [ "$AUTO_YES" = "true" ]; then
echo -e "${BLUE} Auto-yes mode enabled, proceeding with update...${NC}"
echo ""
else
echo -e "${BOLD}${CYAN} Do you want to proceed with the update? ${YELLOW}(y/N)${NC}"
echo -n " Your choice: "
read -n 1 -r REPLY < /dev/tty
echo ""
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo -e "${GREEN}✅ Update cancelled. Your existing installation is safe.${NC}"
echo ""
echo -e "${CYAN}To backup your current installation, run:${NC}"
echo -e "${BLUE}mkdir -p ~/moltron/backups && cp -r $TARGET_DIR/moltron-skill-creator ~/moltron/backups/moltron-skill-creator.backup${NC}"
echo ""
exit 0
fi
fi
echo ""
echo -e "${BLUE}📝 Creating backup before update...${NC}"
# Create backup directory if it doesn't exist
BACKUP_BASE_DIR="$HOME/moltron/backups"
if [ ! -d "$BACKUP_BASE_DIR" ]; then
mkdir -p "$BACKUP_BASE_DIR"
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Created backup directory: ${MAGENTA}$BACKUP_BASE_DIR${NC}"
else
echo -e "${YELLOW}⚠️ Failed to create backup directory, but continuing...${NC}"
fi
fi
# Create automatic backup with timestamp
BACKUP_DIR="$BACKUP_BASE_DIR/moltron-skill-creator.backup.$(date +%Y%m%d_%H%M%S)"
cp -r "$TARGET_DIR/moltron-skill-creator" "$BACKUP_DIR"
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Backup created at: ${MAGENTA}$BACKUP_DIR${NC}"
else
echo -e "${YELLOW}⚠️ Failed to create backup, but continuing...${NC}"
fi
echo ""
fi
# Copy the moltron-skill-creator folder
echo -e "${BLUE}📦 Installing Moltron Skill Creator...${NC}"
cp -r "$SOURCE_DIR" "$TARGET_DIR/"
if [ $? -eq 0 ]; then
echo -e "${GREEN}${BOLD}✨ SUCCESS! ✨${NC}"
echo ""
echo -e "${GREEN}🎉 Moltron Skill Creator has been installed successfully!${NC}"
echo ""
echo -e "${CYAN}📝 Installation details:${NC}"
if [ "$INSTALL_MODE" = "remote" ]; then
echo -e " From: ${MAGENTA}GitHub (${GITHUB_USER}/${GITHUB_REPO})${NC}"
else
echo -e " From: ${MAGENTA}$SOURCE_DIR${NC}"
fi
echo -e " To: ${MAGENTA}$TARGET_DIR/moltron-skill-creator${NC}"
echo ""
echo -e "${YELLOW}${BOLD}Next steps:${NC}"
echo -e " 2️⃣ The Moltron skill should now be available"
echo -e " 3️⃣ Your agents can now learn and evolve! 🚀"
echo ""
else
echo -e "${RED}❌ Installation failed!${NC}"
echo -e "${YELLOW} Please check permissions and try again.${NC}"
exit 1
fi
# build 5