Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 1 | # lib/swift |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 2 | # Functions to control the configuration and operation of the **Swift** service |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 3 | |
| 4 | # Dependencies: |
| 5 | # ``functions`` file |
| 6 | # ``DEST``, ``SCREEN_NAME``, `SWIFT_HASH` must be defined |
| 7 | # ``SWIFT_DATA_DIR`` or ``DATA_DIR`` must be defined |
| 8 | # ``lib/keystone`` file |
| 9 | # ``stack.sh`` calls the entry points in this order: |
| 10 | # |
| 11 | # install_swift |
| 12 | # configure_swift |
| 13 | # init_swift |
| 14 | # start_swift |
| 15 | # stop_swift |
| 16 | # cleanup_swift |
| 17 | |
| 18 | # Save trace setting |
| 19 | XTRACE=$(set +o | grep xtrace) |
| 20 | set +o xtrace |
| 21 | |
| 22 | |
| 23 | # Defaults |
| 24 | # -------- |
| 25 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 26 | # Set up default directories |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 27 | SWIFT_DIR=$DEST/swift |
| 28 | SWIFTCLIENT_DIR=$DEST/python-swiftclient |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 29 | SWIFT_AUTH_CACHE_DIR=${SWIFT_AUTH_CACHE_DIR:-/var/cache/swift} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 30 | |
| 31 | # TODO: add logging to different location. |
| 32 | |
| 33 | # Set ``SWIFT_DATA_DIR`` to the location of swift drives and objects. |
| 34 | # Default is the common DevStack data directory. |
| 35 | SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift} |
| 36 | |
| 37 | # Set ``SWIFT_CONFIG_DIR`` to the location of the configuration files. |
| 38 | # Default is ``/etc/swift``. |
| 39 | SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift} |
| 40 | |
| 41 | # DevStack will create a loop-back disk formatted as XFS to store the |
| 42 | # swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in bytes. |
| 43 | # Default is 1 gigabyte. |
| 44 | SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} |
| 45 | |
| 46 | # The ring uses a configurable number of bits from a path’s MD5 hash as |
| 47 | # a partition index that designates a device. The number of bits kept |
| 48 | # from the hash is known as the partition power, and 2 to the partition |
| 49 | # power indicates the partition count. Partitioning the full MD5 hash |
| 50 | # ring allows other parts of the cluster to work in batches of items at |
| 51 | # once which ends up either more efficient or at least less complex than |
| 52 | # working with each item separately or the entire cluster all at once. |
| 53 | # By default we define 9 for the partition count (which mean 512). |
| 54 | SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} |
| 55 | |
| 56 | # Set ``SWIFT_REPLICAS`` to configure how many replicas are to be |
| 57 | # configured for your Swift cluster. By default the three replicas would need a |
| 58 | # bit of IO and Memory on a VM you may want to lower that to 1 if you want to do |
| 59 | # only some quick testing. |
| 60 | SWIFT_REPLICAS=${SWIFT_REPLICAS:-3} |
| 61 | SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS}) |
| 62 | |
| 63 | # Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE`` |
| 64 | # Port bases used in port number calclution for the service "nodes" |
| 65 | # The specified port number will be used, the additinal ports calculated by |
| 66 | # base_port + node_num * 10 |
| 67 | OBJECT_PORT_BASE=6010 |
| 68 | CONTAINER_PORT_BASE=6011 |
| 69 | ACCOUNT_PORT_BASE=6012 |
| 70 | |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 71 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 72 | # Entry Points |
| 73 | # ------------ |
| 74 | |
| 75 | # cleanup_swift() - Remove residual data files |
| 76 | function cleanup_swift() { |
| 77 | rm -f ${SWIFT_CONFIG_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz} |
| 78 | if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 79 | sudo umount ${SWIFT_DATA_DIR}/drives/sdb1 |
| 80 | fi |
| 81 | if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then |
| 82 | rm ${SWIFT_DATA_DIR}/drives/images/swift.img |
| 83 | fi |
| 84 | } |
| 85 | |
| 86 | # configure_swift() - Set config files, create data dirs and loop image |
| 87 | function configure_swift() { |
| 88 | local swift_auth_server |
| 89 | local node_number |
| 90 | local swift_node_config |
| 91 | local swift_log_dir |
| 92 | |
| 93 | setup_develop $SWIFT_DIR |
| 94 | |
| 95 | # Make sure to kill all swift processes first |
| 96 | swift-init all stop || true |
| 97 | |
| 98 | # First do a bit of setup by creating the directories and |
| 99 | # changing the permissions so we can run it as our user. |
| 100 | |
| 101 | USER_GROUP=$(id -g) |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame^] | 102 | sudo mkdir -p ${SWIFT_DATA_DIR}/{drives,cache} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 103 | sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR} |
| 104 | |
| 105 | # Create a loopback disk and format it to XFS. |
| 106 | if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then |
| 107 | if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 108 | sudo umount ${SWIFT_DATA_DIR}/drives/sdb1 |
| 109 | fi |
| 110 | else |
| 111 | mkdir -p ${SWIFT_DATA_DIR}/drives/images |
| 112 | sudo touch ${SWIFT_DATA_DIR}/drives/images/swift.img |
| 113 | sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img |
| 114 | |
| 115 | dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \ |
| 116 | bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} |
| 117 | fi |
| 118 | |
| 119 | # Make a fresh XFS filesystem |
| 120 | mkfs.xfs -f -i size=1024 ${SWIFT_DATA_DIR}/drives/images/swift.img |
| 121 | |
| 122 | # Mount the disk with mount options to make it as efficient as possible |
| 123 | mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1 |
| 124 | if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 125 | sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ |
| 126 | ${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1 |
| 127 | fi |
| 128 | |
| 129 | # Create a link to the above mount and |
| 130 | # create all of the directories needed to emulate a few different servers |
| 131 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 132 | sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$node_number ${SWIFT_DATA_DIR}/$node_number; |
| 133 | drive=${SWIFT_DATA_DIR}/drives/sdb1/${node_number} |
| 134 | node=${SWIFT_DATA_DIR}/${node_number}/node |
| 135 | node_device=${node}/sdb1 |
| 136 | [[ -d $node ]] && continue |
| 137 | [[ -d $drive ]] && continue |
| 138 | sudo install -o ${USER} -g $USER_GROUP -d $drive |
| 139 | sudo install -o ${USER} -g $USER_GROUP -d $node_device |
| 140 | sudo chown -R $USER: ${node} |
| 141 | done |
| 142 | |
| 143 | sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server /var/run/swift |
| 144 | sudo chown -R $USER: ${SWIFT_CONFIG_DIR} /var/run/swift |
| 145 | |
| 146 | if [[ "$SWIFT_CONFIG_DIR" != "/etc/swift" ]]; then |
| 147 | # Some swift tools are hard-coded to use ``/etc/swift`` and are apparently not going to be fixed. |
| 148 | # Create a symlink if the config dir is moved |
| 149 | sudo ln -sf ${SWIFT_CONFIG_DIR} /etc/swift |
| 150 | fi |
| 151 | |
| 152 | # Swift use rsync to synchronize between all the different |
| 153 | # partitions (which make more sense when you have a multi-node |
| 154 | # setup) we configure it with our version of rsync. |
| 155 | sed -e " |
| 156 | s/%GROUP%/${USER_GROUP}/; |
| 157 | s/%USER%/$USER/; |
| 158 | s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,; |
| 159 | " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf |
| 160 | # rsyncd.conf just prepared for 4 nodes |
Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 161 | if is_ubuntu; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 162 | sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync |
| 163 | else |
| 164 | sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync |
| 165 | fi |
| 166 | |
| 167 | if is_service_enabled swift3;then |
| 168 | swift_auth_server="s3token " |
| 169 | fi |
| 170 | |
| 171 | # By default Swift will be installed with the tempauth middleware |
| 172 | # which has some default username and password if you have |
| 173 | # configured keystone it will checkout the directory. |
| 174 | if is_service_enabled key; then |
| 175 | swift_auth_server+="authtoken keystoneauth" |
| 176 | else |
| 177 | swift_auth_server=tempauth |
| 178 | fi |
| 179 | |
| 180 | SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONFIG_DIR}/proxy-server.conf |
| 181 | cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER} |
| 182 | |
| 183 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user |
| 184 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${USER} |
| 185 | |
| 186 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir |
| 187 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONFIG_DIR} |
| 188 | |
| 189 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers |
| 190 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1 |
| 191 | |
| 192 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level |
| 193 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG |
| 194 | |
| 195 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port |
| 196 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080} |
| 197 | |
| 198 | # Only enable Swift3 if we have it enabled in ENABLED_SERVICES |
| 199 | is_service_enabled swift3 && swift3=swift3 || swift3="" |
| 200 | |
| 201 | iniset ${SWIFT_CONFIG_PROXY_SERVER} pipeline:main pipeline "catch_errors healthcheck cache ratelimit ${swift3} ${swift_auth_server} proxy-logging proxy-server" |
| 202 | |
| 203 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true |
| 204 | |
| 205 | # Configure Keystone |
| 206 | sed -i '/^# \[filter:authtoken\]/,/^# \[filter:keystoneauth\]$/ s/^#[ \t]*//' ${SWIFT_CONFIG_PROXY_SERVER} |
| 207 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_host $KEYSTONE_AUTH_HOST |
| 208 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_port $KEYSTONE_AUTH_PORT |
| 209 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL |
| 210 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/ |
| 211 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 212 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_user swift |
| 213 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_password $SERVICE_PASSWORD |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 214 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken signing_dir $SWIFT_AUTH_CACHE_DIR |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 215 | |
| 216 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth use |
| 217 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles |
| 218 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin" |
| 219 | |
| 220 | if is_service_enabled swift3; then |
| 221 | cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER} |
| 222 | # NOTE(chmou): s3token middleware is not updated yet to use only |
| 223 | # username and password. |
| 224 | [filter:s3token] |
| 225 | paste.filter_factory = keystone.middleware.s3_token:filter_factory |
| 226 | auth_port = ${KEYSTONE_AUTH_PORT} |
| 227 | auth_host = ${KEYSTONE_AUTH_HOST} |
| 228 | auth_protocol = ${KEYSTONE_AUTH_PROTOCOL} |
| 229 | auth_token = ${SERVICE_TOKEN} |
| 230 | admin_token = ${SERVICE_TOKEN} |
| 231 | |
| 232 | [filter:swift3] |
| 233 | use = egg:swift3#swift3 |
| 234 | EOF |
| 235 | fi |
| 236 | |
| 237 | cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONFIG_DIR}/swift.conf |
| 238 | iniset ${SWIFT_CONFIG_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH} |
| 239 | |
| 240 | # This function generates an object/account/proxy configuration |
| 241 | # emulating 4 nodes on different ports |
| 242 | function generate_swift_config() { |
| 243 | local swift_node_config=$1 |
| 244 | local node_id=$2 |
| 245 | local bind_port=$3 |
| 246 | |
| 247 | log_facility=$[ node_id - 1 ] |
| 248 | node_path=${SWIFT_DATA_DIR}/${node_number} |
| 249 | |
| 250 | iniuncomment ${swift_node_config} DEFAULT user |
| 251 | iniset ${swift_node_config} DEFAULT user ${USER} |
| 252 | |
| 253 | iniuncomment ${swift_node_config} DEFAULT bind_port |
| 254 | iniset ${swift_node_config} DEFAULT bind_port ${bind_port} |
| 255 | |
| 256 | iniuncomment ${swift_node_config} DEFAULT swift_dir |
| 257 | iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR} |
| 258 | |
| 259 | iniuncomment ${swift_node_config} DEFAULT devices |
| 260 | iniset ${swift_node_config} DEFAULT devices ${node_path} |
| 261 | |
| 262 | iniuncomment ${swift_node_config} DEFAULT log_facility |
| 263 | iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility} |
| 264 | |
| 265 | iniuncomment ${swift_node_config} DEFAULT mount_check |
| 266 | iniset ${swift_node_config} DEFAULT mount_check false |
| 267 | |
| 268 | iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode |
| 269 | iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes |
| 270 | } |
| 271 | |
| 272 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 273 | swift_node_config=${SWIFT_CONFIG_DIR}/object-server/${node_number}.conf |
| 274 | cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config} |
| 275 | generate_swift_config ${swift_node_config} ${node_number} $[OBJECT_PORT_BASE + 10 * (node_number - 1)] |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame^] | 276 | iniset ${swift_node_config} filter:recon recon_cache_path ${SWIFT_DATA_DIR}/cache |
| 277 | # Using a sed and not iniset/iniuncomment because we want to a global |
| 278 | # modification and make sure it works for new sections. |
| 279 | sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 280 | |
| 281 | swift_node_config=${SWIFT_CONFIG_DIR}/container-server/${node_number}.conf |
| 282 | cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config} |
| 283 | generate_swift_config ${swift_node_config} ${node_number} $[CONTAINER_PORT_BASE + 10 * (node_number - 1)] |
Attila Fazekas | 83e1095 | 2012-11-30 23:28:07 +0100 | [diff] [blame] | 284 | iniuncomment ${swift_node_config} app:container-server allow_versions |
| 285 | iniset ${swift_node_config} app:container-server allow_versions "true" |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame^] | 286 | sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 287 | |
| 288 | swift_node_config=${SWIFT_CONFIG_DIR}/account-server/${node_number}.conf |
| 289 | cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config} |
| 290 | generate_swift_config ${swift_node_config} ${node_number} $[ACCOUNT_PORT_BASE + 10 * (node_number - 1)] |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame^] | 291 | sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 292 | done |
| 293 | |
| 294 | swift_log_dir=${SWIFT_DATA_DIR}/logs |
| 295 | rm -rf ${swift_log_dir} |
| 296 | mkdir -p ${swift_log_dir}/hourly |
| 297 | sudo chown -R $USER:adm ${swift_log_dir} |
| 298 | sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \ |
| 299 | tee /etc/rsyslog.d/10-swift.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | # configure_swiftclient() - Set config files, create data dirs, etc |
| 303 | function configure_swiftclient() { |
| 304 | setup_develop $SWIFTCLIENT_DIR |
| 305 | } |
| 306 | |
| 307 | # init_swift() - Initialize rings |
| 308 | function init_swift() { |
| 309 | local node_number |
| 310 | # Make sure to kill all swift processes first |
| 311 | swift-init all stop || true |
| 312 | |
| 313 | # This is where we create three different rings for swift with |
| 314 | # different object servers binding on different ports. |
| 315 | pushd ${SWIFT_CONFIG_DIR} >/dev/null && { |
| 316 | |
| 317 | rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz |
| 318 | |
| 319 | swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 320 | swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 321 | swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 322 | |
| 323 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 324 | swift-ring-builder object.builder add z${node_number}-127.0.0.1:$[OBJECT_PORT_BASE + 10 * (node_number - 1)]/sdb1 1 |
| 325 | swift-ring-builder container.builder add z${node_number}-127.0.0.1:$[CONTAINER_PORT_BASE + 10 * (node_number - 1)]/sdb1 1 |
| 326 | swift-ring-builder account.builder add z${node_number}-127.0.0.1:$[ACCOUNT_PORT_BASE + 10 * (node_number - 1)]/sdb1 1 |
| 327 | done |
| 328 | swift-ring-builder object.builder rebalance |
| 329 | swift-ring-builder container.builder rebalance |
| 330 | swift-ring-builder account.builder rebalance |
| 331 | } && popd >/dev/null |
| 332 | |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 333 | # Create cache dir |
| 334 | sudo mkdir -p $SWIFT_AUTH_CACHE_DIR |
| 335 | sudo chown `whoami` $SWIFT_AUTH_CACHE_DIR |
| 336 | rm -f $SWIFT_AUTH_CACHE_DIR/* |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | function install_swift() { |
| 340 | git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH |
| 341 | } |
| 342 | |
| 343 | function install_swiftclient() { |
| 344 | git_clone $SWIFTCLIENT_REPO $SWIFTCLIENT_DIR $SWIFTCLIENT_BRANCH |
| 345 | } |
| 346 | |
| 347 | |
| 348 | # start_swift() - Start running processes, including screen |
| 349 | function start_swift() { |
| 350 | # (re)start rsyslog |
| 351 | restart_service rsyslog |
| 352 | # Start rsync |
Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 353 | if is_ubuntu; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 354 | sudo /etc/init.d/rsync restart || : |
| 355 | else |
| 356 | sudo systemctl start xinetd.service |
| 357 | fi |
| 358 | |
| 359 | # First spawn all the swift services then kill the |
| 360 | # proxy service so we can run it in foreground in screen. |
| 361 | # ``swift-init ... {stop|restart}`` exits with '1' if no servers are running, |
| 362 | # ignore it just in case |
| 363 | swift-init all restart || true |
| 364 | swift-init proxy stop || true |
| 365 | screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v" |
| 366 | } |
| 367 | |
| 368 | # stop_swift() - Stop running processes (non-screen) |
| 369 | function stop_swift() { |
| 370 | # screen normally killed by unstack.sh |
| 371 | swift-init all stop || true |
| 372 | } |
| 373 | |
| 374 | # Restore xtrace |
| 375 | $XTRACE |