wiki:S3QLMnt

Version 5 (modified by chris, 3 years ago) (diff)

--

Table of Contents

  1. mnt-s3ql
  2. unmnt-s3ql

S3QL Mount and Unmount

This is a pair of script to mount and unmount S3QL filesystems, they are used on Crin3.

mnt-s3ql

#!/bin/bash

# this scipt is for mounting a s3 compatible bucket using s3ql 
#
# the name of the storageqloud bucket and also
# the local mount point under $MOUNT should match

# mount directory
MOUNT="/media/s3ql"

# s3ql server
SERVER="s3c://s.qstack.advania.com:443"

# check that the script is being run by root
if [[ "$(id -u)" != "0" ]] ; then
  echo "You must run $0 as root or via sudo" 
  exit 2
fi

# check for the number of arguments
if [[ "$2" ]]; then
  if [[ "$1" == "--force" ]]; then
    # force needed
    FORCE="1"
    BUCKET="$2"
  else
    echo "Please use this command like this: $0 --force bucketname"
    exit 0
  fi
else
  # check for bucket name / directory on standard input
  if [[ $1 ]]; then
    BUCKET=$1
  elif [[ ! $1 ]]; then
    echo "Type the bucketname and then [ENTER]:"
    read bucket
    BUCKET=$bucket
  fi
fi

# if force is wanted for filesystem check 
if [[ "$FORCE" = "1" ]]; then
  # file system check with force
  fsck.s3ql --force --batch --backend-options="dumb-copy" ${SERVER}/${BUCKET} \
  || echo "Force filesystem check of ${SERVER}/${BUCKET} failed" 
else
  # file system check
  fsck.s3ql --batch --backend-options="dumb-copy" ${SERVER}/${BUCKET} \
  || echo "Filesystem check of ${SERVER}/${BUCKET} failed"
fi

# mount the s3ql file system
mount.s3ql --backend-options="dumb-copy" --allow-root \
  ${SERVER}/${BUCKET} ${MOUNT}/${BUCKET} || \
  echo "Mounting ${SERVER}/${BUCKET} on ${MOUNT}/${BUCKET} failed" 

exit 0

unmnt-s3ql

#!/bin/bash

# this scipt is for unmounting a s3 compatible bucket using s3ql 

# mount directory
MOUNT="/media/s3ql"

# s3ql server
SERVER="s3c://s.qstack.advania.com:443"

# check that the script is being run by root
if [[ "$(id -u)" != "0" ]] ; then
  echo "You must run $0 as root or via sudo" 
  exit 2
fi

# check for the number of arguments
if [[ "$2" ]]; then
  if [[ "$1" == "--force" ]]; then
    # force needed
    FORCE="1"
    BUCKET="$2"
  else
    echo "Please use this command like this: $0 --force bucketname"
    exit 0
  fi
else
  # check for bucket name / directory on standard input
  if [[ "$1" ]]; then
    BUCKET="$1"
  elif [[ ! "$1" ]]; then
    echo "Type the bucketname and then [ENTER]:"
    read bucket
    BUCKET=$bucket
  fi
fi

# if force is needed
if [[ "$FORCE" ]]; then
  fusermount -u -z ${MOUNT}/${BUCKET}
  killall -9 mount.s3ql
  # file system check with force 
  fsck.s3ql --batch --force --backend-options="dumb-copy" ${SERVER}/${BUCKET}
else
  # unmount
  umount.s3ql ${MOUNT}/${BUCKET}
  # check the file system
  fsck.s3ql --batch --backend-options="dumb-copy" ${SERVER}/${BUCKET}
fi

exit 0