From d7ff0b69b9bd0794bf946f77f97f9f01272a2086 Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Wed, 26 Apr 2017 01:41:50 +0200 Subject: restructure update --- bin/load.sh | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'bin/load.sh') diff --git a/bin/load.sh b/bin/load.sh index e2487df..6dc7deb 100755 --- a/bin/load.sh +++ b/bin/load.sh @@ -1,21 +1,34 @@ #!/bin/bash -WGET=$(which wget) URL="http://pluto.fsinf.at/~astra/config/" FILE="skel.tar.gz" -CLEAN=".vim" -cd ~ +cd ${HOME} # fetch file from server -$WGET -q "${URL}${FILE}" +TMP=`mktemp -u --suffix=".tar.gz" "config-updater-XXXXXX"` +curl -L -s "${URL}${FILE}" -o $TMP -if [ "$1" == "clean" ]; then - for i in $CLEAN - do - rm -rf $i - done +# check if file exists and is not empty +if [ -e $TMP ]; then + if [ -s $TMP ]; then + # run pre-update commands if file exists + if [ -r ${HOME}/var/system/config-updater/pre-update ]; then + . ${HOME}/var/system/config-updater/pre-update + fi + + # unpack new structure + tar -xzf $TMP --strip-components=1 + + # run post-update commands if file exists + if [ -r ${HOME}/var/system/config-updater/post-update ]; then + . ${HOME}/var/system/config-updater/post-update + fi + else + echo "Could not fetch updated config, $TMP is empty" + fi +else + echo "Could not fetch updated config, $TMP is missing" fi -tar -xzf $FILE --strip-components=1 -rm $FILE +rm -f $TMP -- cgit v1.2.3