forked from mgor/docker-acroread
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacroread
executable file
·48 lines (35 loc) · 1004 Bytes
/
acroread
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
#!/usr/bin/env bash
set -eu
[[ ${DEBUG:-0} -gt 0 ]] && set -x
main()
{
local src_path="${HOME}/Documents"
local dst_path="/home/acroread/Documents"
local document=""
local filename=""
[[ $# -ge 1 ]] && { document="$1"; shift; }
if [[ -n "${document}" ]]
then
document="$(readlink -f "$document")"
if [[ -f "${document}" ]]; then
filename="${dst_path}/$(basename "${document}")"
src_path="$(dirname "${document}")"
fi
fi
local serverip=$(ip -4 a show docker0 | awk -F '[ /]+' '/inet[ ]/ { print $3 }')
[[ -z $serverip ]] && exit 1
xhost +local:docker
docker run -it --rm -v "${src_path}:${dst_path}:rw" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /var/run/cups:/var/run/cups:ro \
-e uid="$(id -u)" \
-e gid="$(id -g)" \
-e DISPLAY="unix${DISPLAY}" \
-e CUPS_SERVER="${serverip}" \
-e FILE="${filename}" \
-e DEBUG="${DEBUG:-0}" \
--name acroread \
acroread
return $?
}
main "$@"