-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstall-linux.sh
More file actions
317 lines (261 loc) · 8.43 KB
/
install-linux.sh
File metadata and controls
317 lines (261 loc) · 8.43 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
308
309
310
311
312
313
314
315
316
317
#!/bin/bash
# Auto-Wall Linux Installation Script
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="/opt/auto-wall"
BIN_DIR="/usr/local/bin"
DESKTOP_DIR="/usr/share/applications"
ICONS_DIR="/usr/share/icons/hicolor/256x256/apps"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
check_root() {
if [[ $EUID -eq 0 ]]; then
print_error "This script should not be run as root. Please run as a regular user."
print_error "The script will ask for sudo permissions when needed."
exit 1
fi
}
check_dependencies() {
print_status "Checking dependencies..."
# Check if we're on a supported distribution
if [[ -f /etc/os-release ]]; then
. /etc/os-release
print_status "Detected OS: $NAME"
case "$ID" in
ubuntu|debian|linuxmint|elementary|pop)
PKG_MANAGER="apt"
;;
fedora|centos|rhel)
PKG_MANAGER="dnf"
;;
arch|manjaro)
PKG_MANAGER="pacman"
;;
*)
print_warning "Unsupported distribution: $ID"
print_warning "Installation may not work correctly"
PKG_MANAGER="unknown"
;;
esac
else
print_warning "Could not detect OS distribution"
PKG_MANAGER="unknown"
fi
}
install_dependencies() {
print_status "Installing system dependencies..."
case "$PKG_MANAGER" in
apt)
sudo apt-get update
sudo apt-get install -y python3 python3-tk desktop-file-utils
;;
dnf)
sudo dnf install -y python3 python3-tkinter desktop-file-utils
;;
pacman)
sudo pacman -Sy --noconfirm python python-tkinter desktop-file-utils
;;
*)
print_warning "Unknown package manager. Please install Python 3 and tkinter manually."
;;
esac
}
install_from_appimage() {
local appimage_file="$1"
print_status "Installing from AppImage: $appimage_file"
# Create installation directory
sudo mkdir -p "$INSTALL_DIR"
# Copy AppImage
sudo cp "$appimage_file" "$INSTALL_DIR/auto-wall"
sudo chmod +x "$INSTALL_DIR/auto-wall"
# Create symlink in bin directory
sudo ln -sf "$INSTALL_DIR/auto-wall" "$BIN_DIR/auto-wall"
# Extract icon from AppImage if possible
if command -v 7z >/dev/null 2>&1; then
temp_dir=$(mktemp -d)
cd "$temp_dir"
7z x "$SCRIPT_DIR/$appimage_file" auto-wall.png >/dev/null 2>&1 || true
if [[ -f auto-wall.png ]]; then
sudo mkdir -p "$ICONS_DIR"
sudo cp auto-wall.png "$ICONS_DIR/auto-wall.png"
fi
cd - >/dev/null
rm -rf "$temp_dir"
fi
create_desktop_file
print_success "AppImage installation completed"
}
install_from_deb() {
local deb_file="$1"
print_status "Installing from Debian package: $deb_file"
sudo dpkg -i "$deb_file"
# Fix any missing dependencies
if ! sudo apt-get install -f -y; then
print_error "Failed to install dependencies"
return 1
fi
print_success "Debian package installation completed"
}
install_from_executable() {
local exe_file="$1"
print_status "Installing from standalone executable: $exe_file"
# Create installation directory
sudo mkdir -p "$INSTALL_DIR"
# Copy executable
sudo cp "$exe_file" "$INSTALL_DIR/auto-wall"
sudo chmod +x "$INSTALL_DIR/auto-wall"
# Create symlink in bin directory
sudo ln -sf "$INSTALL_DIR/auto-wall" "$BIN_DIR/auto-wall"
create_desktop_file
print_success "Standalone executable installation completed"
}
create_desktop_file() {
print_status "Creating desktop entry..."
sudo tee "$DESKTOP_DIR/auto-wall.desktop" > /dev/null <<EOF
[Desktop Entry]
Name=Auto-Wall
Comment=Battle Map Wall Detection Tool
Exec=auto-wall
Icon=auto-wall
Type=Application
Categories=Graphics;Photography;
Terminal=false
StartupWMClass=Auto-Wall
EOF
# Update desktop database
if command -v update-desktop-database >/dev/null 2>&1; then
sudo update-desktop-database "$DESKTOP_DIR"
fi
# Update icon cache
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
sudo gtk-update-icon-cache -q "$ICONS_DIR/../../../" 2>/dev/null || true
fi
}
uninstall() {
print_status "Uninstalling Auto-Wall..."
# Remove from package manager if installed
if dpkg -l | grep -q auto-wall 2>/dev/null; then
print_status "Removing Debian package..."
sudo apt-get remove -y auto-wall
fi
# Remove manual installation
if [[ -f "$INSTALL_DIR/auto-wall" ]]; then
print_status "Removing manual installation..."
sudo rm -rf "$INSTALL_DIR"
fi
# Remove symlink
if [[ -L "$BIN_DIR/auto-wall" ]]; then
sudo rm -f "$BIN_DIR/auto-wall"
fi
# Remove desktop file
if [[ -f "$DESKTOP_DIR/auto-wall.desktop" ]]; then
sudo rm -f "$DESKTOP_DIR/auto-wall.desktop"
if command -v update-desktop-database >/dev/null 2>&1; then
sudo update-desktop-database "$DESKTOP_DIR"
fi
fi
# Remove icon
if [[ -f "$ICONS_DIR/auto-wall.png" ]]; then
sudo rm -f "$ICONS_DIR/auto-wall.png"
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
sudo gtk-update-icon-cache -q "$ICONS_DIR/../../../" 2>/dev/null || true
fi
fi
print_success "Auto-Wall has been uninstalled"
}
main() {
echo "Auto-Wall Linux Installation Script"
echo "==================================="
echo
case "${1:-}" in
--uninstall|-u)
uninstall
exit 0
;;
--help|-h)
echo "Usage: $0 [options]"
echo
echo "Options:"
echo " --uninstall, -u Uninstall Auto-Wall"
echo " --help, -h Show this help message"
echo
echo "Installation:"
echo " Run without arguments to auto-detect and install available packages"
exit 0
;;
esac
check_root
check_dependencies
install_dependencies
cd "$SCRIPT_DIR"
# Find available packages
appimage_files=(*.AppImage)
deb_files=(*.deb)
exe_files=()
# Look for standalone executable
if [[ -f "dist/Auto-Wall" ]]; then
exe_files+=("dist/Auto-Wall")
elif [[ -f "Auto-Wall" ]]; then
exe_files+=("Auto-Wall")
fi
# Install in order of preference: .deb > AppImage > standalone
installed=false
# Try .deb first
for deb_file in "${deb_files[@]}"; do
if [[ -f "$deb_file" && "$deb_file" != "*.deb" ]]; then
if install_from_deb "$deb_file"; then
installed=true
break
fi
fi
done
# Try AppImage if .deb failed or not available
if [[ "$installed" == "false" ]]; then
for appimage_file in "${appimage_files[@]}"; do
if [[ -f "$appimage_file" && "$appimage_file" != "*.AppImage" ]]; then
if install_from_appimage "$appimage_file"; then
installed=true
break
fi
fi
done
fi
# Try standalone executable as last resort
if [[ "$installed" == "false" ]]; then
for exe_file in "${exe_files[@]}"; do
if [[ -f "$exe_file" ]]; then
if install_from_executable "$exe_file"; then
installed=true
break
fi
fi
done
fi
if [[ "$installed" == "false" ]]; then
print_error "No suitable package found for installation"
print_error "Please download a package from the releases page:"
print_error "https://github.com/ThreeHats/auto-wall/releases"
exit 1
fi
echo
print_success "Auto-Wall installation completed!"
print_status "You can now run 'auto-wall' from the command line"
print_status "Or find 'Auto-Wall' in your application menu"
}
main "$@"