forked from nextgenusfs/funannotate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
funannotate-podman
36 lines (30 loc) · 969 Bytes
/
funannotate-podman
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
#!/usr/bin/env bash
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(readlink "$(basename "$1")")
while [ "$LINK" ]; do
cd "$(dirname "$LINK")"
LINK=$(readlink "$(basename "$1")")
done
REALPATH="$PWD/$(basename "$1")"
cd "$OURPWD"
echo "$REALPATH"
}
timezone() {
if [ "$(uname)" == "Darwin" ]; then
TZ=$(readlink /etc/localtime | sed 's#/var/db/timezone/zoneinfo/##')
else
TZ=$(readlink /etc/timezone)
fi
echo $TZ
}
# Only allocate tty if one is detected. See - https://stackoverflow.com/questions/911168
if [[ -t 0 ]]; then IT+=(-i); fi
if [[ -t 1 ]]; then IT+=(-t); fi
USER="$(id -u $(logname)):$(id -g $(logname))"
WORKDIR="$(realpath .)"
MOUNT="type=bind,source=${WORKDIR},target=${WORKDIR}"
TZ="$(timezone)"
exec podman run --rm "${IT[@]}" -e TZ="${TZ}" --workdir "${WORKDIR}" --mount "${MOUNT}" nextgenusfs/funannotate:latest funannotate "$@"
# ` --user "${USER}" ` is not needed in rootless mode