-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1password
More file actions
executable file
·107 lines (91 loc) · 2.51 KB
/
1password
File metadata and controls
executable file
·107 lines (91 loc) · 2.51 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
USER_UID=$(id -u)
USER_GID=$(id -g)
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
AGILEBITS_LICENSE=~/.agilebits/
ONEPASS_USER=root
DROPBOX_DIR="${HOME}/Dropbox"
cleanup_stopped_1password_instances(){
echo "Cleaning up stopped 1password instances..."
for c in $(${SUDO} docker ps -a -q)
do
image="$(${SUDO} docker inspect -f {{.Config.Image}} ${c})"
if [ "${image}" == "1password:latest" ]; then
running=$(${SUDO} docker inspect -f {{.State.Running}} ${c})
if [ "${running}" != "true" ]; then
${SUDO} docker rm "${c}" >/dev/null
fi
fi
done
}
prepare_docker_env_parameters() {
ENV_VARS+=" --env=USER_UID=${USER_UID}"
ENV_VARS+=" --env=USER_GID=${USER_GID}"
ENV_VARS+=" --env=DISPLAY"
ENV_VARS+=" --env=XAUTHORITY=${XAUTH}"
ENV_VARS+=" --env=TZ=$(date +%Z)"
}
prepare_docker_volume_parameters() {
touch ${XAUTH}
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f ${XAUTH} nmerge -
AGILEBITS_VAULT=$(find_vaults)
if [ -z ${AGILEBITS_VAULT} ] ; then
echo "No opvault found under ~/"
else
VOLUMES+=" --volume=${AGILEBITS_VAULT}:/tmp/1Password.opvault"
fi
if [ ! -f ${AGILEBITS_LICENSE}/OPW4.license ]; then
echo "You don't seem to have a valid license for 1Password."
echo "If you have one please place it in ${AGILEBITS_LICENSE}/OPW4.license"
else
VOLUMES+=" --volume=${AGILEBITS_LICENSE}:/tmp/agilebits"
fi
VOLUMES+=" --volume=${XSOCK}:${XSOCK}"
VOLUMES+=" --volume=${XAUTH}:${XAUTH}"
# Custom path
}
prepare_docker_device_parameters() {
# enumerate video devices for webcam support
VIDEO_DEVICES=
for device in /dev/video*
do
if [ -c $device ]; then
VIDEO_DEVICES="${VIDEO_DEVICES} --device $device:$device"
fi
done
}
find_vaults() {
vaults=$(find ~/ -type d -name "*.opvault" 2>/dev/null)
echo "$vaults" | tail -1
}
prog=$(basename $0)
exec=$(which $prog)
if [[ ${prog} == "1password-wrapper" ]]; then
case ${1} in
1password)
prog=${1}
shift
;;
*|help)
list_commands
exit 1
;;
esac
elif [[ -n ${exec} ]]; then
# launch host binary if it exists
exec ${exec} $@
fi
[ ! -d ${AGILEBITS_LICENSE} ] && mkdir ${AGILEBITS_LICENSE}
cleanup_stopped_1password_instances
prepare_docker_env_parameters
prepare_docker_volume_parameters
prepare_docker_device_parameters
echo "Starting ${prog}..."
${SUDO} docker run -d \
${ENV_VARS} \
${VIDEO_DEVICES} \
${VOLUMES} \
--net="host" \
eyehatefim/1password:latest >/dev/null