Commit Diff
Diff:
724c6212efe2c1b570a095eaf083300536bde790
afbbeef6d1d01b29e62fdcc1226f32396eb1a48a
Commit:
afbbeef6d1d01b29e62fdcc1226f32396eb1a48a
Tree:
99e0cbca18153773691f52971df57fb2b90fbd12
Author:
Fred. Galusik <f@galusik.xyz>
Committer:
Fred. Galusik <f@galusik.xyz>
Date:
Sun Sep 11 11:24:19 2016 UTC
Message:
Merge branch 'master' into 'master' Master Petite fonction qui vérifie si une version plus récente de snaps est disponible. Fonction de mise à jour incluse. See merge request !3
blob - 39e835404e44c27ad31bcfdd36ef3a204924c94a
blob + e191d0f65fb03e3c4173807ac9dae620a003649e
--- snaps
+++ snaps
@@ -63,10 +63,36 @@ REBOOT='/sbin/reboot'
LOGF=/var/log/snaps.log
NOW=$(date "+ %Y-%m-%d %R")
+REMOTESNAPS='https://framagit.org/fredg/snaps/raw/master/snaps'
+LASTSNAPS=/tmp/snaps
###
###
###
+toupgrade() {
+ echo "Checking for new version..."
+ $GET -V -o "$LASTSNAPS" "$REMOTESNAPS"
+ REMOTEVERSION=$(grep "VERSION=" "$LASTSNAPS" | cut -d'=' -f2)
+
+ if [ $? -eq 0 ]; then
+
+ if [ "$VERSION" != "$REMOTEVERSION" ]; then
+ echo "---"
+ echo "This is not the last version of snaps".
+ echo "Last version : $REMOTEVERSION"
+ echo "To upgrade, run 'snaps -u'"
+ echo "---"
+ fi
+ fi
+}
+
+upgrade() {
+ SELFPATH=$(readlink -f $0)
+ echo "Downloading last snaps version"
+ $GET -o "$SELFPATH" "$REMOTESNAPS"
+}
+
+
usage() {
echo "${0##*/} $VERSION"
echo "Usage: ${0##*/} [-gGlh]"
@@ -74,6 +100,7 @@ usage() {
echo " -G fetch, check and install bsd.rd from \$MIRROR"
echo " -p update port tree to current"
echo " -l list date and \$MIRROR of 3 last bsd.rd"
+ echo " -u upgrade snaps to last version"
echo " -h print this help and exit"
echo ""
echo "MIRROR is based upon /etc/pkg.conf and set to: $MIRROR"
@@ -194,6 +221,7 @@ s_upports() {
##
## Run
##
+toupgrade
case $1 in
-g)
get_rd
@@ -212,6 +240,9 @@ case $1 in
-l)
get_log
;;
+ -u)
+ upgrade
+ ;;
-h|*)
usage
exit 1
Frédéric Galusik