diff --git a/charts/postgres/Chart.yaml b/charts/postgres/Chart.yaml
index 1853f4905853498c01123ee8e955c212774c9706..4cfe061e7045f8d9268f436eb4fecbe02eeb33cc 100644
--- a/charts/postgres/Chart.yaml
+++ b/charts/postgres/Chart.yaml
@@ -7,6 +7,6 @@ type: application
 maintainers:
   - name: groundhog2k
 
-version: 0.3.11
+version: 0.4.0
 
 appVersion: "14.5"
diff --git a/charts/postgres/README.md b/charts/postgres/README.md
index 674f668a730272f234122e1a24bcce83a10196dd..c8f4e2a7ab90b63d8729dbe67e835251338c516f 100644
--- a/charts/postgres/README.md
+++ b/charts/postgres/README.md
@@ -1,6 +1,6 @@
 # PostgreSQL
 
-![Version: 0.3.11](https://img.shields.io/badge/Version-0.3.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 14.5](https://img.shields.io/badge/AppVersion-14.5-informational?style=flat-square)
+![Version: 0.4.0](https://img.shields.io/badge/Version-0.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 14.5](https://img.shields.io/badge/AppVersion-14.5-informational?style=flat-square)
 
 ## Changelog
 
@@ -121,6 +121,7 @@ helm uninstall my-release
 | customConfig | string | `nil` | Optional custom configuration block that will be mounted as file in `/etc/postgresql/postgresql.conf` |
 | extraEnvSecrets | list | `[]` | A list of existing secrets that will be mounted into the container as environment variables |
 | extraSecretConfigs | string | `nil` | An existing secret with files that will be added to the postgres configuration in addition to `/etc/postgresql/postgresql.conf` |
+| customScripts | object | `nil` | Optional custom scripts that can be defined inline and will be mounted as files in `/docker-entrypoint-initdb.d` |
 | extraScripts | string | `nil` | An existing configMap with files that will be mounted into the container as script files (`*.sql`, `*.sh`) in `/docker-entrypoint-initdb.d` |
 | extraSecrets | list | `[]` | A list of additional existing secrets that will be mounted into the container |
 | extraSecrets[].name | string | `nil` | Name of the existing K8s secret |
diff --git a/charts/postgres/RELEASENOTES.md b/charts/postgres/RELEASENOTES.md
index ab182fc2d760467d3dbf9d5fe658a36214dc8d7e..4c71a430b832b826623026fc744ce92c68a1f083 100644
--- a/charts/postgres/RELEASENOTES.md
+++ b/charts/postgres/RELEASENOTES.md
@@ -16,4 +16,5 @@
 | 0.3.9 | 14.3 | Upgraded to Postgres 14.3 |
 | 0.3.10 | 14.4 | Upgraded to Postgres 14.4 |
 | 0.3.11 | 14.5 | Upgraded to Postgres 14.5 |
+| 0.4.0 | 14.5 | Implemented support for custom inline init scripts |
 | | | |
diff --git a/charts/postgres/templates/customscripts.yaml b/charts/postgres/templates/customscripts.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..ef1cfa1edc82ea60bdc4949defe35bf470aca94b
--- /dev/null
+++ b/charts/postgres/templates/customscripts.yaml
@@ -0,0 +1,13 @@
+{{- if .Values.customScripts }}
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "postgres.fullname" . }}-customscripts
+  labels:
+    {{- include "postgres.labels" . | nindent 4 }}
+data:
+  {{- range $name, $value := .Values.customScripts }}
+  {{- $name | nindent 2 }}: |
+    {{- $value | nindent 4 }}
+  {{- end }}
+{{- end }}
diff --git a/charts/postgres/templates/scripts.yaml b/charts/postgres/templates/scripts.yaml
index f266349f7b23ebc7896409bcdeef0c5a01cd6e02..8b95b790d1844f5960c53d5ec1d78b4aefb03347 100644
--- a/charts/postgres/templates/scripts.yaml
+++ b/charts/postgres/templates/scripts.yaml
@@ -27,6 +27,10 @@ data:
       echo "Copy extra scripts"
       cp /extrascripts/* /scripts
     fi
+    if [ -d /customscripts ]; then
+      echo "Copy custom scripts"
+      cp /customscripts/* /scripts
+    fi
     if [ -d /customconfig ]; then
       echo "Create postgres config"
       cat /customconfig/* >>/configs/postgresql.conf
diff --git a/charts/postgres/templates/statefulset.yaml b/charts/postgres/templates/statefulset.yaml
index 690f68e0c198348288ae4db0bb09b91d533d6388..44762f627e831f8ae4e744a0edcdffa1a7220b56 100644
--- a/charts/postgres/templates/statefulset.yaml
+++ b/charts/postgres/templates/statefulset.yaml
@@ -21,6 +21,7 @@ spec:
       annotations:
         checksum/customconfig: {{ include (print $.Template.BasePath "/customconfig.yaml") . | sha256sum }}
         checksum/secureconfig: {{ include (print $.Template.BasePath "/secureconfig.yaml") . | sha256sum }}
+        checksum/customscripts: {{ include (print $.Template.BasePath "/customscripts.yaml") . | sha256sum }}
         checksum/scripts: {{ include (print $.Template.BasePath "/scripts.yaml") . | sha256sum }}
       {{- with .Values.podAnnotations }}
         {{- toYaml . | nindent 8 }}
@@ -50,6 +51,10 @@ spec:
             - mountPath: /extrascripts
               name: extrascripts-volume
             {{- end }}
+            {{- if .Values.customScripts }}
+            - mountPath: /customscripts
+              name: customscripts-volume
+            {{- end }}
             {{- if .Values.extraSecretConfigs }}
             - mountPath: /extraconfigs
               name: extraconfigs-volume
@@ -222,6 +227,12 @@ spec:
             name: {{ .Values.extraScripts }}
             defaultMode: 0555
         {{- end }}
+        {{- if .Values.customScripts }}
+        - name: customscripts-volume
+          configMap:
+            name: {{ include "postgres.fullname" . }}-customscripts
+            defaultMode: 0555
+        {{- end }}
         {{- if .Values.extraSecretConfigs }}
         - name: extraconfigs-volume
           secret:
diff --git a/charts/postgres/values.yaml b/charts/postgres/values.yaml
index 26fd988729d4d65cff8f4ed1376d37cc00d991be..b80c8f62a625171b2e42fbacb42d167c1b5182f8 100644
--- a/charts/postgres/values.yaml
+++ b/charts/postgres/values.yaml
@@ -154,6 +154,13 @@ userDatabase: {}
 ## For more flexible options see extraSecretConfigs: section
 customConfig: |
 
+## Optional custom scripts that can be defined inline and will be mounted as files in /docker-entrypoint-initdb.d
+customScripts: {}
+#  01-a-script.sh: |
+#    echo "hello"
+#  02-another-script.sh: |
+#    echo "hello 2"
+
 ## A list of existing secrets that will be mounted into the container as environment variables
 ## As an alternative these secrets can set the database superuser password or other options when settings.superuserPassword was not specified
 ## For example: Setting POSTGRES_DB, USERDB_USER, USERDB_PASSWORD will allow creating a user database and grant access for the given user