#! /bin/sh
# This file is part of BEAM
# Copyright (C) 2012-2014 Sergey Poznyakoff
#
# BEAM is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# BEAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BEAM. If not, see .
set -e
. @LIBDIR@/beam/common.sh
set +e
if [ "$1" = "--wtf" ]; then
wtf $(basename $0) mount or unmount a backup s3 bucket
exit 0
fi
test -z "$BEAM_CONFIG" && BEAM_CONFIG=@SYSCONFDIR@/beam.conf
if [ ! -r $BEAM_CONFIG ]; then
echo >&2 "$0: configuration file $BEAM_CONFIG is not found or is unreadable"
exit 1
fi
. $BEAM_CONFIG
. @LIBDIR@/beam/s3.sh
if [ -z "$backup_bucket_name" ]; then
echo >&2 "$0: backup_bucket_name is not defined (examine $BEAM_CONFIG)"
exit 1
fi
help() {
cat <
EOT
exit 0
}
while [ $# -ne 0 ]
do
case $1 in
-h|--help) help;;
-V|--version) print_version;;
*) break;;
esac
done
case $1 in
mount)
s3_mount
echo "$backup_bucket_name mounted under $backup_mp_s3";;
umount|unmount)
s3_unmount --force;;
status)
for id in s3 backer
do
mpoint=$(s3_getmpoint $id)
if [ -n "$mpoint" ]; then
echo "$id is mounted on $mpoint"
fi
done;;
*) help
exit 1;;
esac