diff options
| author | David Kaufmann <astra@ionic.at> | 2017-04-26 01:41:50 +0200 |
|---|---|---|
| committer | David Kaufmann <astra@ionic.at> | 2017-04-26 01:41:50 +0200 |
| commit | d7ff0b69b9bd0794bf946f77f97f9f01272a2086 (patch) | |
| tree | e2c12d3f278ef6edb846be4a37d6ed7dd44e920e /bin/load.sh | |
| parent | f4dd7a1c32211e8412c276d33483eed4109a6789 (diff) | |
| download | config-d7ff0b69b9bd0794bf946f77f97f9f01272a2086.tar.gz | |
restructure update
Diffstat (limited to 'bin/load.sh')
| -rwxr-xr-x | bin/load.sh | 35 |
1 files changed, 24 insertions, 11 deletions
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 |
