4
FORMULA_DIR=$(dirname $0)
5
CHARM_DIR=$(dirname $0)
7
echo $JUJU_UNIT_NAME >>/tmp/unit_name
9
if [[ -e $FORMULA_DIR/swift-storage-node-common ]] ; then
10
. $FORMULA_DIR/swift-storage-node-common
8
if [[ -e $CHARM_DIR/swift-storage-node-common ]] ; then
9
. $CHARM_DIR/swift-storage-node-common
12
echo "ERROR: Could not load swift-storage-node-common from $FORMULA_DIR"
11
echo "ERROR: Could not load swift-storage-node-common from $CHARM_DIR"
15
14
function install_hook {
16
### CANONICAL-SPECIFIC BEGIN ###
17
# MAAS preseed is forcing apt to proxy through the deb caching proxy
18
# on the MAAS server. This is preventing us from getting to
19
# cloud-archive. Stop it.
20
rm -f /etc/apt/apt.conf
21
### CANONICAL-SPECIFIC END ###
23
15
apt-get -y --force-yes install python-software-properties || exit 1
17
configure_install_source "$OPENSTACK_ORIGIN"
26
for i in $PACKAGES ; do
27
DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install $i
20
DEBIAN_FRONTEND=noninteractive apt-get -y \
21
install --no-install-recommends $PACKAGES || exit 1
29
23
[[ ! -d /etc/swift ]] && mkdir /etc/swift
30
24
chown swift:swift /etc/swift
26
swift-init all stop || true
33
for i in account container object ; do create_server_conf $i ; done
28
for i in account container object ; do
29
port=$(config-get ${i}-server-port)
30
create_server_conf $i "$port"
36
function proxy_joined {
38
for DEVICE in $DEVICES; do
39
SRVNODENAME="$(echo $DEVICE | sed 's/[\/:]/-/g')"
40
if [ -n "$RELDEVICES" ]; then
41
RELDEVICES="$RELDEVICES:$SRVNODENAME"
34
function storage_joined {
35
local devs=$(determine_block_devs)
38
local srvnodename=$(basename $dev)
39
if [[ -n "$reldevices" ]] ; then
40
reldevices="$reldevices:$srvnodename"
43
RELDEVICES="$SRVNODENAME"
42
reldevices="$srvnodename"
46
relation-set zone=1 hostname=$(unit-get private-address) device=$RELDEVICES
45
relation-set zone="$(config-get zone)" \
46
device="$reldevices" \
47
object_port="$(config-get object-server-port)" \
48
container_port="$(config-get container-server-port)" \
49
account_port="$(config-get account-server-port)"
49
function proxy_changed {
50
URL=`relation-get update_url`
51
SWIFT_HASH=`relation-get swift_hash`
52
[[ -z $URL ]] || [[ -z $SWIFT_HASH ]] && exit 0
53
echo "$URL" >>/tmp/url
54
rm -rf /etc/swift/*.gz
52
function storage_changed {
53
local www_dir=`relation-get www_dir`
54
local swift_hash=`relation-get swift_hash`
55
[[ -z $www_dir ]] || [[ -z $swift_hash ]] && exit 0
57
set_swift_hash $swift_hash
58
local url="http://$(relation-get private-address)/$www_dir"
55
59
for i in account object container ; do
57
echo "Fetching $URL/$i.ring.gz"
60
echo "Fetching $www_dir/$i.ring.gz"
61
wget "$url/$i.ring.gz" -O /etc/swift/$i.ring.gz
60
set_swift_hash $SWIFT_HASH
63
set_swift_hash $swift_hash
61
64
chown swift -R /etc/swift
65
swift-init all start || true
66
69
"install") install_hook ;;
67
70
"start"|"stop") exit 0 ;;
68
"swift-proxy-relation-joined") proxy_joined ;;
69
"swift-proxy-relation-changed") proxy_changed ;;
71
"swift-storage-relation-joined") storage_joined ;;
72
"swift-storage-relation-changed") storage_changed ;;