-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·55 lines (47 loc) · 1.56 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
#!/bin/bash
# vim: foldmethod=marker
# Some info about this script {{{
# This script 'installs' all the files to their corresponding locations
#
# What does it do:
# - Directories will be created if nonexistent
# - Files will be SYMLINKED if nonexistent
#
# This way you can add files in a folder that should not be tracked
# (i.e. symlinked) in this repository. Let's say there are files in
# ~/bin that you don't want to be in this repository. You can simply
# add them to ~/bin directly instead of putting them here and have
# them symlinked. If the whole directory was symlinked instead of its
# files, then adding files to ~/bin will make them be tracked here.
#}}}
install-files() {
SRC="$1"
DEST="$2"
find "$SRC" -type f -printf '%P\0' | while read -rd $'\0' f; do
DIR="$(dirname "$DEST/$f")"
[ -d "$DIR" ] || mkdir -p "$DIR"
if [ -f "$DEST/$f" ]; then
:
#echo "$DEST/$f already exists. Skipping."
#rsync -PUt "$SRC/$f" "$DEST/$f"
#rm -v "$DEST/$f"
else
ln -vs "$(realpath "$SRC/$f")" "$DEST/$f"
fi
done
}
install-go() {
PROG_NAME="$1"
SRC="compiled-programs/$PROG_NAME"
DEST="${2:-$HOME/go/bin}"
[ -d "$DEST" ] || mkdir -p "$DEST"
if [ ! -f "$DEST/$PROG_NAME" ]; then
(cd "$SRC" && go build) &&
ln -vs "$(realpath "$SRC/$PROG_NAME")" "$DEST/$PROG_NAME"
fi
}
install-files "bin" "$HOME/bin"
install-files "config" "$HOME/.config"
install-files "home" "$HOME"
install-go "mount-go"
install-go "ffmpeg-cut-timestamps"