aboutsummaryrefslogtreecommitdiff
path: root/s3.in
blob: 3d9f2c58e09cb4860bf6d05fb16b22d8d1aed38b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /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 <http://www.gnu.org/licenses/>.

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
usage: beam s3 [OPTIONS]
   or: beam s3 {mount|umount|status}
$0 mounts or unmounts a backup s3 bucket, as configured in $BEAM_CONFIG

OPTIONS:
  -V, --version        print program version and exit
  -h, --help           produce this help list

Valid ITEMs are: $backup_items

Report bugs to <@PACKAGE_BUGREPORT@>
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

Return to:

Send suggestions and report system problems to the System administrator.