-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·130 lines (113 loc) · 3.23 KB
/
install.sh
File metadata and controls
executable file
·130 lines (113 loc) · 3.23 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
#!/bin/bash
# Hardware Control Center Installation Script
set -e
echo "========================================"
echo "Hardware Control Center Installation"
echo "========================================"
echo ""
# Check if running on Linux
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
echo "Error: This script is designed for Linux systems"
exit 1
fi
# Check Python version
echo "[1/6] Checking Python version..."
python_version=$(python3 --version 2>&1 | awk '{print $2}')
echo "Found Python $python_version"
if ! python3 -c 'import sys; exit(0 if sys.version_info >= (3, 7) else 1)'; then
echo "Error: Python 3.7 or higher required"
exit 1
fi
# Install system dependencies
echo ""
echo "[2/6] Installing system dependencies..."
echo "This requires sudo privileges"
if command -v apt-get &> /dev/null; then
sudo apt-get update
sudo apt-get install -y \
python3-pip \
python3-pyqt5 \
libusb-1.0-0 \
i2c-tools \
libi2c-dev \
python3-dev \
libgpiod2 \
2>/dev/null || echo "Some packages may already be installed"
elif command -v yum &> /dev/null; then
sudo yum install -y \
python3-pip \
python3-qt5 \
libusb \
i2c-tools \
2>/dev/null || echo "Some packages may already be installed"
else
echo "Warning: Unknown package manager. Please install dependencies manually:"
echo " - Python 3.7+"
echo " - PyQt5"
echo " - libusb"
echo " - i2c-tools"
fi
# Create virtual environment
echo ""
echo "[3/6] Creating Python virtual environment..."
if [ ! -d "venv" ]; then
python3 -m venv venv
echo "Virtual environment created"
else
echo "Virtual environment already exists"
fi
# Install Python dependencies
echo ""
echo "[4/6] Installing Python dependencies..."
source venv/bin/activate
pip3 install --upgrade pip
pip3 install -r requirements.txt
deactivate
# Add user to required groups
echo ""
echo "[5/7] Adding user to hardware access groups..."
current_user=$(whoami)
for group in dialout i2c spi plugdev gpio; do
if getent group $group > /dev/null 2>&1; then
sudo usermod -a -G $group $current_user 2>/dev/null || true
echo "Added to group: $group"
fi
done
# Create desktop launcher (optional)
echo ""
echo "[6/7] Creating desktop launcher..."
desktop_file="$HOME/.local/share/applications/hardware-control-center.desktop"
mkdir -p "$(dirname "$desktop_file")"
cat > "$desktop_file" << EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Hardware Control Center
Comment=Unified hardware management interface
Exec=$(pwd)/run.sh
Icon=applications-system
Terminal=false
Categories=System;Utility;
EOF
echo "Desktop launcher created"
# Make scripts executable
echo ""
echo "[7/7] Setting permissions..."
chmod +x main.py run.sh
echo ""
echo "========================================"
echo "Installation Complete!"
echo "========================================"
echo ""
echo "IMPORTANT: You must logout and login for group changes to take effect!"
echo ""
echo "To run the application:"
echo " cd $(pwd)"
echo " ./run.sh"
echo ""
echo "Or find 'Hardware Control Center' in your application menu"
echo ""
echo "Configuration file: configs/default.json"
echo ""
echo "For troubleshooting, see README.md"
echo ""