-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
install.sh
executable file
ยท235 lines (219 loc) ยท 5.96 KB
/
install.sh
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/sh
set -eu
flatpak_package="app.getclipboard.Clipboard"
unsupported() {
printf "\033[31mSorry, but this installer script doesn't support %s.\n\033[0m" "$1"
printf '\033[32m๐ก However, you can still install CB using the other methods in the readme!\n\033[0m'
}
verify_flatpak(){
if flatpak list | grep -q "$flatpak_package"; then
printf "\033[32mClipboard installed successfully!\n\033[0m"
printf "\033[0mAdd this alias to your terminal profile (like .bashrc) to make it work every time:\n\033[0m"
printf '\033[33malias cb="flatpak run %s"\n\033[0m' "$flatpak_package"
exit 0
else
printf "\033[31mCouldn't install CB\n\033[0m"
exit 1
fi
}
verify() {
if command -v cb 2>&1
then
if ! cb 2>&1
then
unsupported "this system"
exit 1
else
printf "\033[32mClipboard installed successfully!\n\033[0m"
exit 0
fi
else
printf "\033[31mCouldn't install CB\n\033[0m"
exit 1
fi
}
compile() {
git clone --depth 1 https://github.com/slackadays/Clipboard
cd Clipboard/build
cmake ..
cmake --build .
cmake --install .
if [ "$(uname)" = "OpenBSD" ] #check if OpenBSD
then
doas cmake --install .
else
sudo cmake --install .
fi
}
can_use_sudo() {
prompt=$(sudo -nv 2>&1)
if sudo -nv > /dev/null 2>&1; then
# exit code of sudo-command is 0
return 0
elif echo "$prompt" | grep -q '^sudo:'; then
return 0
else
return 1
fi
}
printf "\033[32mSearching for a package manager...\n\033[0m"
if command -v apk > /dev/null 2>&1
then
if can_use_sudo
then
sudo apk add clipboard
verify
fi
elif command -v yay > /dev/null 2>&1
then
if can_use_sudo
then
sudo yay -S clipboard
verify
fi
elif command -v emerge > /dev/null 2>&1
then
if can_use_sudo
then
sudo emerge -av app-misc/clipboard
verify
fi
elif command -v brew > /dev/null 2>&1
then
brew install clipboard
verify
elif command -v flatpak > /dev/null 2>&1
then
if can_use_sudo
then
sudo flatpak install flathub "$flatpak_package" -y
else
flatpak install flathub "$flatpak_package" -y
fi
verify_flatpak
elif command -v snap > /dev/null 2>&1
then
if can_use_sudo
then
sudo snap install clipboard
verify
fi
elif command -v nix-env > /dev/null 2>&1
then
nix-env -iA nixpkgs.clipboard-jh
verify
elif command -v pacstall > /dev/null 2>&1
then
pacstall -I clipboard-bin
verify
elif command -v scoop > /dev/null 2>&1
then
scoop install clipboard
verify
elif command -v xbps-install > /dev/null 2>&1
then
if can_use_sudo
then
sudo xbps-install -S clipboard
verify
fi
fi
tmp_dir=$(mktemp -d -t cb-XXXXXXXXXX)
cd "$tmp_dir"
if can_use_sudo
then
requires_sudo=true
install_path="/usr/local"
sudo mkdir -p "$install_path/bin"
sudo mkdir -p "$install_path/lib"
else
requires_sudo=false
install_path="$HOME/.local"
mkdir -p "$install_path/bin"
mkdir -p "$install_path/lib"
fi
if [ "$(uname)" = "Linux" ]
then
if [ "$(uname -m)" = "x86_64" ]
then
download_link=https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-linux-amd64.zip
elif [ "$(uname -m)" = "aarch64" ]
then
download_link=https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-linux-arm64.zip
elif [ "$(uname -m)" = "riscv64" ]
then
download_link=https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-linux-riscv64.zip
elif [ "$(uname -m)" = "i386" ]
then
download_link=https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-linux-i386.zip
elif [ "$(uname -m)" = "ppc64le" ]
then
download_link=https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-linux-ppc64le.zip
elif [ "$(uname -m)" = "s390x" ]
then
download_link=https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-linux-s390x.zip
else
download_link="skip"
fi
if [ "$download_link" != "skip" ]
then
curl -SL $download_link -o clipboard-linux.zip
unzip clipboard-linux.zip
rm clipboard-linux.zip
if [ "$requires_sudo" = true ]
then
sudo mv bin/cb "$install_path/bin/cb"
else
mv bin/cb "$install_path/bin/cb"
fi
chmod +x "$install_path/bin/cb"
if [ -f "lib/libcbx11.so" ]
then
if [ "$requires_sudo" = true ]
then
sudo mv lib/libcbx11.so "$install_path/lib/libcbx11.so"
else
mv lib/libcbx11.so "$install_path/lib/libcbx11.so"
fi
fi
if [ -f "lib/libcbwayland.so" ]
then
if [ "$requires_sudo" = true ]
then
sudo mv lib/libcbwayland.so "$install_path/lib/libcbwayland.so"
else
mv lib/libcbwayland.so "$install_path/lib/libcbwayland.so"
fi
fi
fi
elif [ "$(uname)" = "Darwin" ]
then
if [ "$(uname -m)" = "x86_64" ]
then
curl -SsLl https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-macos-amd64.zip -o clipboard-macos.zip
elif [ "$(uname -m)" = "arm64" ]
then
curl -SsLl https://nightly.link/Slackadays/Clipboard/workflows/build-clipboard/main/clipboard-macos-arm64.zip -o clipboard-macos.zip
fi
unzip clipboard-macos.zip
rm clipboard-macos.zip
sudo mv bin/cb "$install_path/bin/cb"
chmod +x "$install_path/bin/cb"
elif [ "$(uname)" = "FreeBSD" ]
then
unsupported "FreeBSD"
exit 0
elif [ "$(uname)" = "OpenBSD" ]
then
unsupported "OpenBSD"
exit 0
elif [ "$(uname)" = "NetBSD" ]
then
unsupported "NetBSD"
exit 0
else
compile
fi
cd ..
rm -rf "$tmp_dir"
verify