-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·74 lines (67 loc) · 1.76 KB
/
install.sh
File metadata and controls
executable file
·74 lines (67 loc) · 1.76 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
#!/bin/sh
# Determine the package manager
detect_package_manager() {
if command -v apt > /dev/null; then
echo "apt"
elif command -v dnf > /dev/null; then
echo "dnf"
elif command -v yum > /dev/null; then
echo "yum"
elif command -v pacman > /dev/null; then
echo "pacman"
elif command -v zypper > /dev/null; then
echo "zypper"
elif command -v apk > /dev/null; then
echo "apk"
elif command -v brew > /dev/null; then
echo "brew"
else
echo "unsupported"
fi
}
# Check if the package is installed
is_installed() {
case "$1" in
apt) dpkg -s "$PACKAGE" > /dev/null 2>&1 ;;
dnf|yum) rpm -q "$PACKAGE" > /dev/null 2>&1 ;;
pacman) pacman -Qi "$PACKAGE" > /dev/null 2>&1 ;;
zypper) rpm -q "$PACKAGE" > /dev/null 2>&1 ;;
apk) apk info "$PACKAGE" > /dev/null 2>&1 ;;
brew) brew list "$PACKAGE" > /dev/null 2>&1 ;;
*) return 1 ;;
esac
}
# Install the package
install_package() {
case "$1" in
apt) apt update && sudo apt install -y $package_list ;;
dnf) dnf install -y $package_list ;;
yum) yum install -y $package_list ;;
pacman) pacman -Sy --noconfirm $package_list ;;
zypper) zypper install -y $package_list ;;
apk) apk add $package_list ;;
brew) brew install $package_list ;;
*) echo "Unsupported package manager"; exit 2 ;;
esac
}
check() {
PACKAGE="$1"
if is_installed "$PM"; then
echo "Package '$PACKAGE' is already installed."
else
package_list="$package_list $1"
fi
}
PM=$(detect_package_manager)
if [ "$PM" = "unsupported" ]; then
echo "No supported package manager found on this system."
exit 2
fi
#package_list=""
#check nano
check nmap
check sshpass
#if [ -n "$package_list" ]; then
# echo "Installing$package_list using $PM..."
# install_package "$PM"
#fi