diff --git a/.env.example b/.env.example index cf59f77e..0bb338e4 100644 --- a/.env.example +++ b/.env.example @@ -38,3 +38,5 @@ AIRBRAKE_API_KEY= GITLAB_URI=https://0xacab.org GITLAB_PROJECT= GITLAB_TOKEN= +PGVER=15 +PGPID=/run/postgresql.pid diff --git a/Taskfile.yaml b/Taskfile.yaml index ca2a1ad1..3bb0bdc4 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -76,3 +76,24 @@ tasks: - "echo -e \"::1 panel.{{.SUTTY}} api.{{.SUTTY}} postgresql.{{.SUTTY}}\" | sudo tee -a /etc/hosts" status: - "grep -q \" panel.{{.SUTTY}} \" /etc/hosts" + database-init: + desc: "Database install" + deps: + - "env" + cmds: + - "{{.HAINISH}} /usr/bin/initdb --locale en_US.utf8 -E UTF8 -D /var/lib/postgresql/{{.PGVER}}/data" + - "echo \"host all all samenet trust\" >> ../hain/var/lib/postgresql/{{.PGVER}}/data/pg_hba.conf" + - "echo \"listen_addresses = '*'\" >> ../hain/var/lib/postgresql/{{.PGVER}}/data/postgresql.conf" + - "echo \"external_pid_file = '{{.PGPID}}'\" >> ../hain/var/lib/postgresql/{{.PGVER}}/data/postgresql.conf" + status: + - "test -d ../hain/var/lib/postgresql/{{.PGVER}}/data" + - "test -f ../hain/var/lib/postgresql/{{.PGVER}}/data/postgresql.conf" + database: + desc: "Database" + deps: + - "database-init" + cmds: + - "{{.HAINISH}} daemonize -c /var/lib/postgresql/{{.PGVER}}/data /usr/bin/postgres -D /var/lib/postgresql/{{.PGVER}}/data" + status: + - "test -f ../hain{{.PGPID}}" + - "pgrep -F ../hain{{.PGPID}}"