Skip to content

Commit

Permalink
detect container runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
someth2say committed Jan 22, 2021
1 parent 98b687a commit f99f6e9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ if [ ! -d $pcommit_cache ]; then
mkdir -p $pcommit_cache;
fi

### Helper functions
function has() {
curl -sL https://git.io/_has | bash -s $1 > /dev/null
return $?
}

# Execute container image
podman run --name ${container_name} -ti \
has "podman" && command="podman" || has "docker" && command="docker"

$command run --name ${container_name} -ti \
-v ${book}:${container_book}:z \
-v ${ssh_cfg_cpy}:${container_ssh_cfg}:z,ro \
-v ${pcommit_cache}:${container_pcommit_cache}:z \
Expand All @@ -43,6 +51,6 @@ exitcode=$?

# Cleanup
rm -rf ${ssh_cfg_cpy}
podman rm -f ${container_name} > /dev/null
$command rm -f ${container_name} > /dev/null

exit $exitcode

0 comments on commit f99f6e9

Please sign in to comment.