Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 116 lines (99 sloc) 1.87 KB
#!/bin/ksh
HOST=$(hostname -s || hostname)
OS=$(uname -s)
WD=$(pwd)
RED="\033[1;31m"
GREEN="\033[32m"
WHITE="\033[0;39m"
setup_flag=false
verbose=false
while getopts ":svh" opt; do
case "$opt" in
s)
setup_flag=true
;;
v)
verbose=true
;;
h)
echo "Usage:\n\t-s for setup\n\t-v for verbose"
exit
;;
esac
done
# need something to install git if it's not there.. some kinda package
# wrapper that works with apt/dpkg and pkg_add stuff
git submodule init
git submodule update
function log {
if [ $verbose = true ]; then
echo $1
fi
}
function lnk {
log "$GREEN ln -s $1 $2 $WHITE"
ln -s $1 $2
}
function srm {
log "$RED rm $1 $WHITE"
if [ -L $1 ]; then
if [[ $OS = "OpenBSD" ]]; then
rm $1
else
unlink $1
fi
else
rm $1
fi
}
function link_file {
if [[ -e $2 ]] || [[ -L $2 ]]; then
if [ $setup_flag = true ]; then
diff -q $2 $1
if [ "$?" -ne "0" ]; then
vimdiff $2 $1
else
echo -n "$2 already in place, but is the same. Remove and crate symlink? (y/yes) "
read ANS
if [[ $ANS = "y" || $ANS = "yes" ]]; then
srm $2
lnk $1 $2
else
exit
fi
fi
else
srm $2
lnk $1 $2
fi
else
lnk $1 $2
fi
}
function dotify {
echo $(echo $1 | sed -e 's/^dot_/\./');
}
for file in $(ls common); do
link_file $WD/common/$file ~/$(dotify $file)
done
if [ -d $HOST ]; then
for file in $(ls $HOST); do
if [ "$file" == "config" ]; then
for cfile in $(ls $HOST/$file); do
link_file $WD/$HOST/$file/$cfile ~/.config/$cfile
done
else
link_file $WD/$HOST/$file ~/$(dotify $file)
fi
done
#else
#for file in $(ls default); do
# link_file $WD/default/$file ~/$(dotify $file)
#done
fi
if [ ! -e ~/bin ]; then
mkdir ~/bin
fi
for file in $(ls bin); do
link_file $WD/bin/$file ~/bin/$file
done