4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 #Part power, replica and hour as env
19 if [ $1 == "BACKEND_BUILDER" ]; then
20 echo "Remove unnecessary pid file"
21 rm -rf /var/run/rsyncd/rsyncd.pid
24 file_names="/etc/swift/account-server.conf /etc/swift/container-server.conf /etc/swift/object-server.conf /etc/swift/proxy-server.conf /etc/swift/rsyncd.conf /etc/swift/swift.conf /etc/swift/memcached"
25 /usr/bin/wait-for-files "${file_names}"
26 rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
28 if [ ! -e /etc/swift/account.ring.gz ]; then
30 echo "Ring files not found. Create them..."
31 # get ports from the config files
32 SWIFT_ACCOUNT_PORT=`grep "bind_port" /etc/swift/account-server.conf | awk '{print $3}'`
33 SWIFT_CONTAINER_PORT=`grep "bind_port" /etc/swift/container-server.conf | awk '{print $3}'`
34 SWIFT_OBJECT_PORT=`grep "bind_port" /etc/swift/object-server.conf | awk '{print $3}'`
36 swift-ring-builder account.builder create ${SWIFT_PART_POWER} ${SWIFT_REPLICAS} ${SWIFT_PART_HOUR}
37 swift-ring-builder container.builder create ${SWIFT_PART_POWER} ${SWIFT_REPLICAS} ${SWIFT_PART_HOUR}
38 swift-ring-builder object.builder create ${SWIFT_PART_POWER} ${SWIFT_REPLICAS} ${SWIFT_PART_HOUR}
40 for IP in ${SWIFT_OAM1_IP} ${SWIFT_OAM2_IP} ${SWIFT_OAM3_IP}; do
41 swift-ring-builder account.builder add r1z2-$IP:${SWIFT_ACCOUNT_PORT}/${SWIFT_DISK} 10
42 swift-ring-builder container.builder add r1z2-$IP:${SWIFT_CONTAINER_PORT}/${SWIFT_DISK} 10
43 swift-ring-builder object.builder add r1z2-$IP:${SWIFT_OBJECT_PORT}/${SWIFT_DISK} 10
44 echo "swift-ring-builder object.builder add r1z2-$IP:6000/${SWIFT_DISK} 10"
47 swift-ring-builder account.builder
48 swift-ring-builder container.builder
49 swift-ring-builder object.builder
51 swift-ring-builder account.builder rebalance
52 swift-ring-builder container.builder rebalance
53 swift-ring-builder object.builder rebalance
56 exec /usr/bin/supervisord -c /etc/supervisord.conf