Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 219e126

Browse files
committed
Move postgresql from wsl to feature
1 parent 47640bd commit 219e126

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

bin/wsl-init

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ sudo mkdir -p /etc/apt/keyrings
4040
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
4141
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_21.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
4242

43-
# PostgreSQL
44-
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg
45-
sudo sh -c 'echo "deb [signed-by=/etc/apt/keyrings/postgresql.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
46-
4743
## Update Package Lists
4844
apt-get update -y
4945

@@ -115,21 +111,6 @@ apt-get autoclean
115111
# Install MariaDB
116112
bash 'scripts/features/mariadb.sh'
117113

118-
# Install Postgres 15
119-
apt-get install -y postgresql-15 postgresql-server-dev-15 postgresql-15-postgis-3 postgresql-15-postgis-3-scripts
120-
121-
# Configure Postgres Users
122-
sudo -u postgres psql -c "CREATE ROLE homestead LOGIN PASSWORD 'secret' SUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;"
123-
124-
# Configure Postgres Remote Access
125-
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/15/main/postgresql.conf
126-
echo "host all all 10.0.2.2/32 md5" | tee -a /etc/postgresql/15/main/pg_hba.conf
127-
128-
sudo -u postgres /usr/bin/createdb --echo --owner=homestead homestead
129-
service postgresql restart
130-
# Disable to lower initial overhead
131-
systemctl disable postgresql
132-
133114
# Install Redis, Memcached, & Beanstalk
134115
apt-get install -y redis-server memcached
135116
systemctl enable redis-server

scripts/features/postgresql.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -f ~/.homestead-features/wsl_user_name ]; then
4+
WSL_USER_NAME="$(cat ~/.homestead-features/wsl_user_name)"
5+
WSL_USER_GROUP="$(cat ~/.homestead-features/wsl_user_group)"
6+
else
7+
WSL_USER_NAME=vagrant
8+
WSL_USER_GROUP=vagrant
9+
fi
10+
11+
export DEBIAN_FRONTEND=noninteractive
12+
13+
if [ -f /home/$WSL_USER_NAME/.homestead-features/postgresql ]
14+
then
15+
echo "postgresql already installed."
16+
exit 0
17+
fi
18+
19+
touch /home/$WSL_USER_NAME/.homestead-features/postgresql
20+
chown -Rf $WSL_USER_NAME:$WSL_USER_GROUP /home/$WSL_USER_NAME/.homestead-features
21+
22+
# PostgreSQL
23+
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg
24+
sudo sh -c 'echo "deb [signed-by=/etc/apt/keyrings/postgresql.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
25+
26+
# Install Postgres 15
27+
apt-get install -y postgresql-15 postgresql-server-dev-15 postgresql-15-postgis-3 postgresql-15-postgis-3-scripts
28+
29+
# Configure Postgres Users
30+
sudo -u postgres psql -c "CREATE ROLE homestead LOGIN PASSWORD 'secret' SUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;"
31+
32+
# Configure Postgres Remote Access
33+
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/15/main/postgresql.conf
34+
echo "host all all 10.0.2.2/32 md5" | tee -a /etc/postgresql/15/main/pg_hba.conf
35+
36+
sudo -u postgres /usr/bin/createdb --echo --owner=homestead homestead
37+
service postgresql restart
38+
# Disable to lower initial overhead
39+
systemctl disable postgresql

0 commit comments

Comments
 (0)