summaryrefslogtreecommitdiff
path: root/bin/load.sh
blob: 6dc7deb441235f0009053137df41fd4e19ad3490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

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