-
Notifications
You must be signed in to change notification settings - Fork 0
/
sumirror.sh
50 lines (40 loc) · 1.38 KB
/
sumirror.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env bash
# pull software update server content
# @author Filipp Lepalaan <filipp@mcare.fi>
# @package mtk
if [[ $# -lt 4 ]]
then
echo "usage: $(basename $0) server repo port destination" 2>&1
exit 1
fi
MAC_SERVER=$1
REMOTE_REPO=$2
REMOTE_PORT=$3
LOCAL_DOCROOT=$4
HOSTNAME=$(hostname)
if [[ ! -d "${LOCAL_DOCROOT}" ]];
then
echo "Invalid local document root: ${LOCAL_DOCROOT}" 2>&1
exit 1
fi
# download latest update packages, removing deprecated
rsync -av --delete rsync://${MAC_SERVER}:${REMOTE_PORT}/${REMOTE_REPO} ${LOCAL_DOCROOT}
if [[ ! $? ]]
then
echo "Failed to fetch software update content" 2>&1
exit 1
fi
# update hostnames in catalog files
find ${LOCAL_DOCROOT} -name *.sucatalog -type f -exec sed -i '' "s/${MAC_SERVER}:8088/${HOSTNAME}/g" {} \;
# rebuild symlinks
cd ${LOCAL_DOCROOT}
rm ./index*
ln -s ./content/catalogs/others/index-leopard-snowleopard.merged-1.sucatalog ./index-leopard-snowleopard.merged-1.sucatalog
ln -s ./content/catalogs/others/index-leopard.merged-1.sucatalog ./index-leopard.merged-1.sucatalog
ln -s ./content/catalogs/index.sucatalog ./index.sucatalog
# 10.4 seems to need this
ln -s ./content/catalogs/index.sucatalog ./content/catalogs/index-1.sucatalog
# One more hack for 10.4
mkdir ${LOCAL_DOCROOT}/scanningpoints
curl -o ${LOCAL_DOCROOT}/scanningpoints/scanningpointX.xml http://17.250.248.95/scanningpoints/scanningpointX.xml
exit 0