From d66ef8fe22ccf095205c0586700728d33d81fbd3 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 30 Apr 2022 18:10:24 +0200 Subject: Add a script to install dependencies --- scripts/install-dependencies.sh | 174 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 scripts/install-dependencies.sh (limited to 'scripts/install-dependencies.sh') diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh new file mode 100644 index 00000000..27e0bf15 --- /dev/null +++ b/scripts/install-dependencies.sh @@ -0,0 +1,174 @@ +#!/bin/sh +# +# Script that installs the various dependencies of invidious +# +# Dependencies: +# - crystal => Language in which Invidious is developed +# - postgres => Database server +# - git => required to clone Invidious +# - librsvg2-bin => For login captcha (provides 'rsvg-convert') +# +# - libssl-dev => Used by Crystal's SSL module (standard library) +# - libxml2-dev => Used by Crystal's XML module (standard library) +# - libyaml-dev => Used by Crystal's YAML module (standard library) +# - libgmp-dev => Used by Crystal's BigNumbers module (standard library) +# - libevent-dev => Used by crystal's internal scheduler (?) +# - libpcre3-dev => Used by Crystal's regex engine (?) +# +# - libsqlite3-dev => Used to open .db files from NewPipe exports +# - zlib1g-dev => TBD +# - libreadline-dev => TBD +# +# +# Tested on: +# - OpenSUSE Leap 15.3 + +# +# Load system details +# + +if [ -e /etc/os-release ]; then + . /etc/os-release +elif [ -e /usr/lib/os-release ]; then + . /usr/lib/os-release +else + echo "Unsupported Linux system" + exit 2 +fi + +# +# Some variables +# + +repo_base_url="https://download.opensuse.org/repositories/devel:/languages:/crystal/" +repo_end_url="devel:languages:crystal.repo" + +apt_gpg_key="/usr/share/keyrings/crystal.gpg" +apt_list_file="/etc/apt/sources.list.d/crystal.list" + +yum_repo_file="/etc/yum.repos.d/crystal.repo" + +# +# Major install functions +# + +make_repo_url() { + echo "${repo_base_url}/${1}/${repo_end_url}" +} + + +install_apt() { + repo="$1" + + echo "Adding Crystal repository" + + curl -fsSL "${repo_base_url}/${repo}/Release.key" \ + | gpg --dearmor \ + | sudo tee "${apt_gpg_key}" > /dev/null + + echo "deb [signed-by=${apt_gpg_key}] ${repo_base_url}/${repo}/ /" \ + | sudo tee "$apt_list_file" + + sudo apt-get update + + sudo apt-get install --yes --no-install-recommends \ + libssl-dev libxml2-dev libyaml-dev libgmp-dev libevent-dev \ + libpcre3-dev libreadline-dev libsqlite3-dev zlib1g-dev \ + crystal postgres git librsvg2-bin make +} + +install_yum() { + repo=$(make_repo_url "$1") + + echo "Adding Crystal repository" + + cat << END | sudo tee "${yum_repo_file}" > /dev/null +[crystal] +name=Crystal +type=rpm-md +baseurl=${repo}/ +gpgcheck=1 +gpgkey=${repo}/repodata/repomd.xml.key +enabled=1 +END + + sudo yum -y install \ + openssl-devel libxml2-devel libyaml-devel gmp-devel \ + readline-devel sqlite-devel \ + crystal postgresql postgresql-server git librsvg2-tools make +} + +install_pacman() { + # TODO: find an alternative to --no-confirm? + sudo pacman -S --no-confirm \ + base-devel librsvg postgresql crystal +} + +install_zypper() +{ + repo=$(make_repo_url "$1") + + echo "Adding Crystal repository" + sudo zypper --non-interactive addrepo -f "$repo" + + sudo zypper --non-interactive --gpg-auto-import-keys install --no-recommends \ + libopenssl-devel libxml2-devel libyaml-devel gmp-devel libevent-devel \ + pcre-devel readline-devel sqlite3-devel zlib-devel \ + crystal postgresql postgresql-server git rsvg-convert make +} + + +# +# System-specific logic +# + +case "$ID" in + archlinux) install_pacman;; + + centos) install_dnf "CentOS_${VERSION_ID}";; + + debian) + case "$VERSION_CODENAME" in + sid) install_apt "Debian_Unstable";; + bookworm) install_apt "Debian_Testing";; + *) install_apt "Debian_${VERSION_ID}";; + esac + ;; + + fedora) + if [ "$VERSION" == *"Prerelease"* ]; then + install_dnf "Fedora_Rawhide" + else + install_dnf "Fedora_${VERSION}" + fi + ;; + + opensuse-leap) install_zypper "openSUSE_Leap_${VERSION}";; + + opensuse-tumbleweed) install_zypper "openSUSE_Tumbleweed";; + + rhel) install_dnf "RHEL_${VERSION_ID}";; + + ubuntu) + # Small workaround for recently released 22.04 + case "$VERSION_ID" in + 22.04) install_apt "xUbuntu_21.04";; + *) install_apt "xUbuntu_${VERSION_ID}";; + esac + ;; + + *) + # Try to match on ID_LIKE instead + # Not guaranteed to 100% work + case "$ID_LIKE" in + archlinux) install_pacman;; + centos) install_dnf "CentOS_${VERSION_ID}";; + debian) install_apt "Debian_${VERSION_ID}";; + *) + echo "Error: distribution ${CODENAME} is not supported" + echo "Please install dependencies manually" + exit 2 + ;; + esac + ;; +esac -- cgit v1.2.3 From 8332ad0f1684cd5af68daeb4f7bc5cb04ff03669 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 20 Jun 2022 23:19:05 +0200 Subject: Fix syntax errors in shell scripts --- scripts/deploy-database.sh | 4 ++-- scripts/install-dependencies.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/install-dependencies.sh') diff --git a/scripts/deploy-database.sh b/scripts/deploy-database.sh index ed9464e6..fa24b8f0 100644 --- a/scripts/deploy-database.sh +++ b/scripts/deploy-database.sh @@ -6,7 +6,7 @@ interactive=true -if [ "$1" == "--no-interactive" ]; then +if [ "$1" = "--no-interactive" ]; then interactive=false fi @@ -21,7 +21,7 @@ sudo systemctl enable postgresql.service # Create databse and user # -if [ "$interactive" == "true" ]; then +if [ "$interactive" = "true" ]; then sudo -u postgres -- createuser -P kemal sudo -u postgres -- createdb -O kemal invidious else diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index 27e0bf15..1e67bdaf 100644 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -74,7 +74,7 @@ install_apt() { sudo apt-get install --yes --no-install-recommends \ libssl-dev libxml2-dev libyaml-dev libgmp-dev libevent-dev \ libpcre3-dev libreadline-dev libsqlite3-dev zlib1g-dev \ - crystal postgres git librsvg2-bin make + crystal postgresql-13 git librsvg2-bin make } install_yum() { -- cgit v1.2.3 From 04b97ec261091c8f4f0816335a4b198ffc5efb9e Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 14 Jan 2023 19:56:15 +0100 Subject: make shell scripts executable (chmod 755) --- scripts/deploy-database.sh | 0 scripts/fetch-player-dependencies.cr | 0 scripts/install-dependencies.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/deploy-database.sh mode change 100644 => 100755 scripts/fetch-player-dependencies.cr mode change 100644 => 100755 scripts/install-dependencies.sh (limited to 'scripts/install-dependencies.sh') diff --git a/scripts/deploy-database.sh b/scripts/deploy-database.sh old mode 100644 new mode 100755 diff --git a/scripts/fetch-player-dependencies.cr b/scripts/fetch-player-dependencies.cr old mode 100644 new mode 100755 diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh old mode 100644 new mode 100755 -- cgit v1.2.3