Compare commits
2 Commits
7944dcf5d4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 383c2946ef | |||
| c59b8a0660 |
33
README.md
33
README.md
@@ -1,3 +1,34 @@
|
||||
# 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"
|
||||
|
||||
@@ -102,7 +102,7 @@ function parse_input () {
|
||||
parse_input "${@}"
|
||||
|
||||
# Sanitize filename for unique container name
|
||||
CLEAN="${FILE_ACTIVE//_/}" && CLEAN="${CLEAN// /_}" &&
|
||||
CLEAN="${FILE_ACTIVE//_/}" && CLEAN="${CLEAN// /}" &&
|
||||
CLEAN="${CLEAN//[^a-zA-Z0-9_]/}" && CLEAN="${CLEAN,,}"
|
||||
|
||||
# Allow container access to the pwd
|
||||
@@ -140,27 +140,27 @@ elif [[ $MODE == "1" ]]; then
|
||||
if podman container exists "atom-${CLEAN}-persistent"; then
|
||||
echo "Using existing container!"
|
||||
podman exec "atom-${CLEAN}-persistent" \
|
||||
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE}"
|
||||
/bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE}"
|
||||
else
|
||||
if [[ -n $MASK_DIR ]]; then
|
||||
podman run \
|
||||
-it \
|
||||
--systemd="${SYSTEMD}" \
|
||||
--name "atom-${CLEAN}-persistent" \
|
||||
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \
|
||||
-v "{FILE_ACTIVE_PATH}/${MASK_DIR}" \
|
||||
-w "{FILE_ACTIVE_PATH}" \
|
||||
-v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
|
||||
-v "${FILE_ACTIVE_PATH}/${MASK_DIR}" \
|
||||
-w "${FILE_ACTIVE_PATH}" \
|
||||
"${IMAGE}" \
|
||||
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}"
|
||||
/bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
|
||||
else
|
||||
podman run \
|
||||
-it \
|
||||
--systemd="${SYSTEMD}" \
|
||||
--name "atom-${CLEAN}-persistent" \
|
||||
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \
|
||||
-w "{FILE_ACTIVE_PATH}" \
|
||||
-v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
|
||||
-w "${FILE_ACTIVE_PATH}" \
|
||||
"${IMAGE}" \
|
||||
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}"
|
||||
/bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
|
||||
fi
|
||||
fi
|
||||
# Recreate persistent container
|
||||
@@ -175,19 +175,19 @@ elif [[ $MODE == "2" ]]; then
|
||||
-it \
|
||||
--systemd="${SYSTEMD}" \
|
||||
--name "atom-${CLEAN}-persistent" \
|
||||
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \
|
||||
-v "{FILE_ACTIVE_PATH}/${MASK_DIR}" \
|
||||
-w "{FILE_ACTIVE_PATH}" \
|
||||
-v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
|
||||
-v "${FILE_ACTIVE_PATH}/${MASK_DIR}" \
|
||||
-w "${FILE_ACTIVE_PATH}" \
|
||||
"${IMAGE}" \
|
||||
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}"
|
||||
/bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
|
||||
else
|
||||
podman run \
|
||||
-it \
|
||||
--systemd="${SYSTEMD}" \
|
||||
--name "atom-${CLEAN}-persistent" \
|
||||
-v "{FILE_ACTIVE_PATH}:{FILE_ACTIVE_PATH}" \
|
||||
-w "{FILE_ACTIVE_PATH}" \
|
||||
-v "${FILE_ACTIVE_PATH}:${FILE_ACTIVE_PATH}" \
|
||||
-w "${FILE_ACTIVE_PATH}" \
|
||||
"${IMAGE}" \
|
||||
/bin/bash -c "chmod 755 {FILE_ACTIVE} && {FILE_ACTIVE} ${OPTIONS}"
|
||||
/bin/bash -c "chmod 755 ${FILE_ACTIVE} && ${FILE_ACTIVE} ${OPTIONS}"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user