From fe53b5503cc175ad7cef74d9ad1d8096031c44ac Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 30 Apr 2022 18:11:12 +0200 Subject: Add a script to start postgres and create user/DB --- scripts/deploy-database.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/deploy-database.sh (limited to 'scripts/deploy-database.sh') diff --git a/scripts/deploy-database.sh b/scripts/deploy-database.sh new file mode 100644 index 00000000..9f0bffcb --- /dev/null +++ b/scripts/deploy-database.sh @@ -0,0 +1,41 @@ +#!/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 -- cgit v1.2.3 From 1f359f5a13f3bfd9dddbac47d8e6dbc2ab1c6f49 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 21 May 2022 19:18:01 +0200 Subject: Print some helpful notice for PostgreSQL configuration --- scripts/deploy-database.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'scripts/deploy-database.sh') diff --git a/scripts/deploy-database.sh b/scripts/deploy-database.sh index 9f0bffcb..ed9464e6 100644 --- a/scripts/deploy-database.sh +++ b/scripts/deploy-database.sh @@ -39,3 +39,22 @@ else 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 -- 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/deploy-database.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/deploy-database.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