forked from chr314/nautilus-copy-path
-
Notifications
You must be signed in to change notification settings - Fork 0
/
net-installer.sh
executable file
·53 lines (41 loc) · 1.46 KB
/
net-installer.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
#!/bin/bash
NAUTILUS_PATH=$(which nautilus)
TMP_DIR=$(mktemp --directory)
download() {
curl -s 'https://api.github.com/repos/chr314/nautilus-copy-path/releases/latest' | jq -r '.tarball_url' | wget -i - -O nautilus-copy-path.tar.gz
tar -xzf nautilus-copy-path.tar.gz --strip-components=1
}
install () {
mkdir -p ~/.local/share/nautilus-python/extensions/nautilus-copy-path
cp nautilus-copy-path.py ~/.local/share/nautilus-python/extensions
cp nautilus_copy_path.py translation.py config.json ~/.local/share/nautilus-python/extensions/nautilus-copy-path
cp -rf translations ~/.local/share/nautilus-python/extensions/nautilus-copy-path
"${NAUTILUS_PATH}" -q || true
}
install_dependencies() {
DNF_CMD=$(which dnf)
APT_GET_CMD=$(which apt-get)
PACMAN_CMD=$(which pacman)
if [[ -n $DNF_CMD ]]; then
sudo dnf -y install nautilus-python python3-gobject
elif [[ -n $APT_GET_CMD ]]; then
sudo apt -y install python3-nautilus python3-gi
elif [[ -n $PACMAN_CMD ]]; then
sudo pacman -S python-nautilus python-gobject --noconfirm
fi
}
clear_exit() {
rm -rf "${TMP_DIR}"
exit 0
}
error_exit() {
echo "${1}"
rm -rf "${TMP_DIR}"
exit 1
}
cd "${TMP_DIR}" || error_exit 'Failed to change directory'
install_dependencies || error_exit 'Failed to install dependencies'
download || error_exit 'Failed to download nautilus-copy-path'
install || error_exit 'Failed to install nautilus-copy-path'
echo 'nautilus-copy-path installed successfully'
clear_exit