Compare commits

..

2 Commits

Author SHA1 Message Date
383c2946ef Fix many derps 2020-02-05 18:23:34 -05:00
c59b8a0660 Update README 2020-01-25 12:53:02 -05:00
2 changed files with 48 additions and 17 deletions

View File

@@ -1,3 +1,34 @@
# run-with-podman # run-with-podman
Execute a script in a podman container Execute a script in a podman container
Usage: run-with-podman.sh --file FILE [--file-path PATH] [--mode [0,1,2]]
[--mask-dir PATH] [--image IMAGE_NAME] [--force-systemd]
[--help] [--] $OPTIONS
--file,-f FILE
The local script to execute in the container (typically sent from your IDE)
--file-path PATH
Path that the script operates on (Default: the --file directory)
--mode,-m 0,1,2
0. Nonpersistent container (always recreate) (Default)
1. Persistent container
2. Recreate persistent container
--mask-dir PATH
Hide this directory from the host OS, store contents in the container only (Default: unset)
(Useful for capturing output in the container only for easy reset)
--image,-i IMAGE_NAME
The name of the image to execute the script (Default: fedora:latest)
--force-systemd
Force container to init with systemd support
--help,-h
Print this help message and exit
-- [additional arguments to pass to --file FILE]
Parsed as "quoted string"

View File

@@ -102,7 +102,7 @@ function parse_input () {
parse_input "${@}" parse_input "${@}"
# Sanitize filename for unique container name # Sanitize filename for unique container name
CLEAN="${FILE_ACTIVE//_/}" && CLEAN="${CLEAN// /_}" && CLEAN="${FILE_ACTIVE//_/}" && CLEAN="${CLEAN// /}" &&
CLEAN="${CLEAN//[^a-zA-Z0-9_]/}" && CLEAN="${CLEAN,,}" CLEAN="${CLEAN//[^a-zA-Z0-9_]/}" && CLEAN="${CLEAN,,}"
# Allow container access to the pwd # Allow container access to the pwd
@@ -140,27 +140,27 @@ elif [[ $MODE == "1" ]]; then
if podman container exists "atom-${CLEAN}-persistent"; then if podman container exists "atom-${CLEAN}-persistent"; then
echo "Using existing container!" echo "Using existing container!"
podman exec "atom-${CLEAN}-persistent" \ podman exec "atom-${CLEAN}-persistent" \
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE}" /bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE}"
else else
if [[ -n $MASK_DIR ]]; then if [[ -n $MASK_DIR ]]; then
podman run \ podman run \
-it \ -it \
--systemd="${SYSTEMD}" \ --systemd="${SYSTEMD}" \
--name "atom-${CLEAN}-persistent" \ --name "atom-${CLEAN}-persistent" \
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \ -v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
-v "{FILE_ACTIVE_PATH}/${MASK_DIR}" \ -v "${FILE_ACTIVE_PATH}/${MASK_DIR}" \
-w "{FILE_ACTIVE_PATH}" \ -w "${FILE_ACTIVE_PATH}" \
"${IMAGE}" \ "${IMAGE}" \
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}" /bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
else else
podman run \ podman run \
-it \ -it \
--systemd="${SYSTEMD}" \ --systemd="${SYSTEMD}" \
--name "atom-${CLEAN}-persistent" \ --name "atom-${CLEAN}-persistent" \
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \ -v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
-w "{FILE_ACTIVE_PATH}" \ -w "${FILE_ACTIVE_PATH}" \
"${IMAGE}" \ "${IMAGE}" \
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}" /bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
fi fi
fi fi
# Recreate persistent container # Recreate persistent container
@@ -175,19 +175,19 @@ elif [[ $MODE == "2" ]]; then
-it \ -it \
--systemd="${SYSTEMD}" \ --systemd="${SYSTEMD}" \
--name "atom-${CLEAN}-persistent" \ --name "atom-${CLEAN}-persistent" \
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \ -v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
-v "{FILE_ACTIVE_PATH}/${MASK_DIR}" \ -v "${FILE_ACTIVE_PATH}/${MASK_DIR}" \
-w "{FILE_ACTIVE_PATH}" \ -w "${FILE_ACTIVE_PATH}" \
"${IMAGE}" \ "${IMAGE}" \
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}" /bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
else else
podman run \ podman run \
-it \ -it \
--systemd="${SYSTEMD}" \ --systemd="${SYSTEMD}" \
--name "atom-${CLEAN}-persistent" \ --name "atom-${CLEAN}-persistent" \
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \ -v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
-w "{FILE_ACTIVE_PATH}" \ -w "${FILE_ACTIVE_PATH}" \
"${IMAGE}" \ "${IMAGE}" \
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}" /bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
fi fi
fi fi