-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-piuparts-setup
executable file
·145 lines (129 loc) · 3.4 KB
/
update-piuparts-setup
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh
set -e
#
# update piuparts setup on piatti.debian.org
#
# Copyright 2009-2012 Holger Levsen ([email protected])
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
if [ "`id -n -u`" != "piupartss" ] ; then
echo please run this script as piupartss user
exit 1
fi
PIUPARTS_PREFIX=/org/piuparts.debian.org
PIUPARTS_HTDOCS=$PIUPARTS_PREFIX/htdocs
PIUPARTS_TMPDIR=$PIUPARTS_PREFIX/tmp
# please cleanup yourself
cd
if [ -d piatti ] ; then
echo please rm ~/piatti manually
fi
#
# create $PIUPARTS_PREFIX
#
if [ ! -d $PIUPARTS_PREFIX ] ; then
sudo mkdir -p $PIUPARTS_PREFIX
sudo chown piupartss:piuparts $PIUPARTS_PREFIX
sudo chmod 0775 $PIUPARTS_PREFIX
fi
#
# update source
#
if [ ! -d $PIUPARTS_PREFIX/src ] ; then
mkdir -p $PIUPARTS_PREFIX/src
chmod 0755 $PIUPARTS_PREFIX/src
cd $PIUPARTS_PREFIX/src
git clone git://git.debian.org/git/piuparts/piuparts.git
cd piuparts
git checkout develop
fi
cd $PIUPARTS_PREFIX/src/piuparts
pwd
# git checkout branch if $1 is given
if [ ! -z "$1" ] ; then
git checkout $1
fi
# git fetch+pull if $2 is given
if [ ! -z "$2" ] ; then
git fetch $2
git pull $2 $1
fi
#
# install everything from GIT into PIUPARTS_PREFIX
#
make prefix=$PIUPARTS_PREFIX \
build build-doc
sudo make prefix=$PIUPARTS_PREFIX \
docdir=$PIUPARTS_HTDOCS/doc \
htdocsdir=$PIUPARTS_HTDOCS \
install install-doc install-conf-4-running-from-git
make clean
#
# install copies of the weather icons
# to avoid needing FollowSymlinks in the apache config
#
for icon in weather-severe-alert.png sunny.png
do
if [ -h $PIUPARTS_HTDOCS/images/$icon ] ; then
sudo rm -f $PIUPARTS_HTDOCS/images/$icon
fi
if [ -e /usr/share/icons/Tango/24x24/status/$icon ] ; then
sudo cp -f /usr/share/icons/Tango/24x24/status/$icon $PIUPARTS_HTDOCS/images/$icon
fi
done
#
# update $PIUPARTS_PREFIX
#
cd $PIUPARTS_PREFIX
pwd
mkdir -p master slave slave/basetgz backup
sudo chown piupartss:piuparts slave slave/basetgz
sudo chown piupartsm:piuparts master htdocs backup
# to support multiple hosts with this setup
cd $PIUPARTS_PREFIX/etc/piuparts
pwd
sudo chown piupartss:piuparts . piuparts.conf.*
chmod 0664 piuparts.conf.*
HOSTNAME=$(hostname)
for f in piuparts.conf forward
do
ln -sf $f.$HOSTNAME $f
done
#
# create working dir
#
mkdir -p $PIUPARTS_TMPDIR
#
# update slave home
#
cd
pwd
test ! -L bin || rm bin
test ! -d bin || mv bin bin.old
ln -sf $PIUPARTS_PREFIX/share/piuparts/slave bin
cp $PIUPARTS_PREFIX/etc/piuparts/forward .forward
crontab $PIUPARTS_PREFIX/etc/piuparts/crontab-slave
#
# update master home
#
ssh piupartsm@localhost "
set -e
test ! -L bin || rm bin
test ! -d bin || mv bin bin.old
ln -sf $PIUPARTS_PREFIX/share/piuparts/master bin
cp $PIUPARTS_PREFIX/etc/piuparts/forward .forward
crontab $PIUPARTS_PREFIX/etc/piuparts/crontab-master
"
echo "Update finished."