From 466403723c4c1fd575b1340e0f9214ee28f0aeb7 Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Mon, 3 Nov 2014 14:20:08 -0800 Subject: [PATCH] Make resetswift customizable via environment Instead of recommending to edit resetswift to replace "/dev/sdb1" with "/srv/swift-disk", use an environment variable instead. This way I can set SAIO_BLOCK_DEVICE=/srv/swift-disk in my .bashrc, and then when I'm testing out changes to resetswift, I don't need to remember to edit the modified script, nor do I end up submitting changes with the wrong default in there. The variable defaults to /dev/sdb1, so if you use the script unmodified and don't set SAIO_BLOCK_DEVICE, nothing changes for you. Change-Id: I741a8c91c2c54a4f32bc391cd794ef4206402753 --- doc/saio/bin/resetswift | 4 ++-- doc/source/development_saio.rst | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/saio/bin/resetswift b/doc/saio/bin/resetswift index 0c47690159..dd2692f7da 100755 --- a/doc/saio/bin/resetswift +++ b/doc/saio/bin/resetswift @@ -4,8 +4,8 @@ swift-init all stop # Remove the following line if you did not set up rsyslog for individual logging: sudo find /var/log/swift -type f -exec rm -f {} \; sudo umount /mnt/sdb1 -# If you are using a loopback device substitute "/dev/sdb1" with "/srv/swift-disk" -sudo mkfs.xfs -f /dev/sdb1 +# If you are using a loopback device set SAIO_BLOCK_DEVICE to "/srv/swift-disk" +sudo mkfs.xfs -f ${SAIO_BLOCK_DEVICE:-/dev/sdb1} sudo mount /mnt/sdb1 sudo mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4 sudo chown ${USER}:${USER} /mnt/sdb1/* diff --git a/doc/source/development_saio.rst b/doc/source/development_saio.rst index e33e60db2a..0fb91465d4 100644 --- a/doc/source/development_saio.rst +++ b/doc/source/development_saio.rst @@ -404,17 +404,21 @@ commands are as follows: Setting up scripts for running Swift ------------------------------------ - #. Copy the SAIO scripts resetting the environment:: + #. Copy the SAIO scripts for resetting the environment:: cd $HOME/swift/doc; cp -r saio/bin $HOME/bin; cd - chmod +x $HOME/bin/* #. Edit the ``$HOME/bin/resetswift`` script - If you are using a loopback device substitute ``/dev/sdb1`` with - ``/srv/swift-disk`` in the ``mkfs`` step:: + The template ``resetswift`` script looks like the following: - sed -i "s/dev\/sdb1/srv\/swift-disk/" $HOME/bin/resetswift + .. literalinclude:: /../saio/bin/resetswift + + If you are using a loopback device add an environment var to + subsitute ``/dev/sdb1`` with ``/srv/swift-disk``:: + + echo "export SAIO_BLOCK_DEVICE=/srv/swift-disk" >> $HOME/.bashrc If you did not set up rsyslog for individual logging, remove the ``find /var/log/swift...`` line:: @@ -426,9 +430,6 @@ Setting up scripts for running Swift sed -i "s/service \(.*\) restart/systemctl restart \1.service/" $HOME/bin/resetswift - The template ``resetswift`` script looks like the following: - - .. literalinclude:: /../saio/bin/resetswift #. Install the sample configuration file for running tests::