Improve install.sh look

This commit is contained in:
nemunaire 2014-06-25 11:59:56 +02:00
parent 8432243c92
commit 3d4e7145b5

View File

@ -12,11 +12,11 @@ if [ "$1" == "install" ] || [ "$1" == "link" ] || [ "$1" == "links" ]
then then
REMOVE=1 REMOVE=1
BIN="ln -s" BIN="ln -s"
elif [ "$1" == "update" ] elif [ "$1" == "update" ] || [ "$1" == "pull" ]
then then
cd $SOURCE cd $SOURCE
git pull `git remote -v | head -n 1 | cut -f 1` && git pull `git remote | head -n 1` &&
git submodule init && git submodule update git submodule init && git submodule update --recursive
exit $? exit $?
elif [ "$1" == "remove" ] || [ "$1" == "uninstall" ] elif [ "$1" == "remove" ] || [ "$1" == "uninstall" ]
then then
@ -27,54 +27,54 @@ then
REMOVE=1 REMOVE=1
BIN="cp -r" BIN="cp -r"
else else
echo -e "\e[01mNemunaire's configuration\e[0m" echo -e "\e[32;01mNemunaire's configuration \e[0;33m("`git branch --no-color | grep '*' | cut -d " " -f 2-`")\e[0m"
echo -e " Author:\t\tNemunaire <nemunaire@pomail.fr>" echo -e " \e[01mAuthor:\e[0m\t\t"`git log -1 --format="%aN <%aE>"`
echo -e " Original source:\thttps://git.nemunai.re/?p=conf.git" echo -e " \e[01mOriginal source:\e[0m\thttps://git.nemunai.re/?p=conf.git"
echo echo
echo "Usage:" echo -e "\e[01mUsage:\e[0m"
echo " $0 install" echo -e " $0 \e[36;01minstall\e[0m"
echo " Create symbolic links from this directory to your home" echo -e " Create symbolic links from this directory to your home"
echo " $0 remove" echo -e " $0 \e[36;01mremove\e[0m"
echo " Remove symbolic links from your home" echo -e " Remove symbolic links from your home"
echo " $0 update" echo -e " $0 \e[36;01mupdate\e[0m"
echo " Pull last commits from the server from" `git remote -v | head -n 1 | cut -f 2` echo -e " Pull latest commits from the server at" `git remote -v | head -n 1 | cut -f 2`
echo " $0 copy" echo -e " $0 \e[36;01mcopy\e[0m"
echo " Copy configuration files instead of make links" echo -e " Copy configuration files instead of making links"
exit 0 exit 0
fi fi
cd $SOURCE cd "$SOURCE"
git submodule init git submodule init &&
git submodule update git submodule update --recursive
TMPERR=`mktemp` TMPERR=`mktemp`
for f in `ls -a $SOURCE` for f in `ls -a "$SOURCE"`
do do
if [ "$f" != "." ] && [ "$f" != ".." ] && [ "$f" != ".git" ] && if [ "$f" != "." ] && [ "$f" != ".." ] && [ "$f" != ".git" ] &&
[ "$f" != ".gitmodules" ] && [ "$f" != "install.sh" ] [ "$f" != ".gitmodules" ] && [ "$f" != "install.sh" ]
then then
if [ $REMOVE -eq 0 ]; then if [ "$REMOVE" -eq 0 ]; then
echo -ne "Removing $f ...\t" echo -ne "Removing $f ...\t"
if [ -L $DESTINATION/$f ]; then if [ -L "$DESTINATION/$f" ]; then
$BIN $DESTINATION/$f >&2 2> $TMPERR $BIN "$DESTINATION/$f" >&2 2> "$TMPERR"
if [ $? == 0 ]; then echo -e "done"; else echo -e "fail"; fi if [ $? == 0 ]; then echo -e "\e[32mdone\e[0m"; else echo -e "\e[31;01mfail\e[0m"; fi
cat $TMPERR cat "$TMPERR"
else else
echo -e "Not installed" echo -e "Not installed"
fi fi
else else
echo -ne "Installing $f ...\t" echo -ne "Installing $f ...\t"
if [ ${#f} -lt 9 ]; then echo -en "\t"; fi if [ ${#f} -lt 9 ]; then echo -en "\t"; fi
if [ -L $DESTINATION/$f ] if [ -L "$DESTINATION/$f" ]
then then
echo -e "Already installed" echo -e "\e[36mAlready installed\e[0m"
elif [ -e $DESTINATION/$f ] elif [ -e "$DESTINATION/$f" ]
then then
echo -e "Already existing" echo -e "\e[35mAlready exists\e[0m"
else else
$BIN $SOURCE/$f $DESTINATION/$f >&2 2> $TMPERR $BIN "$SOURCE/$f" "$DESTINATION/$f" >&2 2> "$TMPERR"
if [ $? == 0 ]; then echo -e "done"; else echo -e "fail"; fi if [ $? == 0 ]; then echo -e "\e[32mdone\e[0m"; else echo -e "\e[31;01mfail\e[0m"; fi
cat $TMPERR cat "$TMPERR"
fi fi
fi fi
fi fi