runtipi/scripts/install.sh

198 lines
6.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
echo "Installing runtipi..."
Release/1.0.0 (#316) * fix: create default media folder structure on install * feat: add link to open exposed app to domain * [ImgBot] Optimize images *Total -- 2,048.42kb -> 1,263.43kb (38.32%) /screenshots/darkmode.png -- 998.43kb -> 609.77kb (38.93%) /screenshots/appstore.png -- 1,006.73kb -> 620.12kb (38.4%) /packages/dashboard/public/error.png -- 42.38kb -> 32.70kb (22.84%) /packages/dashboard/public/empty.svg -- 0.87kb -> 0.85kb (2.35%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * chore: bump version 0.8.1 * refactor: move all dashboard's files into a client folder * feat: setup trpc and create system router * test: split jest config for client and server * refactor: replace grapqhl queries with trpc in the frontend * refactor: remove now un-used system queries/mutations/resolvers from both client and server * chore: bump dependencies * feat: setup prisma and configure it for tests and development * feat: create trpc router for auth service * refactor: migrate client auth queries to trpc procedures * refactor: cleanup now un-used graphql resolvers and services * feat: create sql migrations by replicating typeorm ones in an idempotent manner * feat: create server-preload script to run migrations upon server start * chore: remove legacy migrations steps * feat: add redis_host as an env variable * refactor: remove prisma from context and use client directly in service * feat: create trpc router & service for apps * refactor: migrate client app queries/mutations to trpc * refactor: removal and replace usage of old graphql generated types * refactor: move from node --require to custom next server * test: fix tests and bump various dependencies * chore: cleanup system-api from now un-used files * refactor(dashboard): remove code related to apollo * refactor: serve static files through next's server instead of system-api * refactor(server): move auth and system services to class * refactor(client): remove layoutv2 abstraction * fix: return correct update info * chore: remove legacy system-api folder * refactor: remove system-api from docker files * feat: create scheduler to run cron jobs and setup periodic repo update * fix: failing build caused by remark-mdx * refactor: move migrations to server folder * feat: compile server using esbuild * refactor: ts issue mis-used file from client in server * ci: make pipeline pass by cd into dashboard before each step (temp) * chore: drop armv7 support * refactor: move dashboard files in root folder * feat(db): create migration to add operator field on user * feat(user): create routes and services for password reset * feat(auth): add reset password page, container & form * refactor(dashboard): change layout and page of auth to be url based instead of state based * feat(script): add reset-password script * fix(dashboard): only check status if restart or update has been requested * test: increase coverage for get-server-auth-session * fix(start.sh): prompt for network interface only if there is not an internal ip set * feat(script): support user docker-compose.yml and app.env * chore: bump version * fix: add missing postgres variables to start script * fix: check for 32 bits before installing/starting * fix: create default media folder structure on install * Updated demo instance link Changed demo.runtipi.com to https://demo.runtipi.com * feat: adding config for codespaces * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: Freddie Sackur <github@dustyfox.uk> Co-authored-by: Kieran Klukas <92754843+kcoderhtml@users.noreply.github.com> Co-authored-by: alwerner <alexander.werner@bonprix.net> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
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
echo "runtipi is not supported on 32 bits systems"
exit 1
Release/1.0.0 (#316) * fix: create default media folder structure on install * feat: add link to open exposed app to domain * [ImgBot] Optimize images *Total -- 2,048.42kb -> 1,263.43kb (38.32%) /screenshots/darkmode.png -- 998.43kb -> 609.77kb (38.93%) /screenshots/appstore.png -- 1,006.73kb -> 620.12kb (38.4%) /packages/dashboard/public/error.png -- 42.38kb -> 32.70kb (22.84%) /packages/dashboard/public/empty.svg -- 0.87kb -> 0.85kb (2.35%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * chore: bump version 0.8.1 * refactor: move all dashboard's files into a client folder * feat: setup trpc and create system router * test: split jest config for client and server * refactor: replace grapqhl queries with trpc in the frontend * refactor: remove now un-used system queries/mutations/resolvers from both client and server * chore: bump dependencies * feat: setup prisma and configure it for tests and development * feat: create trpc router for auth service * refactor: migrate client auth queries to trpc procedures * refactor: cleanup now un-used graphql resolvers and services * feat: create sql migrations by replicating typeorm ones in an idempotent manner * feat: create server-preload script to run migrations upon server start * chore: remove legacy migrations steps * feat: add redis_host as an env variable * refactor: remove prisma from context and use client directly in service * feat: create trpc router & service for apps * refactor: migrate client app queries/mutations to trpc * refactor: removal and replace usage of old graphql generated types * refactor: move from node --require to custom next server * test: fix tests and bump various dependencies * chore: cleanup system-api from now un-used files * refactor(dashboard): remove code related to apollo * refactor: serve static files through next's server instead of system-api * refactor(server): move auth and system services to class * refactor(client): remove layoutv2 abstraction * fix: return correct update info * chore: remove legacy system-api folder * refactor: remove system-api from docker files * feat: create scheduler to run cron jobs and setup periodic repo update * fix: failing build caused by remark-mdx * refactor: move migrations to server folder * feat: compile server using esbuild * refactor: ts issue mis-used file from client in server * ci: make pipeline pass by cd into dashboard before each step (temp) * chore: drop armv7 support * refactor: move dashboard files in root folder * feat(db): create migration to add operator field on user * feat(user): create routes and services for password reset * feat(auth): add reset password page, container & form * refactor(dashboard): change layout and page of auth to be url based instead of state based * feat(script): add reset-password script * fix(dashboard): only check status if restart or update has been requested * test: increase coverage for get-server-auth-session * fix(start.sh): prompt for network interface only if there is not an internal ip set * feat(script): support user docker-compose.yml and app.env * chore: bump version * fix: add missing postgres variables to start script * fix: check for 32 bits before installing/starting * fix: create default media folder structure on install * Updated demo instance link Changed demo.runtipi.com to https://demo.runtipi.com * feat: adding config for codespaces * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: Freddie Sackur <github@dustyfox.uk> Co-authored-by: Kieran Klukas <92754843+kcoderhtml@users.noreply.github.com> Co-authored-by: alwerner <alexander.werner@bonprix.net> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2023-03-02 19:19:20 +00:00
fi
### --------------------------------
### CLI arguments
### --------------------------------
UPDATE="false"
2023-08-24 06:49:13 +00:00
VERSION="latest"
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
;;
--)
shift # The double dash makes them parameters
break
;;
*) echo "Option $1 not recognized" && exit 1 ;;
esac
shift
done
Release/1.0.0 (#316) * fix: create default media folder structure on install * feat: add link to open exposed app to domain * [ImgBot] Optimize images *Total -- 2,048.42kb -> 1,263.43kb (38.32%) /screenshots/darkmode.png -- 998.43kb -> 609.77kb (38.93%) /screenshots/appstore.png -- 1,006.73kb -> 620.12kb (38.4%) /packages/dashboard/public/error.png -- 42.38kb -> 32.70kb (22.84%) /packages/dashboard/public/empty.svg -- 0.87kb -> 0.85kb (2.35%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * chore: bump version 0.8.1 * refactor: move all dashboard's files into a client folder * feat: setup trpc and create system router * test: split jest config for client and server * refactor: replace grapqhl queries with trpc in the frontend * refactor: remove now un-used system queries/mutations/resolvers from both client and server * chore: bump dependencies * feat: setup prisma and configure it for tests and development * feat: create trpc router for auth service * refactor: migrate client auth queries to trpc procedures * refactor: cleanup now un-used graphql resolvers and services * feat: create sql migrations by replicating typeorm ones in an idempotent manner * feat: create server-preload script to run migrations upon server start * chore: remove legacy migrations steps * feat: add redis_host as an env variable * refactor: remove prisma from context and use client directly in service * feat: create trpc router & service for apps * refactor: migrate client app queries/mutations to trpc * refactor: removal and replace usage of old graphql generated types * refactor: move from node --require to custom next server * test: fix tests and bump various dependencies * chore: cleanup system-api from now un-used files * refactor(dashboard): remove code related to apollo * refactor: serve static files through next's server instead of system-api * refactor(server): move auth and system services to class * refactor(client): remove layoutv2 abstraction * fix: return correct update info * chore: remove legacy system-api folder * refactor: remove system-api from docker files * feat: create scheduler to run cron jobs and setup periodic repo update * fix: failing build caused by remark-mdx * refactor: move migrations to server folder * feat: compile server using esbuild * refactor: ts issue mis-used file from client in server * ci: make pipeline pass by cd into dashboard before each step (temp) * chore: drop armv7 support * refactor: move dashboard files in root folder * feat(db): create migration to add operator field on user * feat(user): create routes and services for password reset * feat(auth): add reset password page, container & form * refactor(dashboard): change layout and page of auth to be url based instead of state based * feat(script): add reset-password script * fix(dashboard): only check status if restart or update has been requested * test: increase coverage for get-server-auth-session * fix(start.sh): prompt for network interface only if there is not an internal ip set * feat(script): support user docker-compose.yml and app.env * chore: bump version * fix: add missing postgres variables to start script * fix: check for 32 bits before installing/starting * fix: create default media folder structure on install * Updated demo instance link Changed demo.runtipi.com to https://demo.runtipi.com * feat: adding config for codespaces * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: Freddie Sackur <github@dustyfox.uk> Co-authored-by: Kieran Klukas <92754843+kcoderhtml@users.noreply.github.com> Co-authored-by: alwerner <alexander.werner@bonprix.net> Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2023-03-02 19:19:20 +00:00
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 '"' || echo 'unknown')"
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}"
echo "Your sudo password might be asked to install docker"
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 -ne 0 ]]; then
echo "Your system ${OS} is not supported trying with sub_os ${SUB_OS}"
install_docker "${SUB_OS}"
docker_sub_result=$?
if [[ docker_sub_result -ne 0 ]]; then
echo "Your system ${SUB_OS} is not supported please install docker manually"
exit 1
fi
fi
# Make sure user is in docker group
if ! groups | grep -q '\bdocker\b'; then
echo "Adding user to docker group"
sudo usermod -aG docker "$USER"
echo "✓ Docker installed. Please re-run the installation script to continue with the installation. (curl -L https://setup.runtipi.io | bash)"
fi
# Reload user groups
newgrp docker
exit 0
fi
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"
2023-08-24 06:49:13 +00:00
# If version was not given it will install the latest version
if [[ "${VERSION}" == "latest" ]]; then
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-24 06:49:13 +00:00
ASSET="runtipi-cli-linux-x64"
if [ "$ARCHITECTURE" == "arm64" ] || [ "$ARCHITECTURE" == "aarch64" ]; then
2023-08-24 06:49:13 +00:00
ASSET="runtipi-cli-linux-arm64"
fi
URL="https://github.com/runtipi/runtipi/releases/download/$VERSION/$ASSET"
if [[ "${UPDATE}" == "false" ]]; then
mkdir -p runtipi
cd runtipi || exit
fi
curl --location "$URL" -o ./runtipi-cli
chmod +x ./runtipi-cli
./runtipi-cli start