-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy-functions.sh
96 lines (71 loc) · 1.85 KB
/
deploy-functions.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# These are helper functions for deploy.sh
# (c) 2008-2011, Michael Renner
check_settings() {
if [ "${ADMINADDR+set}" != set ]; then
echo "ADMINADDR is not set. Please check '$CONFIGFILE'"
exit 1
fi
if [ "${RECURSOR+set}" != set ]; then
echo "RECURSOR is not set. Please check '$CONFIGFILE'"
exit 1
fi
if [ "${SMARTHOST+set}" != set ]; then
echo "SMARTHOST is not set. Please check '$CONFIGFILE'"
exit 1
fi
if [ "${DEPLOYTEMPLATE+set}" != set ]; then
echo "DEPLOYTEMPLATE is not set. Please check '$CONFIGFILE'"
exit 1
fi
if [ "${DEBMIRROR+set}" != set ]; then
echo "DEBMIRROR is not set. Please check '$CONFIGFILE'"
exit 1
fi
if [ "${DEBARCH+set}" != set ]; then
echo "DEBARCH is not set. Please check '$CONFIGFILE'"
exit 1
fi
}
prompt_user() {
read safetypin
if [ "$safetypin" != "y" ]; then
echo "Aborting at your discretion"
exit 1
fi
}
check_rc() {
RC=$?
if [ $RC -ne 0 ]; then
echo "Failed in $1, RC was $RC. Bailing out"
exit 1
fi
}
fetch_vz_setting() {
VZCONFVALUE=`grep -m1 ^$1= $VZCONF | cut -f2- -d"="`
}
create_template() {
fetch_vz_setting "TEMPLATE"
TEMPLATEDIR=$VZCONFVALUE
TARGETFILE=$TEMPLATEDIR/cache/$DEPLOYTEMPLATE.tar.gz
if [ -f $TARGETFILE ]; then
echo "$TARGETFILE already exists. Skipping template creation."
return
fi
TEMPDIR=`mktemp -d` || exit 1
TEMPFILE=`mktemp` || exit 1
# We need a file in the tarball since vzcreate barfs on empty tarballs
touch $TEMPDIR/BOOTSTRAPPED
tar -zc -C $TEMPDIR . -f $TEMPFILE
mv $TEMPFILE $TARGETFILE
rm $TEMPDIR/BOOTSTRAPPED
rmdir $TEMPDIR
}
create_dist() {
SOURCEFILE=$VZCONFDIR/dists/debian.conf
TARGETFILE=$VZCONFDIR/dists/$DEPLOYTEMPLATE.conf
if [ -f $TARGETFILE ]; then
echo "$TARGETFILE already exists. Skipping dists creation."
return
fi
cp $SOURCEFILE $TARGETFILE
}