mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-22 13:37:24 +00:00
Merge pull request #3103 from SamantazFox/add-utility-scripts
Add utility scripts
This commit is contained in:
commit
dbc7c97e0b
60
scripts/deploy-database.sh
Normal file
60
scripts/deploy-database.sh
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Parameters
|
||||
#
|
||||
|
||||
interactive=true
|
||||
|
||||
if [ "$1" == "--no-interactive" ]; then
|
||||
interactive=false
|
||||
fi
|
||||
|
||||
#
|
||||
# Enable and start Postgres
|
||||
#
|
||||
|
||||
sudo systemctl start postgresql.service
|
||||
sudo systemctl enable postgresql.service
|
||||
|
||||
#
|
||||
# Create databse and user
|
||||
#
|
||||
|
||||
if [ "$interactive" == "true" ]; then
|
||||
sudo -u postgres -- createuser -P kemal
|
||||
sudo -u postgres -- createdb -O kemal invidious
|
||||
else
|
||||
# Generate a DB password
|
||||
if [ -z "$POSTGRES_PASS" ]; then
|
||||
echo "Generating database password"
|
||||
POSTGRES_PASS=$(tr -dc 'A-Za-z0-9.;!?{[()]}\\/' < /dev/urandom | head -c16)
|
||||
fi
|
||||
|
||||
# hostname:port:database:username:password
|
||||
echo "Writing .pgpass"
|
||||
echo "127.0.0.1:*:invidious:kemal:${POSTGRES_PASS}" > "$HOME/.pgpass"
|
||||
|
||||
sudo -u postgres -- psql -c "CREATE USER kemal WITH PASSWORD '$POSTGRES_PASS';"
|
||||
sudo -u postgres -- psql -c "CREATE DATABASE invidious WITH OWNER kemal;"
|
||||
sudo -u postgres -- psql -c "GRANT ALL ON DATABASE invidious TO kemal;"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Instructions for modification of pg_hba.conf
|
||||
#
|
||||
|
||||
if [ "$interactive" = "true" ]; then
|
||||
echo
|
||||
echo "-------------"
|
||||
echo " NOTICE "
|
||||
echo "-------------"
|
||||
echo
|
||||
echo "Make sure that your postgreSQL's pg_hba.conf file contains the follwong"
|
||||
echo "lines before previous 'host' configurations:"
|
||||
echo
|
||||
echo "host invidious kemal 127.0.0.1/32 md5"
|
||||
echo "host invidious kemal ::1/128 md5"
|
||||
echo
|
||||
fi
|
174
scripts/install-dependencies.sh
Normal file
174
scripts/install-dependencies.sh
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user