-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·47 lines (39 loc) · 1.18 KB
/
install.sh
File metadata and controls
executable file
·47 lines (39 loc) · 1.18 KB
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
#!/bin/bash
#
# Installs all dotfiles to the appropriate locations
# We don't want to rely on $PATH being set as this may be run as part of
# automatic system setup when enviroment variables are not present
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin/"
SCRIPT=$(readlink -f "$0")
SCRIPTDIR=$(dirname $SCRIPT)
# We don't want to rely on $HOME being set as this may be run as part of
# automatic system setup when enviroment variables are not present
#
# Hence we are going to detect the home directory of the user this script
# is being ran as, and install to there
TARGET=$(eval echo "~$(whoami)")
STOW_CMD='/usr/bin/stow'
if [ -f '/usr/bin/stowforce' ] ; then
STOW_CMD='/usr/bin/stowforce'
fi
#####################
# Helper to install files from a particular directory
install_from_dir () {
pushd ${1}
for d in `ls -d */`;
do
printf "Installing %32s : '${d}' to '${TARGET}'"
$STOW_CMD $d --target $TARGET
printf "Done\n"
done
popd
}
# Install common files
install_from_dir ${SCRIPTDIR}/config/common
# Install host specific files
HOSTDIR=${SCRIPTDIR}/config/$(hostname)
echo $HOSTDIR
if [ -d ${HOSTDIR} ] ; then
install_from_dir $HOSTDIR
fi
exit 0