-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoci
executable file
·48 lines (46 loc) · 1.27 KB
/
oci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -eu -o pipefail
if [[ ! -e "$HOME/.kube" ]]; then
mkdir "$HOME/.kube"
fi
if [[ ! -e "$HOME/.oci" ]]; then
mkdir "$HOME/.oci"
fi
if [[ ! -e "$HOME/suggestion_variable.txt" ]]; then
touch "$HOME/suggestion_variable.txt"
fi
if command -v docker &>/dev/null; then
# shellcheck disable=SC2046
docker container run \
--name oci$$ \
--rm \
-e HOME="$HOME" \
-e USER_NAME="$(id -un)" \
-i \
-t \
-u "$(id -u):$(id -g)" \
-v "$HOME/.kube:$HOME/.kube" \
-v "$HOME/.oci:$HOME/.oci" \
-v "$HOME/suggestion_variable.txt:$HOME/suggestion_variable.txt" \
$([[ -v OCI_CLI_PROFILE ]] && echo "-e OCI_CLI_PROFILE=$OCI_CLI_PROFILE") \
ghcr.io/shakiyam/oci-cli "$@"
elif command -v podman &>/dev/null; then
# shellcheck disable=SC2046
podman container run \
--entrypoint=/usr/local/bin/oci \
--name oci$$ \
--rm \
--security-opt label=disable \
--userns=keep-id \
-e HOME="$HOME" \
-i \
-t \
-v "$HOME/.kube:$HOME/.kube" \
-v "$HOME/.oci:$HOME/.oci" \
-v "$HOME/suggestion_variable.txt:$HOME/suggestion_variable.txt" \
$([[ -v OCI_CLI_PROFILE ]] && echo "-e OCI_CLI_PROFILE=$OCI_CLI_PROFILE") \
ghcr.io/shakiyam/oci-cli "$@"
else
echo "Neither docker nor podman is installed."
exit 1
fi