55 lines
1.4 KiB
Bash
Executable File
55 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
SCRIPTNAME=update-nutools
|
|
TMPSCRIPT="/tmp/$SCRIPTNAME"
|
|
PRIV_REPO=http://vcs.univ.run/anongit/modules/nutools.git
|
|
PUB_REPO=http://vcs.univ-reunion.fr/anongit/modules/nutools.git
|
|
NAME=nutools
|
|
|
|
################################################################################
|
|
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
|
|
else
|
|
REPO="$PUB_REPO"
|
|
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"
|
|
fi
|
|
|
|
if [ $# -ne 1 -o "$1" != --do-update ]; then
|
|
cp "$0" "$TMPSCRIPT"
|
|
chmod 755 "$TMPSCRIPT"
|
|
exec bash "$TMPSCRIPT" --do-update
|
|
fi
|
|
|
|
cd /tmp
|
|
rm -rf "$NAME"
|
|
git clone "$REPO" || exit 1
|
|
cd "$NAME"
|
|
if ! diff -q "$SCRIPTNAME" "$0"; then
|
|
echo "NOTE: Le script $SCRIPTNAME a été mis à jour. Il va être relancé."
|
|
exec bash "./$SCRIPTNAME"
|
|
fi
|
|
bash ./uinst -y || exit 1
|
|
cd ..
|
|
rm -rf "$NAME"
|
|
rm "$0"; exit 0
|