Skip to content

Commit a4c6d0e

Browse files
authored
Update install_postgres_json_schema_extension.sh
1 parent cf4dbeb commit a4c6d0e

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed
+36-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,47 @@
11
#!/bin/bash
2-
apk add --update make
3-
apk add --update git
2+
3+
# Detect the operating system
4+
if [ -f /etc/os-release ]; then
5+
. /etc/os-release
6+
OS=$NAME
7+
else
8+
OS=$(uname -s)
9+
fi
10+
11+
# Function to install packages on Alpine
12+
install_alpine() {
13+
apk add --update $@
14+
}
15+
16+
# Function to install packages on Ubuntu
17+
install_ubuntu() {
18+
apt-get update
19+
apt-get install -y $@
20+
}
21+
22+
# Install packages based on the detected OS
23+
if [[ "$OS" == *"Alpine"* ]]; then
24+
echo "Detected Alpine Linux"
25+
install_alpine make git libpq-dev postgresql-client
26+
elif [[ "$OS" == *"Ubuntu"* ]]; then
27+
echo "Detected Ubuntu"
28+
install_ubuntu make git libpq-dev postgresql-client
29+
else
30+
echo "Unsupported operating system: $OS"
31+
exit 1
32+
fi
433

534
# Clone the repository
635
git clone https://github.com/gavinwahl/postgres-json-schema/
736

8-
apk add libpq-dev
937
# Move into the directory
1038
cd postgres-json-schema
1139

1240
# Build the extension
13-
make & make install
14-
15-
16-
apk add postgresql-client
41+
make && make install
1742

18-
/bin/mkdir -p '/usr/local/share/postgresql/extension'
43+
# Create the extension directory if it doesn't exist
44+
mkdir -p '/usr/local/share/postgresql/extension'
1945

20-
chmod 666 /usr/local/share/postgresql/extension/postgres-json-schema.control
46+
# Set appropriate permissions for the control file
47+
chmod 644 /usr/local/share/postgresql/extension/postgres-json-schema.control

0 commit comments

Comments
 (0)