-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path,install_sys_cmd
executable file
·47 lines (42 loc) · 1.21 KB
/
,install_sys_cmd
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
#!/usr/bin/env bash
# Thanks https://unix.stackexchange.com/a/6348/5362
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
INSTALL_CMD="zypper install"
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
INSTALL_CMD="yum install"
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
echo "$OS $VER"
if [[ "$OS" == "Manjaro"* || "$OS" == "Arch"* ]]; then
# arch or manjaro
INSTALL_CMD="pacman -Sy"
fi
# When we are here, we should have figured out the pkg manager.
if [[ ! -v INSTALL_CMD ]]; then
echo "Could not figure out pkg manager."
exit 1;
fi
set -x; sudo $INSTALL_CMD $@; set +x