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"
|
2018-11-15 09:40:06 +04:00
|
|
|
PRIV_REPO=http://vs-git.univ.run/modules/nutools
|
|
|
|
PUB_REPO=https://git.univ-reunion.fr/modules/nutools
|
2013-10-24 16:03:50 +04:00
|
|
|
NAME=nutools
|
|
|
|
|
2013-12-04 16:39:52 +04:00
|
|
|
################################################################################
|
2022-06-18 10:43:40 +04:00
|
|
|
eval "set -- $(getopt -n update-nutools -o dpx -l develop,public,use-proxy,do-update -- "$@" || echo exit 1)"
|
|
|
|
develop=
|
|
|
|
public=
|
|
|
|
use_proxy=
|
|
|
|
do_update=
|
|
|
|
while [ "$1" != -- ]; do
|
|
|
|
case "$1" in
|
|
|
|
--help)
|
|
|
|
echo "update-nutools: mettre à jour nutools
|
2016-11-28 17:43:34 +04:00
|
|
|
|
|
|
|
USAGE:
|
|
|
|
update-nutools [--develop]
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-d, --develop
|
|
|
|
Mettre à jour avec la branche develop pour avoir les dernières fonctions
|
|
|
|
qui ne sont pas encore stabilisées. Par défaut, la mise à jour est faite
|
2022-06-18 10:43:40 +04:00
|
|
|
avec la branche master.
|
|
|
|
-p, --public
|
|
|
|
Forcer l'utilisation de l'url publique"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-d|--develop)
|
|
|
|
develop=develop
|
|
|
|
;;
|
|
|
|
-p|--public)
|
|
|
|
public=1
|
|
|
|
NUTOOLS_REPO="$PUB_REPO"
|
|
|
|
;;
|
|
|
|
-x|--use-proxy)
|
|
|
|
use_proxy=1
|
|
|
|
;;
|
|
|
|
--do-update)
|
|
|
|
do_update=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
[ -n "$use_proxy" ] || export http_proxy=
|
|
|
|
|
|
|
|
if [ -z "$do_update" ]; then
|
|
|
|
scriptdir="$(dirname -- "$0")"
|
2016-04-27 03:34:32 +04:00
|
|
|
|
2022-06-18 10:43:40 +04:00
|
|
|
cp "$0" "$TMPSCRIPT"
|
|
|
|
chmod 755 "$TMPSCRIPT"
|
|
|
|
exec bash "$TMPSCRIPT" ${develop:+--develop} ${public:+--public} --do-update "$scriptdir"
|
|
|
|
fi
|
2015-07-17 22:01:59 +04:00
|
|
|
|
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
|
|
|
|
|
2022-06-18 10:43:40 +04:00
|
|
|
scriptdir="$1"
|
2013-12-28 10:47:01 +04:00
|
|
|
clonerepo=
|
2014-04-11 17:03:02 +04:00
|
|
|
if [ -z "$NUTOOLS_REPO" -a -f "$scriptdir/.nutools-devel" -a -d "$scriptdir/.git" ]; then
|
2013-12-28 10:47:01 +04:00
|
|
|
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"
|
2016-11-28 17:43:34 +04:00
|
|
|
git clone --depth 1 ${develop:+--branch "$develop"} "$REPO" || exit 1
|
2013-12-28 10:47:01 +04:00
|
|
|
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é."
|
2016-11-28 17:43:34 +04:00
|
|
|
exec bash "./$SCRIPTNAME" ${develop:+--develop}
|
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
|
2014-07-07 22:06:38 +04:00
|
|
|
# IMPORTANT: la ligne suivante ne doit pas se terminer par un retour à la ligne:
|
2013-12-28 10:47:01 +04:00
|
|
|
rm "$0"; exit 0
|