forked from ccollicutt/docker-swift-onlyone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartmain.sh
83 lines (65 loc) · 3.05 KB
/
startmain.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
#!/bin/bash
#
# Make the rings if they don't exist already
#
# These can be set with docker run -e VARIABLE=X at runtime
SWIFT_PART_POWER=${SWIFT_PART_POWER:-7}
SWIFT_PART_HOURS=${SWIFT_PART_HOURS:-1}
SWIFT_REPLICAS=${SWIFT_REPLICAS:-1}
if [ -e /srv/account.builder ]; then
echo "Ring files already exist in /srv, copying them to /etc/swift..."
cp /srv/*.builder /etc/swift/
cp /srv/*.gz /etc/swift/
fi
# This comes from a volume, so need to chown it here, not sure of a better way
# to get it owned by Swift.
if [ ! -e /srv/node ]; then
mkdir /srv/node
fi
chown -R swift:swift /srv
if [ ! -e /etc/swift/account.builder ]; then
cd /etc/swift
# 2^& = 128 we are assuming just one drive
# 1 replica only
echo "No existing ring files, creating them..."
swift-ring-builder object.builder create ${SWIFT_PART_POWER} ${SWIFT_REPLICAS} ${SWIFT_PART_HOURS}
swift-ring-builder object.builder add r1z1-127.0.0.1:6010/sdb1 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create ${SWIFT_PART_POWER} ${SWIFT_REPLICAS} ${SWIFT_PART_HOURS}
swift-ring-builder container.builder add r1z1-127.0.0.1:6011/sdb1 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create ${SWIFT_PART_POWER} ${SWIFT_REPLICAS} ${SWIFT_PART_HOURS}
swift-ring-builder account.builder add r1z1-127.0.0.1:6012/sdb1 1
swift-ring-builder account.builder rebalance
# Back these up for later use
echo "Copying ring files to /srv to save them if it's a docker volume..."
cp *.gz /srv
cp *.builder /srv
fi
# If you are going to put an ssl terminator in front of the proxy, then I believe
# the storage_url_scheme should be set to https. So if this var isn't empty, set
# the default storage url to https.
if [ ! -z "${SWIFT_STORAGE_URL_SCHEME}" ]; then
echo "Setting default_storage_scheme to https in proxy-server.conf..."
sed -i -e "s/storage_url_scheme = default/storage_url_scheme = https/g" /etc/swift/proxy-server.conf
grep "storage_url_scheme" /etc/swift/proxy-server.conf
fi
if [ ! -z "${SWIFT_USER_PASSWORD}" ]; then
echo "Setting passwords in /etc/swift/proxy-server.conf"
PASS=`pwgen 12 1`
sed -i -e "s/user_admin_admin = admin .admin .reseller_admin/user_admin_admin = ${SWIFT_USER_PASSWORD} .admin .reseller_admin/g" /etc/swift/proxy-server.conf
sed -i -e "s/user_test_tester = testing .admin/user_test_tester = ${SWIFT_USER_PASSWORD} .admin/g" /etc/swift/proxy-server.conf
sed -i -e "s/user_test2_tester2 = testing2 .admin/user_test2_tester2 = ${SWIFT_USER_PASSWORD} .admin/g" /etc/swift/proxy-server.conf
sed -i -e "s/user_test_tester3 = testing3/user_test_tester3 = ${SWIFT_USER_PASSWORD}/g" /etc/swift/proxy-server.conf
grep "user_test" /etc/swift/proxy-server.conf
fi
# Start supervisord
echo "Starting supervisord..."
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
#
# Tail the log file for "docker log $CONTAINER_ID"
#
# sleep waiting for rsyslog to come up under supervisord
sleep 3
echo "Starting to tail /var/log/syslog...(hit ctrl-c if you are starting the container in a bash shell)"
tail -n 0 -f /var/log/syslog