From c5001f3620d6a9d4d24ce63afdf892a690b16440 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 6 Apr 2019 07:38:33 -0500 Subject: [PATCH] Add role to psql scripts --- README.md | 6 +++--- config/migrate-scripts/migrate-db-17cf077.sh | 4 ++-- config/migrate-scripts/migrate-db-1c8075c.sh | 8 ++++---- config/migrate-scripts/migrate-db-30e6d29.sh | 4 ++-- config/migrate-scripts/migrate-db-3646395.sh | 4 ++-- config/migrate-scripts/migrate-db-6e51189.sh | 4 ++-- config/migrate-scripts/migrate-db-88b7097.sh | 2 +- config/migrate-scripts/migrate-db-8e884fe.sh | 6 +++--- docker/entrypoint.postgres.sh | 12 ++++++------ 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d8aaef47..0d02fe32 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ $ exit $ sudo systemctl enable postgresql $ sudo systemctl start postgresql $ sudo -i -u postgres -$ psql -c "CREATE USER kemal WITH PASSWORD 'kemal';" +$ psql -c "CREATE USER kemal WITH PASSWORD 'kemal';" # Change 'kemal' here to a stronger password, and update `password` in config/config.yml $ createdb -O kemal invidious $ psql invidious < /home/invidious/invidious/config/sql/channels.sql $ psql invidious < /home/invidious/invidious/config/sql/videos.sql @@ -143,8 +143,8 @@ $ brew install shards crystal-lang postgres imagemagick librsvg $ git clone https://github.com/omarroth/invidious $ cd invidious $ brew services start postgresql -$ psql -c "CREATE ROLE kemal WITH LOGIN PASSWORD 'kemal';" -$ createdb invidious -U kemal +$ psql -c "CREATE ROLE kemal WITH PASSWORD 'kemal';" # Change 'kemal' here to a stronger password, and update `password` in config/config.yml +$ createdb -O kemal invidious $ psql invidious < config/sql/channels.sql $ psql invidious < config/sql/videos.sql $ psql invidious < config/sql/channel_videos.sql diff --git a/config/migrate-scripts/migrate-db-17cf077.sh b/config/migrate-scripts/migrate-db-17cf077.sh index a544f763..5e5bb214 100755 --- a/config/migrate-scripts/migrate-db-17cf077.sh +++ b/config/migrate-scripts/migrate-db-17cf077.sh @@ -1,4 +1,4 @@ #!/bin/sh -psql invidious -c "ALTER TABLE channels ADD COLUMN subscribed bool;" -psql invidious -c "UPDATE channels SET subscribed = false;" +psql invidious kemal -c "ALTER TABLE channels ADD COLUMN subscribed bool;" +psql invidious kemal -c "UPDATE channels SET subscribed = false;" diff --git a/config/migrate-scripts/migrate-db-1c8075c.sh b/config/migrate-scripts/migrate-db-1c8075c.sh index 92ad1c7b..63954397 100755 --- a/config/migrate-scripts/migrate-db-1c8075c.sh +++ b/config/migrate-scripts/migrate-db-1c8075c.sh @@ -1,7 +1,7 @@ #!/bin/sh -psql invidious -c "ALTER TABLE channel_videos DROP COLUMN live_now CASCADE" -psql invidious -c "ALTER TABLE channel_videos DROP COLUMN premiere_timestamp CASCADE" +psql invidious kemal -c "ALTER TABLE channel_videos DROP COLUMN live_now CASCADE" +psql invidious kemal -c "ALTER TABLE channel_videos DROP COLUMN premiere_timestamp CASCADE" -psql invidious -c "ALTER TABLE channel_videos ADD COLUMN live_now bool" -psql invidious -c "ALTER TABLE channel_videos ADD COLUMN premiere_timestamp timestamptz" +psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN live_now bool" +psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN premiere_timestamp timestamptz" diff --git a/config/migrate-scripts/migrate-db-30e6d29.sh b/config/migrate-scripts/migrate-db-30e6d29.sh index 259862df..3a377461 100755 --- a/config/migrate-scripts/migrate-db-30e6d29.sh +++ b/config/migrate-scripts/migrate-db-30e6d29.sh @@ -1,4 +1,4 @@ #!/bin/sh -psql invidious -c "ALTER TABLE channels ADD COLUMN deleted bool;" -psql invidious -c "UPDATE channels SET deleted = false;" +psql invidious kemal -c "ALTER TABLE channels ADD COLUMN deleted bool;" +psql invidious kemal -c "UPDATE channels SET deleted = false;" diff --git a/config/migrate-scripts/migrate-db-3646395.sh b/config/migrate-scripts/migrate-db-3646395.sh index 38a4f665..915f364e 100755 --- a/config/migrate-scripts/migrate-db-3646395.sh +++ b/config/migrate-scripts/migrate-db-3646395.sh @@ -1,5 +1,5 @@ #!/bin/sh psql invidious < config/sql/session_ids.sql -psql invidious -c "INSERT INTO session_ids (SELECT unnest(id), email, CURRENT_TIMESTAMP FROM users) ON CONFLICT (id) DO NOTHING" -psql invidious -c "ALTER TABLE users DROP COLUMN id" +psql invidious kemal -c "INSERT INTO session_ids (SELECT unnest(id), email, CURRENT_TIMESTAMP FROM users) ON CONFLICT (id) DO NOTHING" +psql invidious kemal -c "ALTER TABLE users DROP COLUMN id" diff --git a/config/migrate-scripts/migrate-db-6e51189.sh b/config/migrate-scripts/migrate-db-6e51189.sh index adadc109..ce728118 100755 --- a/config/migrate-scripts/migrate-db-6e51189.sh +++ b/config/migrate-scripts/migrate-db-6e51189.sh @@ -1,4 +1,4 @@ #!/bin/sh -psql invidious -c "ALTER TABLE channel_videos ADD COLUMN live_now bool;" -psql invidious -c "UPDATE channel_videos SET live_now = false;" +psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN live_now bool;" +psql invidious kemal -c "UPDATE channel_videos SET live_now = false;" diff --git a/config/migrate-scripts/migrate-db-88b7097.sh b/config/migrate-scripts/migrate-db-88b7097.sh index c63d37f0..6bde8399 100755 --- a/config/migrate-scripts/migrate-db-88b7097.sh +++ b/config/migrate-scripts/migrate-db-88b7097.sh @@ -1,3 +1,3 @@ #!/bin/sh -psql invidious -c "ALTER TABLE channel_videos ADD COLUMN premiere_timestamp timestamptz;" +psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN premiere_timestamp timestamptz;" diff --git a/config/migrate-scripts/migrate-db-8e884fe.sh b/config/migrate-scripts/migrate-db-8e884fe.sh index 095c7632..1c8dafd1 100755 --- a/config/migrate-scripts/migrate-db-8e884fe.sh +++ b/config/migrate-scripts/migrate-db-8e884fe.sh @@ -1,5 +1,5 @@ #!/bin/sh -psql invidious -c "ALTER TABLE channels DROP COLUMN subscribed" -psql invidious -c "ALTER TABLE channels ADD COLUMN subscribed timestamptz" -psql invidious -c "UPDATE channels SET subscribed = '2019-01-01 00:00:00+00'" +psql invidious kemal -c "ALTER TABLE channels DROP COLUMN subscribed" +psql invidious kemal -c "ALTER TABLE channels ADD COLUMN subscribed timestamptz" +psql invidious kemal -c "UPDATE channels SET subscribed = '2019-01-01 00:00:00+00'" diff --git a/docker/entrypoint.postgres.sh b/docker/entrypoint.postgres.sh index 8f987201..64bcfe48 100755 --- a/docker/entrypoint.postgres.sh +++ b/docker/entrypoint.postgres.sh @@ -12,12 +12,12 @@ if [ ! -f /var/lib/postgresql/data/setupFinished ]; then >&2 echo "### importing table schemas" su postgres -c 'createdb invidious' su postgres -c 'psql -c "CREATE USER kemal WITH PASSWORD '"'kemal'"'"' - su postgres -c 'psql invidious < config/sql/channels.sql' - su postgres -c 'psql invidious < config/sql/videos.sql' - su postgres -c 'psql invidious < config/sql/channel_videos.sql' - su postgres -c 'psql invidious < config/sql/users.sql' - su postgres -c 'psql invidious < config/sql/session_ids.sql' - su postgres -c 'psql invidious < config/sql/nonces.sql' + su postgres -c 'psql invidious kemal < config/sql/channels.sql' + su postgres -c 'psql invidious kemal < config/sql/videos.sql' + su postgres -c 'psql invidious kemal < config/sql/channel_videos.sql' + su postgres -c 'psql invidious kemal < config/sql/users.sql' + su postgres -c 'psql invidious kemal < config/sql/session_ids.sql' + su postgres -c 'psql invidious kemal < config/sql/nonces.sql' touch /var/lib/postgresql/data/setupFinished echo "### invidious database setup finished" exit