Add options to install.sh: help, install, copy, remove, update
This commit is contained in:
parent
3371af9f21
commit
81471913ae
53
install.sh
53
install.sh
@ -8,19 +8,61 @@ else
|
||||
fi
|
||||
DESTINATION=~
|
||||
|
||||
if [ "$1" == "install" ] || [ "$1" == "link" ] || [ "$1" == "links" ]
|
||||
then
|
||||
REMOVE=1
|
||||
BIN="ln -s"
|
||||
elif [ "$1" == "update" ]
|
||||
then
|
||||
cd $SOURCE
|
||||
git pull `git remote -v | head -n 1 | cut -f 1` &&
|
||||
git submodule init && git submodule update
|
||||
exit $?
|
||||
elif [ "$1" == "remove" ] || [ "$1" == "uninstall" ]
|
||||
then
|
||||
REMOVE=0
|
||||
BIN="rm"
|
||||
elif [ "$1" == "copy" ]
|
||||
then
|
||||
REMOVE=1
|
||||
BIN="cp -r"
|
||||
else
|
||||
echo -e "\e[01mNemunaire's configuration\e[0m"
|
||||
echo -e " Author:\t\tNemunaire <nemunaire@pomail.fr>"
|
||||
echo -e " Original source:\thttps://git.nemunai.re/?p=conf.git"
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo " $0 install"
|
||||
echo " Create symbolic links from this directory to your home"
|
||||
echo " $0 remove"
|
||||
echo " Remove symbolic links from your home"
|
||||
echo " $0 update"
|
||||
echo " Pull last commits from the server from" `git remote -v | head -n 1 | cut -f 2`
|
||||
echo " $0 copy"
|
||||
echo " Copy configuration files instead of make links"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd $SOURCE
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
#BIN="cp -r"
|
||||
BIN="ln -s"
|
||||
|
||||
TMPERR=`mktemp`
|
||||
for f in `ls -a $SOURCE`
|
||||
do
|
||||
if [ "$f" != "." ] && [ "$f" != ".." ] &&
|
||||
if [ "$f" != "." ] && [ "$f" != ".." ] && [ "$f" != ".git" ] &&
|
||||
[ "$f" != ".gitmodules" ] && [ "$f" != "install.sh" ]
|
||||
then
|
||||
if [ $REMOVE -eq 0 ]; then
|
||||
echo -ne "Removing $f ...\t"
|
||||
if [ -L $DESTINATION/$f ]; then
|
||||
$BIN $DESTINATION/$f >&2 2> $TMPERR
|
||||
if [ $? == 0 ]; then echo -e "done"; else echo -e "fail"; fi
|
||||
cat $TMPERR
|
||||
else
|
||||
echo -e "Not installed"
|
||||
fi
|
||||
else
|
||||
echo -ne "Installing $f ...\t"
|
||||
if [ ${#f} -lt 9 ]; then echo -en "\t"; fi
|
||||
if [ -L $DESTINATION/$f ]
|
||||
@ -28,11 +70,12 @@ do
|
||||
echo -e "Already installed"
|
||||
elif [ -e $DESTINATION/$f ]
|
||||
then
|
||||
echo -e "Already existing $f"
|
||||
echo -e "Already existing"
|
||||
else
|
||||
$BIN $SOURCE/$f $DESTINATION/$f >&2 2> $TMPERR
|
||||
if [ $? == 0 ]; then echo -e "done"; else echo -e "fail"; fi
|
||||
cat $TMPERR
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user