Skip to content

Commit 0722c39

Browse files
committed
simplify and generalize
1 parent 81c4ac5 commit 0722c39

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
"ghcr.io/devcontainers-extra/features/mysql-homebrew:1": {}
2626
},
2727
"forwardPorts": [],
28-
"postCreateCommand": "/bin/bash -lc '/workspace/.devcontainer/post-create.sh'",
29-
"postStartCommand": "/bin/bash -lc 'echo \"local all all trust\nhost all all 127.0.0.1/32 trust\nhost all all ::1/128 trust\" | sudo tee /etc/postgresql/16/main/pg_hba.conf > /dev/null && sudo service postgresql restart && /workspace/.devcontainer/start-mysql.sh && /workspace/.devcontainer/init-mysql.sh'",
28+
"postCreateCommand": "/bin/bash -lc '${containerWorkspaceFolder}/.devcontainer/post-create.sh'",
29+
"postStartCommand": "/bin/bash -lc 'echo \"local all all trust\nhost all all 127.0.0.1/32 trust\nhost all all ::1/128 trust\" | sudo tee /etc/postgresql/16/main/pg_hba.conf > /dev/null && sudo service postgresql restart && ${containerWorkspaceFolder}/.devcontainer/start-mysql.sh && ${containerWorkspaceFolder}/.devcontainer/init-mysql.sh'",
3030
"remoteUser": "vscode",
31-
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace:Z,type=bind,consistency=cached",
32-
"workspaceFolder": "/workspace",
3331
"containerEnv": {
3432
"GOPATH": "/home/vscode/go",
3533
"MYSQL_DATABASE": "singularity",

.devcontainer/init-mysql.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ fi
99
# Use same socket as mysql.server (homebrew default)
1010
SOCKET="${MYSQL_SOCKET:-/tmp/mysql.sock}"
1111

12-
# One-time init guard
13-
MARKER="/workspace/.devcontainer/.mysql-initialized"
14-
if [ -f "$MARKER" ]; then
15-
exit 0
16-
fi
12+
## Removed one-time init guard; operations below are idempotent
1713

1814
# Determine root auth flags
1915
MYSQL_ROOT_FLAGS=("-uroot")
@@ -48,7 +44,6 @@ GRANT ALL PRIVILEGES ON \`${DB}\`.* TO '${USER}'@'%';
4844
FLUSH PRIVILEGES;
4945
SQL
5046

51-
# mark initialized
52-
touch "$MARKER"
47+
## No marker file; script can run safely on every start
5348

5449

0 commit comments

Comments
 (0)