-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate.sh
executable file
·43 lines (39 loc) · 1.13 KB
/
update.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
#!/bin/bash
# ------------------------------------------------------------------------------
# Updates Misc-Scripts already installed.
#
# Usage: [sudo] ./update.sh
#
# Run as root/sudo, copies scripts over the existing files in /usr/local/bin
# and /usr/local/sbin, otherwise in the user's home directory ~/bin and ~/sbin.
#
# Author : Esa Jokinen (oh2fih)
# Home : https://github.com/oh2fih/Misc-Scripts
# ------------------------------------------------------------------------------
if [ "$EUID" -eq 0 ]; then
BIN=/usr/local/bin
SBIN=/usr/local/sbin
else
BIN="$HOME/bin"
SBIN="$HOME/sbin"
fi
GITROOT="$(git rev-parse --show-toplevel)" || exit 1
printf "Updating scripts in directories %s & %s...\n\n" "$BIN" "$SBIN"
cd "$GITROOT/bin" || exit 1
for f in *; do
if test -f "$BIN/$f"; then
printf "Updating %s/%s...\n" "$BIN" "$f"
cp "$GITROOT/bin/$f" "$BIN/$f"
else
printf "Skipping bin/%s...\n" "$f"
fi
done
cd "$GITROOT/sbin" || exit 1
for f in *; do
if test -f "$SBIN/$f"; then
printf "Updating %s/%s...\n" "$SBIN" "$f"
cp "$GITROOT/sbin/$f" "$SBIN/$f"
else
printf "Skipping sbin/%s...\n" "$f"
fi
done