-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·136 lines (116 loc) · 2.75 KB
/
install.sh
File metadata and controls
executable file
·136 lines (116 loc) · 2.75 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
#!/bin/bash
check() {
command -v "$1" &>/dev/null
}
# Set destination directory
DEST=$HOME/.local/bin
# Check if $DEST exists and create if not
if [ ! -d "$DEST" ]; then
echo "Creating $DEST directory..."
mkdir -p "$DEST"
fi
# Create .config directory if not exist
CONFIG_DIR="$HOME/.config"
if [ ! -d "$CONFIG_DIR" ]; then
echo "Creating $CONFIG_DIR directory..."
mkdir -p "$CONFIG_DIR"
fi
checks() {
# check if DEST in PATH variable
if [[ ":$PATH:" != *":$DEST:"* ]]; then
echo "$DEST is not in PATH variable. Add it to PATH variable."
fi
# Call function to check dependencies
check_dependencies
}
# Getting the package manager
get_package_manager() {
if check apt; then
PACKAGE_MANAGER="apt"
elif check yum; then
PACKAGE_MANAGER="yum"
elif check dnf; then
PACKAGE_MANAGER="dnf"
elif check pacman; then
PACKAGE_MANAGER="pacman"
elif check yay; then
PACKAGE_MANAGER="yay"
elif check zypper; then
PACKAGE_MANAGER="zypper"
else
PACKAGE_MANAGER="Unknown"
fi
}
# Install dependencies
install_dependencies() {
case $PACKAGE_MANAGER in
"apt")
sudo apt update
sudo apt install -y "${MISSING_DEPENDENCIES[@]}"
;;
"yum" | "dnf")
sudo yum install -y "${MISSING_DEPENDENCIES[@]}"
;;
"pacman" | "yay")
sudo $PACKAGE_MANAGER -Sy --noconfirm "${MISSING_DEPENDENCIES[@]}"
;;
"zypper")
sudo zypper install -y "${MISSING_DEPENDENCIES[@]}"
;;
*)
echo "Unknown package manager. Please install curl and jq manually."
;;
esac
}
# Check dependencies
check_dependencies() {
get_package_manager
MISSING_DEPENDENCIES=()
# Check for curl
if ! check curl; then
MISSING_DEPENDENCIES+=("curl")
fi
# Check for jq
if ! check jq; then
MISSING_DEPENDENCIES+=("jq")
fi
if [ ${#MISSING_DEPENDENCIES[@]} -gt 0 ]; then
echo "Missing dependencies: ${MISSING_DEPENDENCIES[*]}"
echo "Installing dependencies..."
install_dependencies
else
echo "All dependencies are installed."
fi
}
install() {
checks
# Download excuse database
echo "Installing Excuse database..."
curl -fsSL https://raw.githubusercontent.com/K4R7IK/DevExcuse/master/excuse.json -o "$CONFIG_DIR/excuse.json"
# Download devexcuse script
echo "Installing devexcuse..."
curl -fsSL https://raw.githubusercontent.com/K4R7IK/DevExcuse/master/devexcuse.sh -o "$DEST/devexcuse"
# Set executable permissions
echo "Setting executable permissions..."
chmod +x "$DEST/devexcuse"
}
uninstall() {
echo "Uninstalling devexcuse..."
rm -f "$DEST/devexcuse"
# user if the want to remove the database
read -r -p "Do you want to remove the excuse database? [y/N]: " response
case $response in
[yY][eE][sS] | [yY])
echo "Uninstalling Excuse database..."
rm -f "$CONFIG_DIR/excuse.json"
;;
esac
echo "Uninstall complete."
}
case $1 in
"uninstall")
uninstall
exit
;;
esac
install