2022-12-16 23:23:07 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
echo "Installing runtipi..."
|
2023-03-02 19:19:20 +00:00
|
|
|
|
|
|
|
ARCHITECTURE="$(uname -m)"
|
|
|
|
# Not supported on 32 bits systems
|
|
|
|
if [[ "$ARCHITECTURE" == "armv7"* ]] || [[ "$ARCHITECTURE" == "i686" ]] || [[ "$ARCHITECTURE" == "i386" ]]; then
|
2023-08-31 21:15:25 +00:00
|
|
|
echo "runtipi is not supported on 32 bits systems"
|
|
|
|
exit 1
|
2023-03-02 19:19:20 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-22 05:48:59 +00:00
|
|
|
### --------------------------------
|
|
|
|
### CLI arguments
|
|
|
|
### --------------------------------
|
|
|
|
UPDATE="false"
|
2023-08-24 06:49:13 +00:00
|
|
|
VERSION="latest"
|
2023-08-22 05:48:59 +00:00
|
|
|
while [ -n "${1-}" ]; do
|
|
|
|
case "$1" in
|
|
|
|
--update) UPDATE="true" ;;
|
2023-08-24 06:49:13 +00:00
|
|
|
--version)
|
|
|
|
shift # Move to the next parameter
|
|
|
|
VERSION="$1" # Assign the value to VERSION
|
|
|
|
if [ -z "$VERSION" ]; then
|
|
|
|
echo "Option --version requires a value" && exit 1
|
|
|
|
fi
|
|
|
|
;;
|
2023-08-22 05:48:59 +00:00
|
|
|
--)
|
|
|
|
shift # The double dash makes them parameters
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*) echo "Option $1 not recognized" && exit 1 ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2023-03-02 19:19:20 +00:00
|
|
|
|
2023-08-15 20:49:50 +00:00
|
|
|
OS="$(cat /etc/[A-Za-z]*[_-][rv]e[lr]* | grep "^ID=" | cut -d= -f2 | uniq | tr '[:upper:]' '[:lower:]' | tr -d '"')"
|
2023-08-25 22:27:50 +00:00
|
|
|
SUB_OS="$(cat /etc/[A-Za-z]*[_-][rv]e[lr]* | grep "^ID_LIKE=" | cut -d= -f2 | uniq | tr '[:upper:]' '[:lower:]' | tr -d '"' || echo 'unknown')"
|
2023-08-15 20:49:50 +00:00
|
|
|
|
|
|
|
function install_generic() {
|
|
|
|
local dependency="${1}"
|
|
|
|
local os="${2}"
|
|
|
|
|
|
|
|
if [[ "${os}" == "debian" ]]; then
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${dependency}"
|
|
|
|
return 0
|
|
|
|
elif [[ "${os}" == "ubuntu" || "${os}" == "pop" ]]; then
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${dependency}"
|
|
|
|
return 0
|
|
|
|
elif [[ "${os}" == "centos" ]]; then
|
|
|
|
sudo yum install -y --allowerasing "${dependency}"
|
|
|
|
return 0
|
|
|
|
elif [[ "${os}" == "fedora" ]]; then
|
|
|
|
sudo dnf -y install "${dependency}"
|
|
|
|
return 0
|
|
|
|
elif [[ "${os}" == "arch" ]]; then
|
|
|
|
if ! sudo pacman -Sy --noconfirm "${dependency}" ; then
|
|
|
|
if command -v yay > /dev/null 2>&1 ; then
|
|
|
|
sudo -u $SUDO_USER yay -Sy --noconfirm "${dependency}"
|
|
|
|
else
|
|
|
|
echo "Could not install \"${dependency}\", either using pacman or the yay AUR helper. Please try installing it manually."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_docker() {
|
|
|
|
local os="${1}"
|
|
|
|
echo "Installing docker for os ${os}"
|
|
|
|
|
|
|
|
if [[ "${os}" == "debian" ]]; then
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl gnupg lsb-release
|
|
|
|
sudo mkdir -p /etc/apt/keyrings
|
|
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
|
|
return 0
|
|
|
|
elif [[ "${os}" == "ubuntu" || "${os}" == "pop" ]]; then
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl gnupg lsb-release
|
|
|
|
sudo mkdir -p /etc/apt/keyrings
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
|
|
return 0
|
|
|
|
elif [[ "${os}" == "centos" ]]; then
|
|
|
|
sudo yum install -y yum-utils
|
|
|
|
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
|
|
|
|
sudo dnf -y install dnf-plugins-core
|
|
|
|
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
|
|
|
|
sudo pacman -Sy --noconfirm docker docker-compose
|
|
|
|
sudo systemctl start docker.service
|
|
|
|
sudo systemctl enable docker.service
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! command -v docker >/dev/null; then
|
|
|
|
echo "Installing docker"
|
|
|
|
install_docker "${OS}"
|
|
|
|
docker_result=$?
|
|
|
|
|
|
|
|
if [[ docker_result -eq 0 ]]; then
|
|
|
|
echo "Docker installed"
|
|
|
|
else
|
|
|
|
echo "Your system ${OS} is not supported trying with sub_os ${SUB_OS}"
|
|
|
|
install_docker "${SUB_OS}"
|
|
|
|
docker_sub_result=$?
|
|
|
|
|
|
|
|
if [[ docker_sub_result -eq 0 ]]; then
|
|
|
|
echo "Docker installed"
|
|
|
|
else
|
|
|
|
echo "Your system ${SUB_OS} is not supported please install docker manually"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2022-12-16 23:23:07 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-15 20:49:50 +00:00
|
|
|
function check_dependency_and_install() {
|
|
|
|
local dependency="${1}"
|
|
|
|
|
|
|
|
if ! command -v "${dependency}" >/dev/null; then
|
|
|
|
echo "Installing ${dependency}"
|
|
|
|
install_generic "${dependency}" "${OS}"
|
|
|
|
install_result=$?
|
|
|
|
|
|
|
|
if [[ install_result -eq 0 ]]; then
|
|
|
|
echo "${dependency} installed"
|
|
|
|
else
|
|
|
|
echo "Your system ${OS} is not supported trying with sub_os ${SUB_OS}"
|
|
|
|
install_generic "${dependency}" "${SUB_OS}"
|
|
|
|
install_sub_result=$?
|
|
|
|
|
|
|
|
if [[ install_sub_result -eq 0 ]]; then
|
|
|
|
echo "${dependency} installed"
|
|
|
|
else
|
|
|
|
echo "Your system ${SUB_OS} is not supported please install ${dependency} manually"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Example
|
|
|
|
# check_dependency_and_install "openssl"
|
2022-12-16 23:23:07 +00:00
|
|
|
|
2023-08-24 06:49:13 +00:00
|
|
|
# If version was not given it will install the latest version
|
|
|
|
if [[ "${VERSION}" == "latest" ]]; then
|
2023-10-16 20:58:25 +00:00
|
|
|
LATEST_VERSION=$(curl -sL https://api.github.com/repos/runtipi/runtipi/releases/latest | grep tag_name | cut -d '"' -f4)
|
2023-08-24 06:49:13 +00:00
|
|
|
VERSION="${LATEST_VERSION}"
|
|
|
|
fi
|
2023-08-22 05:48:59 +00:00
|
|
|
|
2023-08-24 06:49:13 +00:00
|
|
|
ASSET="runtipi-cli-linux-x64"
|
2023-08-15 20:49:50 +00:00
|
|
|
if [ "$ARCHITECTURE" == "arm64" ] || [ "$ARCHITECTURE" == "aarch64" ]; then
|
2023-08-24 06:49:13 +00:00
|
|
|
ASSET="runtipi-cli-linux-arm64"
|
2022-12-16 23:23:07 +00:00
|
|
|
fi
|
|
|
|
|
2023-10-12 19:16:37 +00:00
|
|
|
URL="https://github.com/runtipi/runtipi/releases/download/$VERSION/$ASSET"
|
2023-06-18 16:36:06 +00:00
|
|
|
|
2023-08-22 05:48:59 +00:00
|
|
|
if [[ "${UPDATE}" == "false" ]]; then
|
2023-08-31 21:15:25 +00:00
|
|
|
mkdir -p runtipi
|
|
|
|
cd runtipi || exit
|
2023-08-22 05:48:59 +00:00
|
|
|
fi
|
2022-12-16 23:23:07 +00:00
|
|
|
|
2023-08-22 05:48:59 +00:00
|
|
|
curl --location "$URL" -o ./runtipi-cli
|
2023-08-22 20:31:10 +00:00
|
|
|
chmod +x ./runtipi-cli
|
2023-08-22 05:48:59 +00:00
|
|
|
|
2023-08-26 09:29:23 +00:00
|
|
|
# Check if git is installed
|
|
|
|
if ! command -v git >/dev/null; then
|
|
|
|
echo "Git is not installed. Please install git and restart the script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-11-02 17:01:09 +00:00
|
|
|
sudo ./runtipi-cli start
|