| ... | ... |
@@ -594,51 +594,56 @@ fi |
| 594 | 594 |
|
| 595 | 595 |
# Storage Service |
| 596 | 596 |
if [[ "$ENABLED_SERVICES" =~ "swift" ]];then |
| 597 |
- mkdir -p ${SWIFT_LOCATION}/drives
|
|
| 598 |
- local s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable
|
|
| 597 |
+ sudo mkdir -p ${SWIFT_LOCATION}/drives
|
|
| 598 |
+ sudo chown -R stack: ${SWIFT_LOCATION}/drives
|
|
| 599 |
+ s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable
|
|
| 599 | 600 |
|
| 600 | 601 |
# Create a loopback disk and format it with XFS. |
| 601 | 602 |
if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then
|
| 603 |
+ sudo touch ${SWIFT_LOCATION}/swift-disk
|
|
| 604 |
+ sudo chown stack: ${SWIFT_LOCATION}/swift-disk
|
|
| 605 |
+ |
|
| 602 | 606 |
dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
|
| 603 | 607 |
mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk
|
| 604 | 608 |
fi |
| 605 | 609 |
|
| 606 | 610 |
# Add the mountpoint to fstab |
| 607 | 611 |
if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then
|
| 608 |
- echo "# Added by devstack" | tee -a /etc/fstab |
|
| 612 |
+ echo "# Added by devstack" | sudo tee -a /etc/fstab |
|
| 609 | 613 |
echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \
|
| 610 |
- tee -a /etc/fstab |
|
| 614 |
+ sudo tee -a /etc/fstab |
|
| 611 | 615 |
fi |
| 612 | 616 |
|
| 613 | 617 |
# Create and mount drives. |
| 614 | 618 |
mkdir -p ${s}
|
| 615 |
- mount ${s}
|
|
| 616 |
- mkdir ${s}/{1..4}
|
|
| 619 |
+ if ! egrep -q "$s" /proc/mounts;then |
|
| 620 |
+ sudo mount ${s}
|
|
| 621 |
+ fi |
|
| 617 | 622 |
|
| 618 | 623 |
# Create directories |
| 619 |
- install -g stack -o stack -d /etc/swift/{object,container,account}-server \
|
|
| 620 |
- ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift
|
|
| 624 |
+ sudo install -g stack -o stack -d /etc/swift /etc/swift/{object,container,account}-server \
|
|
| 625 |
+ ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4}
|
|
| 621 | 626 |
|
| 622 | 627 |
# Adjust rc.local to always have a /var/run/swift on reboot |
| 623 | 628 |
# created and chown to our user. |
| 624 | 629 |
# TODO (chmou): We may not have a "exit 0" |
| 625 |
- sed -i '/^exit 0/d' /etc/rc.local |
|
| 626 |
-cat <<EOF>>/etc/rc.local |
|
| 630 |
+ sudo sed -i '/^exit 0/d' /etc/rc.local |
|
| 631 |
+cat <<EOF | sudo tee -a /etc/rc.local |
|
| 627 | 632 |
mkdir -p /var/run/swift |
| 628 | 633 |
chown stack: /var/run/swift |
| 629 | 634 |
exit 0 |
| 630 | 635 |
EOF |
| 631 | 636 |
|
| 632 | 637 |
# Add rsync file |
| 633 |
- sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf |
|
| 638 |
+ sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf |
|
| 634 | 639 |
|
| 635 | 640 |
# Copy proxy-server configuration |
| 636 | 641 |
cp $FILES/swift-proxy-server.conf /etc/swift/ |
| 637 | 642 |
|
| 638 | 643 |
# Generate swift.conf, we need to have the swift-hash being random |
| 639 | 644 |
# and unique. |
| 640 |
- local SWIFT_HASH=$(od -t x8 -N 8 -A n </dev/random) |
|
| 641 |
- sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf |
|
| 645 |
+ swift_hash=$(od -t x8 -N 8 -A n </dev/random) |
|
| 646 |
+ sed -e "s/%sWIFT_HASH%/$swift_hash/" $FILES/swift.conf > /etc/swift/swift.conf |
|
| 642 | 647 |
|
| 643 | 648 |
# We need to generate a object/account/proxy configuration |
| 644 | 649 |
# emulating 4 nodes on different ports we have a litle function |
| ... | ... |
@@ -658,6 +663,8 @@ EOF |
| 658 | 658 |
generate_swift_configuration object 6010 2 |
| 659 | 659 |
generate_swift_configuration container 6011 2 |
| 660 | 660 |
generate_swift_configuration account 6012 2 |
| 661 |
+ |
|
| 662 |
+ unset s swift_hasH |
|
| 661 | 663 |
|
| 662 | 664 |
fi |
| 663 | 665 |
|