forked from stepb/urxvt-tabbedex
-
Notifications
You must be signed in to change notification settings - Fork 13
/
install
69 lines (55 loc) · 1.57 KB
/
install
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
#!/bin/sh
# tabbedex install script
# Wrap everything in a function so we don’t have to worry about connection
# dropping in the middle of the stream. This makes ‘curl … | sh’ as well as
# updating the install script while it is running safe.
_() {
url=https://github.com/mina86/urxvt-tabbedex
set -eu
if [ -e ~/.urxvt/tabbedex ]; then
printf >&2 '~/.urxvt/tabbedex already exist, overwrite? [y/N] '
if ! read ans || [ "$ans" != y ]; then
echo >&2 'Aborting'
exit 1
fi
fi
log () {
echo >&2
echo "$*" >&2
}
git=$(which git 2>/dev/null) || true
if [ -z "$git" ]; then
log 'Downloading and extracting the package to ~/.urxvt/tabbedex'
mkdir -p ~/.urxvt/tabbedex && cd ~/.urxvt/tabbedex
curl -L "$url/archive/master.tar.gz" |
tar vzx --exclude=.gitignore --strip-components=1
elif [ -e ~/.urxvt/tabbedex/.git ]; then
log 'Updating the repository'
cd ~/.urxvt/tabbedex
git remote update
git reset --hard origin/master
else
if [ -e ~/.urxvt/tabbedex ]; then
log 'Deleting ~/.urxvt/tabbedex'
rm -rf -- ~/.urxvt/tabbedex
fi
log 'Cloning the repository to ~/.urxvt/tabbedex'
mkdir -p ~/.urxvt
git clone "$url" ~/.urxvt/tabbedex
cd ~/.urxvt/tabbedex
fi
case "$(id -u)" in
0)
log 'Running as super user, installing globally.'
make install
;;
*)
log 'Running as regular user, installing symbolic links locally'
make install-local-symlink
esac
log 'You can re-run this script to update the extension.'
# Exit so that if this script got longer (if user run it from the repository),
# shell will not try to execute anything past its cursor in the file.
exit
}
_