2013-10-24 16:03:50 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
|
2013-10-28 14:33:14 +04:00
|
|
|
SCRIPTNAME=update-nutools
|
|
|
|
TMPSCRIPT="/tmp/$SCRIPTNAME"
|
2013-12-04 16:31:04 +04:00
|
|
|
PRIV_REPO=http://vcs.univ.run/anongit/modules/nutools.git
|
|
|
|
PUB_REPO=http://vcs.univ-reunion.fr/anongit/modules/nutools.git
|
2013-10-24 16:03:50 +04:00
|
|
|
NAME=nutools
|
|
|
|
|
2013-12-04 16:39:52 +04:00
|
|
|
################################################################################
|
|
|
|
CURL="$(which curl 2>/dev/null)"
|
|
|
|
WGET="$(which wget 2>/dev/null)"
|
|
|
|
if [ -n "$NUTOOLS_REPO" ]; then
|
|
|
|
REPO="$NUTOOLS_REPO"
|
|
|
|
elif [ -n "$CURL" ]; then
|
|
|
|
if curl -fs "$PRIV_REPO" >&/dev/null; then
|
|
|
|
REPO="$PRIV_REPO"
|
|
|
|
else
|
|
|
|
REPO="$PUB_REPO"
|
|
|
|
fi
|
|
|
|
elif [ -n "$WGET" ]; then
|
|
|
|
if wget -q -O - "$PRIV_REPO" >&/dev/null; then
|
|
|
|
REPO="$PRIV_REPO"
|
|
|
|
else
|
|
|
|
REPO="$PUB_REPO"
|
|
|
|
fi
|
2013-12-04 16:31:04 +04:00
|
|
|
else
|
|
|
|
REPO="$PUB_REPO"
|
2013-12-04 16:39:52 +04:00
|
|
|
echo "\
|
|
|
|
WARN: impossible de déterminer la source pour la mise à jour.
|
|
|
|
sélection de l'adresse publique $PUB_REPO"
|
|
|
|
echo "\
|
|
|
|
NOTE: si une erreur se produit, utiliser l'adresse privée, e.g.
|
|
|
|
NUTOOLS_REPO=$PRIV_REPO $0"
|
2013-12-04 16:31:04 +04:00
|
|
|
fi
|
|
|
|
|
2013-12-28 10:47:01 +04:00
|
|
|
scriptdir="$(dirname "$0")"
|
|
|
|
if [ $# -ne 2 -o "$1" != --do-update ]; then
|
2013-10-28 14:33:14 +04:00
|
|
|
cp "$0" "$TMPSCRIPT"
|
2013-10-24 16:03:50 +04:00
|
|
|
chmod 755 "$TMPSCRIPT"
|
2013-12-28 10:47:01 +04:00
|
|
|
exec bash "$TMPSCRIPT" --do-update "$scriptdir"
|
|
|
|
fi
|
|
|
|
|
|
|
|
scriptdir="$2"
|
|
|
|
clonerepo=
|
|
|
|
if [ -z "$NUTOOLS_UPDATE_REPO" -a -f "$scriptdir/.nutools-devel" -a -d "$scriptdir/.git" ]; then
|
|
|
|
echo "NOTE: tentative de mise à jour du dépôt local"
|
|
|
|
cd "$scriptdir"
|
|
|
|
git pull || clonerepo=1
|
|
|
|
else
|
|
|
|
clonerepo=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$clonerepo" ]; then
|
|
|
|
echo "NOTE: clonage du dépôt distant $REPO"
|
|
|
|
cd /tmp
|
|
|
|
rm -rf "$NAME"
|
|
|
|
git clone "$REPO" || exit 1
|
|
|
|
cd "$NAME"
|
2013-10-24 16:03:50 +04:00
|
|
|
fi
|
2013-10-28 13:02:41 +04:00
|
|
|
|
2013-10-28 14:33:14 +04:00
|
|
|
if ! diff -q "$SCRIPTNAME" "$0"; then
|
2013-12-04 16:31:04 +04:00
|
|
|
echo "NOTE: Le script $SCRIPTNAME a été mis à jour. Il va être relancé."
|
2013-10-28 14:33:14 +04:00
|
|
|
exec bash "./$SCRIPTNAME"
|
2013-10-28 13:02:41 +04:00
|
|
|
fi
|
|
|
|
bash ./uinst -y || exit 1
|
2013-12-28 10:47:01 +04:00
|
|
|
|
|
|
|
if [ -n "$clonerepo" ]; then
|
|
|
|
cd ..
|
|
|
|
rm -rf "$NAME"
|
|
|
|
fi
|
|
|
|
rm "$0"; exit 0
|