Merge branch 'check-jq-installed' of https://github.com/rblaine95/runtipi into rblaine95-check-jq-installed
This commit is contained in:
commit
84360e738e
1 changed files with 49 additions and 5 deletions
|
@ -16,7 +16,7 @@ function install_docker() {
|
|||
local os="${1}"
|
||||
echo "Installing docker for os ${os}" >/dev/tty
|
||||
|
||||
if [[ "${OS}" == "debian" ]]; then
|
||||
if [[ "${os}" == "debian" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade
|
||||
sudo apt-get install -y ca-certificates curl gnupg jq lsb-release
|
||||
|
@ -26,7 +26,7 @@ function install_docker() {
|
|||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
return 0
|
||||
elif [[ "${OS}" == "ubuntu" ]]; then
|
||||
elif [[ "${os}" == "ubuntu" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade
|
||||
sudo apt-get install -y ca-certificates curl gnupg jq lsb-release
|
||||
|
@ -36,21 +36,21 @@ function install_docker() {
|
|||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
return 0
|
||||
elif [[ "${OS}" == "centos" ]]; then
|
||||
elif [[ "${os}" == "centos" ]]; then
|
||||
sudo yum install -y yum-utils jq
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
sudo yum install -y --allowerasing docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
return 0
|
||||
elif [[ "${OS}" == "fedora" ]]; then
|
||||
elif [[ "${os}" == "fedora" ]]; then
|
||||
sudo dnf -y install dnf-plugins-core jq
|
||||
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
|
||||
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
return 0
|
||||
elif [[ "${OS}" == "arch" ]]; then
|
||||
elif [[ "${os}" == "arch" ]]; then
|
||||
sudo pacman -Sy --noconfirm docker jq
|
||||
sudo systemctl start docker.service
|
||||
sudo systemctl enable docker.service
|
||||
|
@ -66,6 +66,28 @@ function install_docker() {
|
|||
fi
|
||||
}
|
||||
|
||||
function install_jq() {
|
||||
local os="${1}"
|
||||
echo "Installing jq for os ${os}" >/dev/tty
|
||||
|
||||
if [[ "${os}" == "debian" || "${os}" == "ubuntu" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
return 0
|
||||
elif [[ "${os}" == "centos" ]]; then
|
||||
sudo yum install -y jq
|
||||
return 0
|
||||
elif [[ "${os}" == "fedora" ]]; then
|
||||
sudo dnf -y install jq
|
||||
return 0
|
||||
elif [[ "${os}" == "arch" ]]; then
|
||||
sudo pacman -Sy --noconfirm jq
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
OS="$(cat /etc/[A-Za-z]*[_-][rv]e[lr]* | grep "^ID=" | cut -d= -f2 | uniq | tr '[:upper:]' '[:lower:]' | tr -d '"')"
|
||||
SUB_OS="$(cat /etc/[A-Za-z]*[_-][rv]e[lr]* | grep "^ID_LIKE=" | cut -d= -f2 | uniq | tr '[:upper:]' '[:lower:]' | tr -d '"')"
|
||||
|
||||
|
@ -95,3 +117,25 @@ if ! command -v docker-compose >/dev/null; then
|
|||
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
echo "jq is already installed"
|
||||
else
|
||||
install_jq "${OS}"
|
||||
jq_result=$?
|
||||
|
||||
if [[ jq_result -eq 0 ]]; then
|
||||
echo "jq installed"
|
||||
else
|
||||
echo "Your system ${OS} is not supported trying with sub_os ${SUB_OS}"
|
||||
install_jq "${SUB_OS}"
|
||||
jq_sub_result=$?
|
||||
|
||||
if [[ jq_sub_result -eq 0 ]]; then
|
||||
echo "jq installed"
|
||||
else
|
||||
echo "Your system ${SUB_OS} is not supported please install jq manually"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue