@@ -19,6 +19,12 @@ install_ubuntu() {
19
19
apt-get install -y $@
20
20
}
21
21
22
+ # Function to get PostgreSQL version on Ubuntu
23
+ get_postgres_version_ubuntu () {
24
+ local pg_version=$( ls /usr/share/postgresql/ | grep -E ' ^[0-9]+$' | sort -rn | head -n1)
25
+ echo " $pg_version "
26
+ }
27
+
22
28
# Install packages based on the detected OS
23
29
if [[ " $OS " == * " Alpine" * ]]; then
24
30
echo " Detected Alpine Linux"
@@ -40,17 +46,24 @@ cd postgres-json-schema
40
46
# Build the extension
41
47
make && make install
42
48
43
-
44
49
if [[ " $OS " == * " Alpine" * ]]; then
45
50
# Create the extension directory if it doesn't exist
46
51
mkdir -p ' /usr/local/share/postgresql/extension'
47
52
# Set appropriate permissions for the control file
48
53
chmod 644 /usr/local/share/postgresql/extension/postgres-json-schema.control
49
54
elif [[ " $OS " == * " Ubuntu" * ]]; then
55
+ # Get PostgreSQL version
56
+ PG_VERSION=$( get_postgres_version_ubuntu)
57
+
58
+ if [ -z " $PG_VERSION " ]; then
59
+ echo " Could not determine PostgreSQL version"
60
+ exit 1
61
+ fi
62
+
50
63
# Create the extension directory if it doesn't exist
51
- mkdir -p ' /usr/share/postgresql/extension'
64
+ mkdir -p " /usr/share/postgresql/$PG_VERSION / extension"
52
65
# Set appropriate permissions for the control file
53
- chmod 644 /usr/share/postgresql/extension/postgres-json-schema.control
66
+ chmod 644 " /usr/share/postgresql/$PG_VERSION / extension/postgres-json-schema.control"
54
67
else
55
68
echo " Unsupported operating system: $OS "
56
69
exit 1
0 commit comments