1 Commits

Author SHA1 Message Date
94e6f55e4d feat: create user and db
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-02-22 15:11:58 +01:00
3 changed files with 11 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ jobs:
env:
GIT_REFERENCE: ${{ github.ref }}
- name: Build rpm package
run: rpmbuild -ba netoik-db.spec
run: rpmbuild -ba "%(make name).spec"
- name: Upload rpm package
run: make upload
env:

View File

@@ -17,4 +17,4 @@ jobs:
- name: Build tarball
run: make tarball
- name: Build rpm file
run: rpmbuild -ba netoik-db.spec
run: rpmbuild -ba "$(make name).spec"

View File

@@ -22,6 +22,15 @@ Install the database management system called postgresql with a predefined confi
%make_install
%post
# Create databases and users from DB_USERS variable (separator is ",") if not existing
echo "$DB_USERS" | IFS="," read -ra users
for user in "${users[@]}"; do
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --invert-match postgres | grep --quiet "$user"; then
runuser --user=postgres -- createuser "$user"
runuser --user=postgres -- createdb --owner="$user" "$user"
fi
done
# Restart services
systemctl daemon-reload
systemctl reenable --now postgresql.service