-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·63 lines (51 loc) · 1.26 KB
/
deploy.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
#!/bin/sh
# "Deploys" this config pack,
# i.e. symlink config files to those in this repo
# backing up existing files etc.
# Accepts one argument: specific file to be symlinked as "per-box.lua"
if [ -z "$1" -o ! -f "$1" ]; then
echo "Set file with box-specific as the first and only argument"
exit 1
fi
RDIR=$(dirname `readlink -fn $0`)
excludes="workstation.lua notebook.lua deploy.sh"
include() {
for i in ${excludes[@]}; do
if [ $i == $1 ]; then
return 1
fi
done
return 0
}
symlinkit() {
SRC=$1
TRGT=$2
if [ -L $TRGT ]; then
echo "Removing old symlink $TRGT..."
rm "$TRGT"
elif [ -e $TRGT ]; then
if [ -e $TRGT~ ]; then
echo "Both $TRGT and $TRGT~ exist, skipping..."
return
fi
echo "Backing up $TRGT to $TRGT~"
mv "$TRGT" "$TRGT"~
fi
ln -s "$SRC" "$TRGT"
}
FILES=$(ls $RDIR)
CONFDIR=${XDG_CONFIG_HOME="$HOME/.config"}/awesome
if [ -e "$CONFDIR" ]; then
if [ ! -d $CONFDIR ]; then
echo "$CONFDIR is not a directory"
return 1
fi
else
mkdir -p "$CONFDIR"
fi
for f in $FILES; do
if include $f; then
symlinkit "$RDIR/$f" "$CONFDIR/$f"
fi
done
symlinkit "$(pwd)/$1" "$CONFDIR/per-box.lua"