@@ -21,7 +21,8 @@ Options:
2121 --playwright Also start playwright profile container
2222 --playwright-ssh-port PORT SSH port for playwright container (default: 2203)
2323 --playwright-container NAME Playwright container name (default: devbox-playwright)
24- --post-install TARGET Optional post-install script/profile: example | dev | ai | migrate | /projects/path/script.sh
24+ --post-install TARGET Optional post-install script/profile(s): example | dev | ai | migrate | /projects/path/script.sh
25+ Repeat flag or use comma list: --post-install dev --post-install ai / --post-install dev,ai
2526 --env-file PATH Optional env file (default auto-load: ./.env, then ./.env.local)
2627 --recreate Remove existing containers before rebuild
2728 -h, --help Show this help
@@ -49,6 +50,8 @@ DEVBOX_PLAYWRIGHT_ENABLED="no"
4950DEVBOX_PLAYWRIGHT_SSH_PORT=" 2203"
5051DEVBOX_PLAYWRIGHT_CONTAINER_NAME=" devbox-playwright"
5152POST_INSTALL_TARGET=" "
53+ POST_INSTALL_SET_BY_CLI=" no"
54+ POST_INSTALL_TARGETS=()
5255DEVBOX_ENV_FILE=" "
5356RECREATE=" no"
5457
@@ -95,7 +98,19 @@ while [ $# -gt 0 ]; do
9598 --playwright) DEVBOX_PLAYWRIGHT_ENABLED=" yes" ; shift ;;
9699 --playwright-ssh-port) DEVBOX_PLAYWRIGHT_SSH_PORT=" ${2:- } " ; shift 2 ;;
97100 --playwright-container) DEVBOX_PLAYWRIGHT_CONTAINER_NAME=" ${2:- } " ; shift 2 ;;
98- --post-install) POST_INSTALL_TARGET=" ${2:- } " ; shift 2 ;;
101+ --post-install)
102+ if [ " ${POST_INSTALL_SET_BY_CLI} " != " yes" ]; then
103+ POST_INSTALL_TARGETS=()
104+ POST_INSTALL_SET_BY_CLI=" yes"
105+ fi
106+ IFS=' ,' read -r -a _post_items <<< " ${2:-}"
107+ for _post_item in " ${_post_items[@]} " ; do
108+ _post_item=" ${_post_item# " ${_post_item%% [![:space:]]* } " } "
109+ _post_item=" ${_post_item% " ${_post_item##* [![:space:]]} " } "
110+ [ -n " ${_post_item} " ] && POST_INSTALL_TARGETS+=(" ${_post_item} " )
111+ done
112+ shift 2
113+ ;;
99114 --env-file) DEVBOX_ENV_FILE=" ${2:- } " ; shift 2 ;; # already loaded in pre-parse
100115 --recreate) RECREATE=" yes" ; shift ;;
101116 -h|--help) usage; exit 0 ;;
@@ -107,6 +122,15 @@ while [ $# -gt 0 ]; do
107122 esac
108123done
109124
125+ if [ " ${POST_INSTALL_SET_BY_CLI} " != " yes" ] && [ -n " ${POST_INSTALL_TARGET} " ]; then
126+ IFS=' ,' read -r -a _post_items <<< " ${POST_INSTALL_TARGET}"
127+ for _post_item in " ${_post_items[@]} " ; do
128+ _post_item=" ${_post_item# " ${_post_item%% [![:space:]]* } " } "
129+ _post_item=" ${_post_item% " ${_post_item##* [![:space:]]} " } "
130+ [ -n " ${_post_item} " ] && POST_INSTALL_TARGETS+=(" ${_post_item} " )
131+ done
132+ fi
133+
110134if [ " ${DEVBOX_WORKSPACE_LINK} " != " on" ] && [ " ${DEVBOX_WORKSPACE_LINK} " != " off" ]; then
111135 echo " Error: --workspace-link must be 'on' or 'off'." >&2
112136 exit 1
@@ -219,7 +243,13 @@ export DEVBOX_USER DEVBOX_PASS DEVBOX_UID DEVBOX_GID DEVBOX_SSH_PORT DOCKER_GID
219243export DEVBOX_PROJECTS_DIR DEVBOX_PROJECTS_MOUNT DEVBOX_WORKSPACE_LINK DEVBOX_START_DIR DEVBOX_PASSWORDLESS_SUDO DEVBOX_CONTAINER_NAME DEVBOX_HOME_DIR
220244export DEVBOX_PLAYWRIGHT_SSH_PORT DEVBOX_PLAYWRIGHT_CONTAINER_NAME
221245
222- POST_INSTALL_SCRIPT=" $( resolve_post_install_script " $POST_INSTALL_TARGET " ) "
246+ POST_INSTALL_SCRIPTS=()
247+ if [ " ${# POST_INSTALL_TARGETS[@]} " -gt 0 ]; then
248+ for _post_target in " ${POST_INSTALL_TARGETS[@]} " ; do
249+ _post_script=" $( resolve_post_install_script " $_post_target " ) "
250+ [ -n " ${_post_script} " ] && POST_INSTALL_SCRIPTS+=(" ${_post_script} " )
251+ done
252+ fi
223253
224254mkdir -p " ${DEVBOX_PROJECTS_DIR} "
225255mkdir -p " ${DEVBOX_HOME_DIR} " " ${DEVBOX_HOME_DIR} /.ssh"
@@ -275,11 +305,13 @@ if [ "${DEVBOX_PLAYWRIGHT_ENABLED}" = "yes" ]; then
275305 " chown -R '${DEVBOX_USER} ' '${DEVBOX_PROJECTS_MOUNT} ' '/home/${DEVBOX_USER} ' || true"
276306fi
277307
278- if [ -n " $POST_INSTALL_SCRIPT " ]; then
279- run_post_install " ${DEVBOX_CONTAINER_NAME} " " $POST_INSTALL_SCRIPT "
280- if [ " ${DEVBOX_PLAYWRIGHT_ENABLED} " = " yes" ]; then
281- run_post_install " ${DEVBOX_PLAYWRIGHT_CONTAINER_NAME} " " $POST_INSTALL_SCRIPT "
282- fi
308+ if [ " ${# POST_INSTALL_SCRIPTS[@]} " -gt 0 ]; then
309+ for _post_script in " ${POST_INSTALL_SCRIPTS[@]} " ; do
310+ run_post_install " ${DEVBOX_CONTAINER_NAME} " " ${_post_script} "
311+ if [ " ${DEVBOX_PLAYWRIGHT_ENABLED} " = " yes" ]; then
312+ run_post_install " ${DEVBOX_PLAYWRIGHT_CONTAINER_NAME} " " ${_post_script} "
313+ fi
314+ done
283315fi
284316
285317echo
@@ -295,8 +327,11 @@ echo "| Passwordless sudo: ${DEVBOX_PASSWORDLESS_SUDO}"
295327if [ " ${DEVBOX_PLAYWRIGHT_ENABLED} " = " yes" ]; then
296328 echo " | Playwright SSH: ${DEVBOX_PLAYWRIGHT_SSH_PORT} "
297329fi
298- if [ -n " $POST_INSTALL_SCRIPT " ]; then
299- echo " | Post-install: ${POST_INSTALL_SCRIPT} "
330+ if [ " ${# POST_INSTALL_SCRIPTS[@]} " -gt 0 ]; then
331+ echo " | Post-install:"
332+ for _post_script in " ${POST_INSTALL_SCRIPTS[@]} " ; do
333+ echo " | - ${_post_script} "
334+ done
300335fi
301336if [ " ${DEVBOX_PASS} " = " changeme" ]; then
302337 echo " | Password: changeme (default)."
0 commit comments