-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1password.bits
More file actions
85 lines (70 loc) · 1.81 KB
/
1password.bits
File metadata and controls
85 lines (70 loc) · 1.81 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
#!/bin/bash
set -e
#-----------
# VARIABLES
#-----------
ONEPASSWORD_VERSION=${ONEPASSWORD_VERSION-1.5.0}
#-----------
# HELPERS
#-----------
set_env()
{
KEY=$1
VAL=$2
echo "export $KEY=$VAL" >> $HOME/.bash_aliases
}
install_shapkgsum()
{
wget https://github.com/aforward/shapkgsum/raw/main/bin/shapkgsum && \
chmod 755 ./shapkgsum
}
install_1password()
{
if [ "$(uname -a | grep Darwin)" == "" ]; then
install_1password_linux
else
install_1password_mac
fi
}
install_1password_linux()
{
wget https://cache.agilebits.com/dist/1P/op/pkg/v${ONEPASSWORD_VERSION}/op_linux_amd64_v${ONEPASSWORD_VERSION}.zip
unzip -u op_linux_amd64_v${ONEPASSWORD_VERSION}.zip
mkdir -p $HOME/.gnupg
echo "keyserver keyserver.ubuntu.com" >> $HOME/.gnupg/gpg.conf
gpg --receive-keys 3FEF9748469ADBE15DA7CA80AC2D62742012EA22
gpg --verify op.sig op && \
set_env PATH "${MY_DIR}:\$PATH"
}
install_1password_mac()
{
wget https://cache.agilebits.com/dist/1P/op/pkg/v${ONEPASSWORD_VERSION}/op_darwin_amd64_v${ONEPASSWORD_VERSION}.pkg && \
verify_signature && \
sudo installer -pkg op_darwin_amd64_v${ONEPASSWORD_VERSION}.pkg -target / && \
op --version
}
verify_signature()
{
# information on verifying the signature is available
# https://support.1password.com/verify-command-line/
AGILEBITS=$(./shapkgsum op_darwin_amd64_v1.5.0.pkg)
FINGERPRINT="14 1D D8 7B 2B 23 12 11 F1 44 08 49 79 80 07 DF 62 1D E6 EB 3D AB 98 5B C9 64 EE 97 04 C4 A1 C1"
if [ "${AGILEBITS}" != "${FINGERPRINT}" ]; then
echo "Unverified signature"
echo "${AGILEBITS}"
exit 1
else
echo "Signature verified"
fi
}
#-----------
# INSTALLER
#-----------
INSTALL_DIR=${INSTALL_DIR-/opt}
MY_DIR=${INSTALL_DIR}/1password
rm -rf $MY_DIR
mkdir -p $MY_DIR
(cd $MY_DIR && \
install_shapkgsum && \
install_1password && \
echo "OK")