-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
setup-util-1password
executable file
Β·152 lines (136 loc) Β· 4.98 KB
/
setup-util-1password
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env bash
# Desktop
# https://support.1password.com/install-linux/
# https://support.1password.com/betas/?linux
# https://releases.1password.com/linux/beta/#1password-for-linux-8.6.0-68
# https://1password.community/discussion/comment/631532#Comment_631532
# https://developer.1password.com/docs/ssh/agent
# https://aur.archlinux.org/packages/1password
# https://aur.archlinux.org/packages/1password-beta
# Browser
# https://app-updates.agilebits.com/product_history/B5X
# https://support.1password.com/betas/#install-a-beta-release-of-the-1password-extension
# This use to install the betas, as the betas were more stable. However that was a long time ago. If you desire the betas, send a PR for a `--beta` flag, or do `setup-util-1password-beta`
function setup_util_1password() (
source "$DOROTHY/sources/bash.bash"
# don't use improve performance snippet, as not all install methods provide something we can detect
# enable GITHUB_BUILD_EVAL
source "$(type -P setup-util)"
# =================================
# Desktop App
# setup
local arch sudo_reason='Installing 1Password to be accessible to all users, requires sudo.' options=(
--name='1Password App'
"$@"
)
arch="$(get-arch)"
function do_apt_keys {
setup-util-gpg --quiet
sudo-helper --reason="$sudo_reason" \
-- mkdir -p /etc/debsig/policies/AC2D62742012EA22 /usr/share/debsig/keyrings/AC2D62742012EA22
fetch 'https://downloads.1password.com/linux/debian/debsig/1password.pol' | sudo-helper --reason="$sudo_reason" \
-- tee /etc/debsig/policies/AC2D62742012EA22/1password.pol
fetch 'https://downloads.1password.com/linux/keys/1password.asc' | sudo-helper --reason="$sudo_reason" \
-- gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg
}
function do_rpm_keys {
sudo-helper --reason="$sudo_reason" \
-- rpm --import 'https://downloads.1password.com/linux/keys/1password.asc'
cat <<-EOF | sudo-helper --reason="$sudo_reason" -- tee /etc/yum.repos.d/1password.repo
[1password]
name=1Password Channel
baseurl=https://downloads.1password.com/linux/rpm/stable/\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey="https://downloads.1password.com/linux/keys/1password.asc"
EOF
}
function do_gpg_keys {
setup-util-gpg --quiet
fetch 'https://downloads.1password.com/linux/keys/1password.asc' | gpg --import
}
function do_install {
# linux 1password expects it to be inside [/opt/1Password/]
# ensure moving doesn't get nested
fs-rm --quiet --no-confirm --sudo -- /opt/1Password
# make the directory again
sudo-helper --reason="$sudo_reason" \
-- mkdir -pv /opt/1Password
# move everything that was extracted to go inside the directory
sudo-helper --reason="$sudo_reason" \
-- mv -v 1password-*/* /opt/1Password
# run the official after-install script, and if it fails, just do the symlink part of it
sudo-helper --reason="$sudo_reason" \
-- /opt/1Password/after-install.sh || sudo-helper -- ln -sf /opt/1Password/1password /usr/bin/1password
# @todo is there an official uninstall script?
}
function do_uninstall {
# https://support.1password.com/uninstall-1password/
if is-present -- /opt/1Password/after-remove.sh; then
sudo-helper --reason="$sudo_reason" \
-- /opt/1Password/after-remove.sh || :
fi
fs-rm --quiet --no-confirm --sudo -- /opt/1Password /usr/bin/1password
}
if is-mac; then
options+=(
--app='1Password'
CASK='1password'
)
elif is-linux; then
if test "$arch" = 'a64'; then
options+=(
DOWNLOAD='https://downloads.1password.com/linux/tar/stable/aarch64/1password-latest.tar.gz'
DOWNLOAD_UNZIP_FORMAT='tar'
DOWNLOAD_TARGET_PATH='/opt/1Password/1password'
DOWNLOAD_BUILD_INSTALL='do_install'
EVAL_UNINSTALL='do_uninstall'
)
elif is-apt; then
do_apt_keys
options+=(
APT='1password' # UBUNTU
APT_KEY='https://downloads.1password.com/linux/keys/1password.asc'
APT_REPO='deb [arch={ARCH} signed-by={KEY}] https://downloads.1password.com/linux/debian/amd64 stable main'
)
elif __command_exists -- rpm yum dnf; then
do_rpm_keys
options+=(
RPM='1password' # FEDORA
)
elif is-arch; then
do_gpg_keys
options+=(
AUR='1password' # ARCH
)
elif is-snap; then
options+=(
SNAP='1password'
)
elif is-flatpak; then
options+=(
FLATPAK='https://downloads.1password.com/linux/flatpak/1Password.flatpakref'
)
elif test "$arch" = 'x64'; then
options+=(
DOWNLOAD='https://downloads.1password.com/linux/tar/stable/x86_64/1password-latest.tar.gz'
DOWNLOAD_UNZIP_FORMAT='tar'
DOWNLOAD_TARGET_PATH='/opt/1Password/1password'
DOWNLOAD_BUILD_INSTALL='do_install'
EVAL_UNINSTALL='do_uninstall'
)
fi
fi
setup_util "${options[@]}"
# =================================
# Browser
cat <<-EOF
Install the 1Password Browser extension by visiting the following URL:
$(echo-style --code='https://1password.com/downloads/browser-extension')
EOF
)
# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
setup_util_1password "$@"
fi