diff options
| -rwxr-xr-x | bin/load.sh | 35 | ||||
| -rwxr-xr-x | bin/updateConfig.sh | 21 | ||||
| -rw-r--r--[-rwxr-xr-x] | home/bin/config-update.sh | 35 |
3 files changed, 26 insertions, 65 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 diff --git a/bin/updateConfig.sh b/bin/updateConfig.sh deleted file mode 100755 index ffa35e4..0000000 --- a/bin/updateConfig.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# goto root dir (this script resides in src) -BASEDIR=`dirname $(readlink -f $0)` -cd ${BASEDIR}/../ - -#ALLHOSTS=`cat ~/.ssh/config | egrep "^Host" | egrep -v "nohome|noshell|localnet|offline" | sed 's/^Host //' | sed 's/ #.*//' | tr '\n' ' ' | sed 's/ $//' ` -ALLHOSTS=`cat ~/.ssh/config | egrep "^Host" | egrep -v "nohome|noshell|noconfig|localnet|offline|\!|\*|\+" | sed 's/^Host \([^ ]*\).*/\1/'` -HOSTS=${HOSTS:-$ALLHOSTS} - -echo "loaded keys:" -ssh-add -l - -echo "updated hosts:" -echo $HOSTS - -echo "waiting 10 seconds" -sleep 10 - -echo "Run new load.sh" -pssh -i --host "$HOSTS" -t 120 "rm -f load.sh ; curl -s https://pluto.fsinf.at/~astra/config/load.sh | bash" diff --git a/home/bin/config-update.sh b/home/bin/config-update.sh index 6dc7deb..61bfabb 100755..100644 --- a/home/bin/config-update.sh +++ b/home/bin/config-update.sh @@ -1,34 +1,3 @@ -#!/bin/bash +#!/bin/sh -URL="http://pluto.fsinf.at/~astra/config/" -FILE="skel.tar.gz" - -cd ${HOME} - -# fetch file from server -TMP=`mktemp -u --suffix=".tar.gz" "config-updater-XXXXXX"` -curl -L -s "${URL}${FILE}" -o $TMP - -# 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 - -rm -f $TMP +curl -L -s https://pluto.fsinf.at/~astra/config/load.sh | sh |
