summaryrefslogtreecommitdiff
path: root/bin/load.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/load.sh')
-rwxr-xr-xbin/load.sh35
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