File tree Expand file tree Collapse file tree 4 files changed +44
-0
lines changed
bitnami/postgresql-repmgr
17/debian-12/rootfs/opt/bitnami/scripts Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -747,6 +747,46 @@ postgresql_initialize() {
747
747
postgresql_stop
748
748
}
749
749
750
+ # #######################
751
+ # Run custom start scripts
752
+ # Globals:
753
+ # POSTGRESQL_*
754
+ # Arguments:
755
+ # None
756
+ # Returns:
757
+ # None
758
+ # ########################
759
+ postgresql_custom_start_scripts () {
760
+ info " Loading custom start scripts..."
761
+ if [[ -d " $POSTGRESQL_STARTSCRIPTS_DIR " ]] && [[ -n $( find " $POSTGRESQL_STARTSCRIPTS_DIR /" -type f -regex " .*\.\(sh\|sql\|sql.gz\)" ) ]] ; then
762
+ info " Loading user's custom files from $POSTGRESQL_STARTSCRIPTS_DIR ..."
763
+ postgresql_start_bg " false"
764
+ find " $POSTGRESQL_STARTSCRIPTS_DIR /" -type f -regex " .*\.\(sh\|sql\|sql.gz\)" | sort | while read -r f; do
765
+ case " $f " in
766
+ * .sh)
767
+ if [[ -x " $f " ]]; then
768
+ debug " Executing $f "
769
+ " $f "
770
+ else
771
+ debug " Sourcing $f "
772
+ . " $f "
773
+ fi
774
+ ;;
775
+ * .sql)
776
+ debug " Executing $f "
777
+ postgresql_execute " $POSTGRESQL_DATABASE " " $POSTGRESQL_INITSCRIPTS_USERNAME " " $POSTGRESQL_INITSCRIPTS_PASSWORD " < " $f "
778
+ ;;
779
+ * .sql.gz)
780
+ debug " Executing $f "
781
+ gunzip -c " $f " | postgresql_execute " $POSTGRESQL_DATABASE " " $POSTGRESQL_INITSCRIPTS_USERNAME " " $POSTGRESQL_INITSCRIPTS_PASSWORD "
782
+ ;;
783
+ * ) debug " Ignoring $f " ;;
784
+ esac
785
+ done
786
+ touch " $POSTGRESQL_VOLUME_DIR " /.user_scripts_initialized
787
+ fi
788
+ }
789
+
750
790
# #######################
751
791
# Run custom pre-initialization scripts
752
792
# Globals:
Original file line number Diff line number Diff line change @@ -895,6 +895,8 @@ repmgr_initialize() {
895
895
else
896
896
debug " Skipping repmgr configuration..."
897
897
fi
898
+ # Allow running custom start scripts - always run after initialization
899
+ postgresql_custom_start_scripts
898
900
elif [[ " $REPMGR_ROLE " = " standby" ]]; then
899
901
local -r psql_major_version=" $( postgresql_get_major_version) "
900
902
Original file line number Diff line number Diff line change @@ -242,6 +242,7 @@ export POSTGRESQL_TMP_DIR="$POSTGRESQL_BASE_DIR/tmp"
242
242
export POSTGRESQL_PID_FILE=" $POSTGRESQL_TMP_DIR /postgresql.pid"
243
243
export POSTGRESQL_BIN_DIR=" $POSTGRESQL_BASE_DIR /bin"
244
244
export POSTGRESQL_INITSCRIPTS_DIR=" /docker-entrypoint-initdb.d"
245
+ export POSTGRESQL_STARTSCRIPTS_DIR=" /docker-entrypoint-startdb.d"
245
246
export POSTGRESQL_PREINITSCRIPTS_DIR=" /docker-entrypoint-preinitdb.d"
246
247
export PATH=" ${POSTGRESQL_BIN_DIR} :${BITNAMI_ROOT_DIR} /common/bin:${PATH} "
247
248
Original file line number Diff line number Diff line change @@ -685,6 +685,7 @@ Refer to [issues/27124](https://github.com/bitnami/containers/issues/27124) for
685
685
| `POSTGRESQL_PID_FILE` | PostgreSQL PID file | `$POSTGRESQL_TMP_DIR/postgresql.pid` |
686
686
| `POSTGRESQL_BIN_DIR` | PostgreSQL executables directory | `$POSTGRESQL_BASE_DIR/bin` |
687
687
| `POSTGRESQL_INITSCRIPTS_DIR` | Init scripts directory | `/docker-entrypoint-initdb.d` |
688
+ | `POSTGRESQL_STARTSCRIPTS_DIR` | Start scripts directory | `/docker-entrypoint-startdb.d` |
688
689
| `POSTGRESQL_PREINITSCRIPTS_DIR` | Pre-init scripts directory | `/docker-entrypoint-preinitdb.d` |
689
690
| `POSTGRESQL_DAEMON_USER` | PostgreSQL system user | `postgres` |
690
691
| `POSTGRESQL_DAEMON_GROUP` | PostgreSQL system group | `postgres` |
You can’t perform that action at this time.
0 commit comments