-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·308 lines (278 loc) · 10.2 KB
/
install.sh
File metadata and controls
executable file
·308 lines (278 loc) · 10.2 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#!/bin/bash
# Installation script for Meshcore Firmware Editor and Flasher (Linux/macOS)
# Don't use set -e here, as we want to continue even if optional dependencies fail
echo "=========================================="
echo "Meshcore Firmware Editor and Flasher - Installation"
echo "=========================================="
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check Python
echo "Checking Python installation..."
if command_exists python3; then
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
echo -e "${GREEN}✓${NC} Python found: $PYTHON_VERSION"
PYTHON_CMD=python3
elif command_exists python; then
PYTHON_VERSION=$(python --version 2>&1 | awk '{print $2}')
echo -e "${GREEN}✓${NC} Python found: $PYTHON_VERSION"
PYTHON_CMD=python
else
echo -e "${RED}✗${NC} Python not found!"
echo "Please install Python 3.6 or higher from https://www.python.org/downloads/"
exit 1
fi
# Check Python version
PYTHON_VER=$($PYTHON_CMD -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
PYTHON_MAJOR=$(echo $PYTHON_VER | cut -d. -f1)
PYTHON_MINOR=$(echo $PYTHON_VER | cut -d. -f2)
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 6 ]); then
echo -e "${RED}✗${NC} Python 3.6 or higher is required (found $PYTHON_VER)"
exit 1
fi
# Check pip
echo ""
echo "Checking pip installation..."
if command_exists pip3; then
echo -e "${GREEN}✓${NC} pip3 found"
PIP_CMD=pip3
elif command_exists pip; then
echo -e "${GREEN}✓${NC} pip found"
PIP_CMD=pip
else
echo -e "${YELLOW}⚠${NC} pip not found, installing..."
$PYTHON_CMD -m ensurepip --upgrade || {
echo -e "${RED}✗${NC} Failed to install pip. Please install pip manually."
exit 1
}
PIP_CMD="$PYTHON_CMD -m pip"
fi
# Check Tkinter
echo ""
echo "Checking Tkinter..."
if $PYTHON_CMD -c "import tkinter" 2>/dev/null; then
echo -e "${GREEN}✓${NC} Tkinter is available"
else
echo -e "${YELLOW}⚠${NC} Tkinter not found"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Installing Tkinter for Linux..."
if command_exists apt-get; then
sudo apt-get update && sudo apt-get install -y python3-tk
elif command_exists dnf; then
sudo dnf install -y python3-tkinter
elif command_exists pacman; then
sudo pacman -S --noconfirm tk
elif command_exists zypper; then
sudo zypper install -y python3-tk
else
echo -e "${YELLOW}⚠${NC} Please install python3-tk using your package manager"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Installing Tkinter for macOS..."
if command_exists brew; then
brew install python-tk
else
echo -e "${YELLOW}⚠${NC} Please install python-tk: brew install python-tk"
fi
fi
fi
# Install the package
echo ""
echo "Installing Meshcore Firmware Editor and Flasher..."
if ! $PIP_CMD install -e . --user; then
echo -e "${RED}✗${NC} Installation failed!"
exit 1
fi
echo ""
echo -e "${GREEN}=========================================="
echo -e "Main installation completed successfully!"
echo -e "==========================================${NC}"
echo ""
# Install optional dependencies
echo ""
echo "Installing optional dependencies..."
echo ""
# Install PlatformIO
echo "Installing PlatformIO..."
if command_exists pio; then
PIO_VERSION=$(pio --version 2>&1 | head -n1)
echo -e "${GREEN}✓${NC} PlatformIO already installed: $PIO_VERSION"
else
echo "Installing PlatformIO via pip..."
if $PIP_CMD install platformio --user; then
# Add user's local bin to PATH if not already there
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo ""
echo -e "${YELLOW}⚠${NC} Note: You may need to add ~/.local/bin to your PATH"
echo " Add this to your ~/.bashrc or ~/.zshrc:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
fi
if command_exists pio; then
PIO_VERSION=$(pio --version 2>&1 | head -n1)
echo -e "${GREEN}✓${NC} PlatformIO installed: $PIO_VERSION"
else
echo -e "${YELLOW}⚠${NC} PlatformIO installed but 'pio' command not found in PATH"
echo " You may need to restart your terminal or add ~/.local/bin to PATH"
fi
else
echo -e "${YELLOW}⚠${NC} Failed to install PlatformIO. You can install it manually:"
echo " $PIP_CMD install platformio"
fi
fi
# Install Git
echo ""
echo "Installing Git..."
if command_exists git; then
GIT_VERSION=$(git --version)
echo -e "${GREEN}✓${NC} Git already installed: $GIT_VERSION"
else
echo "Installing Git..."
GIT_INSTALLED=false
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command_exists apt-get; then
if sudo apt-get update && sudo apt-get install -y git; then
GIT_INSTALLED=true
fi
elif command_exists dnf; then
if sudo dnf install -y git; then
GIT_INSTALLED=true
fi
elif command_exists pacman; then
if sudo pacman -S --noconfirm git; then
GIT_INSTALLED=true
fi
elif command_exists zypper; then
if sudo zypper install -y git; then
GIT_INSTALLED=true
fi
else
echo -e "${YELLOW}⚠${NC} Please install git using your package manager"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command_exists brew; then
if brew install git; then
GIT_INSTALLED=true
fi
else
echo -e "${YELLOW}⚠${NC} Homebrew not found. Installing Git..."
echo " Please install Homebrew first: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
echo " Then run: brew install git"
fi
fi
if [ "$GIT_INSTALLED" = true ] && command_exists git; then
GIT_VERSION=$(git --version)
echo -e "${GREEN}✓${NC} Git installed: $GIT_VERSION"
else
echo -e "${YELLOW}⚠${NC} Git installation may require manual steps"
fi
fi
# Install tkinterweb (for embedded browser in OTA tab)
echo ""
echo "Installing tkinterweb (for embedded browser support)..."
if $PYTHON_CMD -c "import tkinterweb" 2>/dev/null; then
echo -e "${GREEN}✓${NC} tkinterweb already installed"
else
echo "Installing tkinterweb via pip..."
if $PIP_CMD install tkinterweb --user; then
echo -e "${GREEN}✓${NC} tkinterweb installed successfully"
else
echo -e "${YELLOW}⚠${NC} Failed to install tkinterweb. OTA tab will use external browser."
echo " You can install it manually: $PIP_CMD install tkinterweb"
fi
fi
# Install PyQt5 and QScintilla (for advanced code editor features)
echo ""
echo "Installing PyQt5 and QScintilla (optional - for advanced code editor)..."
if $PYTHON_CMD -c "from PyQt5.Qsci import QsciScintilla" 2>/dev/null; then
echo -e "${GREEN}✓${NC} PyQt5 and QScintilla already installed"
else
echo "Installing PyQt5 and QScintilla via pip..."
if $PIP_CMD install PyQt5 PyQt5-QScintilla --user; then
echo -e "${GREEN}✓${NC} PyQt5 and QScintilla installed successfully"
echo " Advanced code editor features (syntax highlighting, code folding, etc.) are now available"
else
echo -e "${YELLOW}⚠${NC} Failed to install PyQt5/QScintilla. Basic editor will be used."
echo " You can install it manually: $PIP_CMD install PyQt5 PyQt5-QScintilla"
echo " Note: QScintilla embedding works best on Windows. Linux/macOS support is limited."
fi
fi
# Create desktop shortcut
echo ""
echo "Creating desktop shortcut..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux: Create .desktop file
DESKTOP_FILE="$HOME/Desktop/meshcore-firmware-editor.desktop"
# Try alternative desktop locations if ~/Desktop doesn't exist
if [ ! -d "$HOME/Desktop" ]; then
if [ -d "$HOME/desktop" ]; then
DESKTOP_FILE="$HOME/desktop/meshcore-firmware-editor.desktop"
elif [ -d "$HOME/.local/share/applications" ]; then
DESKTOP_FILE="$HOME/.local/share/applications/meshcore-firmware-editor.desktop"
else
# Create Desktop directory if it doesn't exist
mkdir -p "$HOME/Desktop" 2>/dev/null || true
fi
fi
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=MeshCore Firmware Editor
Comment=Edit and flash MeshCore firmware
Exec=$SCRIPT_DIR/run.sh
Icon=applications-development
Terminal=false
Categories=Development;Electronics;
Path=$SCRIPT_DIR
EOF
chmod +x "$DESKTOP_FILE"
chmod +x "$SCRIPT_DIR/run.sh"
# Try to make it executable/trusted (some desktop environments require this)
if command_exists gio; then
gio set "$DESKTOP_FILE" metadata::trusted true 2>/dev/null || true
fi
if [ -f "$DESKTOP_FILE" ]; then
echo -e "${GREEN}✓${NC} Desktop shortcut created: $DESKTOP_FILE"
else
echo -e "${YELLOW}⚠${NC} Could not create desktop shortcut"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS: Create .command file (simpler than .app bundle)
DESKTOP_FILE="$HOME/Desktop/MeshCore Firmware Editor.command"
cat > "$DESKTOP_FILE" << EOF
#!/bin/bash
cd "$SCRIPT_DIR"
exec ./run.sh
EOF
chmod +x "$DESKTOP_FILE"
chmod +x "$SCRIPT_DIR/run.sh"
if [ -f "$DESKTOP_FILE" ]; then
echo -e "${GREEN}✓${NC} Desktop launcher created: $DESKTOP_FILE"
else
echo -e "${YELLOW}⚠${NC} Could not create desktop launcher"
fi
fi
echo ""
echo -e "${GREEN}=========================================="
echo -e "Installation completed!"
echo -e "==========================================${NC}"
echo ""
echo "You can now run the application with:"
echo " meshcore-firmware-editor"
echo ""
echo "Or directly with:"
echo " $PYTHON_CMD meshcore_flasher.py"
echo ""
if [ -f "$DESKTOP_FILE" ] 2>/dev/null; then
echo "Or double-click the desktop shortcut!"
echo ""
fi