| | 1 | [[PageOutline(2-5, Table of Contents, floated)]] |
| | 2 | |
| | 3 | = S3QL Mount and Unmount = |
| | 4 | |
| | 5 | This is a pair of script to mount and unmount S3QL filesystems, they are used on [[Crin3]]. |
| | 6 | |
| | 7 | == mnt-s3ql == |
| | 8 | |
| | 9 | {{{ |
| | 10 | #!/bin/bash |
| | 11 | |
| | 12 | # this scipt is for mounting a s3 compatible bucket using s3ql |
| | 13 | # |
| | 14 | # the name of the storageqloud bucket and also |
| | 15 | # the local mount point under $MOUNT should match |
| | 16 | |
| | 17 | # mount directory |
| | 18 | MOUNT="/media" |
| | 19 | |
| | 20 | # s3ql server |
| | 21 | SERVER="s3c://s.qstack.advania.com:443" |
| | 22 | |
| | 23 | # check that the script is being run by root |
| | 24 | if [[ "$(id -u)" != "0" ]] ; then |
| | 25 | echo "You must run $0 as root or via sudo" |
| | 26 | exit 2 |
| | 27 | fi |
| | 28 | |
| | 29 | # check for bucket name / directory on standard input |
| | 30 | if [[ $1 ]]; then |
| | 31 | BUCKET=$1 |
| | 32 | elif [[ ! $1 ]]; then |
| | 33 | echo "Type the bucketname and then [ENTER]:" |
| | 34 | read bucket |
| | 35 | BUCKET=$bucket |
| | 36 | fi |
| | 37 | |
| | 38 | # if force is wanted for filesystem check |
| | 39 | if [[ $1 == "--force" ]]; then |
| | 40 | # file system check with force |
| | 41 | fsck.s3ql --force --batch ${SERVER}/${BUCKET} \ |
| | 42 | || echo "Force filesystem check of ${SERVER}/${BUCKET} failed" |
| | 43 | else |
| | 44 | # file system check |
| | 45 | fsck.s3ql --batch ${SERVER}/${BUCKET} \ |
| | 46 | || echo "Filesystem check of ${SERVER}/${BUCKET} failed" |
| | 47 | fi |
| | 48 | |
| | 49 | # mount the s3ql file system |
| | 50 | mount.s3ql --backend-options="dumb-copy" --allow-root \ |
| | 51 | ${SERVER}/${BUCKET} ${MOUNT}/${BUCKET} || \ |
| | 52 | echo "Mounting ${SERVER}/${BUCKET} on ${MOUNT}/${BUCKET} failed" |
| | 53 | |
| | 54 | exit 0 |
| | 55 | }}} |
| | 56 | |
| | 57 | == unmnt-s3ql == |
| | 58 | |
| | 59 | {{{ |
| | 60 | #!/bin/bash |
| | 61 | |
| | 62 | # this scipt is for unmounting a s3 compatible bucket using s3ql |
| | 63 | |
| | 64 | # mount directory |
| | 65 | MOUNT="/media" |
| | 66 | |
| | 67 | # s3ql server |
| | 68 | SERVER="s3c://s.qstack.advania.com:443" |
| | 69 | |
| | 70 | # check that the script is being run by root |
| | 71 | if [[ "$(id -u)" != "0" ]] ; then |
| | 72 | echo "You must run $0 as root or via sudo" |
| | 73 | exit 2 |
| | 74 | fi |
| | 75 | |
| | 76 | # check for bucket name / directory on standard input |
| | 77 | if [[ $1 ]]; then |
| | 78 | BUCKET=$1 |
| | 79 | elif [[ ! $1 ]]; then |
| | 80 | echo "Type the bucketname and then [ENTER]:" |
| | 81 | read bucket |
| | 82 | BUCKET=$bucket |
| | 83 | fi |
| | 84 | |
| | 85 | # if force is needed |
| | 86 | if [[ $1 == "--force" ]]; then |
| | 87 | fusermount -u -z ${MOUNT}/${BUCKET} |
| | 88 | killall -9 mount.s3ql |
| | 89 | # file system check with force |
| | 90 | fsck.s3ql --batch --force ${SERVER}/${BUCKET} |
| | 91 | else |
| | 92 | # unmount |
| | 93 | umount.s3ql ${MOUNT}/${BUCKET} |
| | 94 | # check the file system |
| | 95 | fsck.s3ql --batch ${SERVER}/${BUCKET} |
| | 96 | fi |
| | 97 | |
| | 98 | exit 0 |
| | 99 | }}} |