forked from collin80/SavvyCAN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-linux.sh
More file actions
executable file
·79 lines (65 loc) · 1.6 KB
/
install-linux.sh
File metadata and controls
executable file
·79 lines (65 loc) · 1.6 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
#!/bin/bash
APP_PATH="/usr/bin/SavvyCAN"
DESKTOP_PATH="/usr/share/applications/savvycan.desktop"
ICON_PATH="/usr/share/pixmaps/SavvyCAN.png"
require_root() {
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root."
exit 1
fi
}
show_help() {
echo "Usage: $0 [option]"
echo ""
echo "Options:"
echo " --help Show this help message"
echo " --uninstall Remove SavvyCAN from the system"
echo " (no option) Install or reinstall SavvyCAN"
}
install_error() {
echo "SavvyCAN installation failed."
exit 1
}
uninstall_error() {
echo "SavvyCAN uninstallation failed."
exit 1
}
if [ "$1" = "--help" ]; then
show_help
exit 0
fi
require_root
# Uninstall
if [ "$1" = "--uninstall" ]; then
echo "Uninstalling SavvyCAN..."
trap uninstall_error ERR
rm -f "$APP_PATH" "$DESKTOP_PATH" "$ICON_PATH"
trap - ERR
echo "SavvyCAN has been uninstalled."
exit 0
fi
# Check required files
if [ ! -f "SavvyCAN" ]; then
echo "Missing file \"SavvyCAN\". You need to build first."
install_error
fi
if [ ! -f "SavvyCAN.desktop" ]; then
echo "Missing file \"SavvyCAN.desktop\"."
install_error
fi
if [ ! -f "icons/SavvyIcon.png" ]; then
echo "Missing file \"icons/SavvyIcon.png\"."
install_error
fi
# Install
if [ -f "$APP_PATH" ]; then
echo "Re-installing SavvyCAN..."
else
echo "Installing SavvyCAN..."
fi
trap install_error ERR
install -Dm755 SavvyCAN "$APP_PATH"
install -Dm644 SavvyCAN.desktop "$DESKTOP_PATH"
install -Dm644 icons/SavvyIcon.png "$ICON_PATH"
trap - ERR
echo "SavvyCAN is installed."