-
Notifications
You must be signed in to change notification settings - Fork 1
/
s3ql-entrypoint.sh
62 lines (53 loc) · 1.8 KB
/
s3ql-entrypoint.sh
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
#! /usr/bin/env bash
# Copyright 2017 Taras Pudiak
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
_term() {
umount.s3ql /mnt/s3ql
exit 0
}
_config() {
sed -i "s/S3QL_BUCKET/$S3QL_BUCKET/" /etc/s3ql/s3ql-b2.auth
sed -i "s/S3QL_PREFIX/$S3QL_PREFIX/" /etc/s3ql/s3ql-b2.auth
sed -i "s/S3QL_ACCOUNTID/$S3QL_ACCOUNTID/" /etc/s3ql/s3ql-b2.auth
sed -i "s/S3QL_APPLICATIONKEY/$S3QL_APPLICATIONKEY/" /etc/s3ql/s3ql-b2.auth
if [ "$S3QL_PASSPHRASE" != "" ]; then
sed -i "s/#fs-passphrase/fs-passphrase/" /etc/s3ql/s3ql-b2.auth
sed -i "s/S3QL_PASSPHRASE/$S3QL_PASSPHRASE/" /etc/s3ql/s3ql-b2.auth
fi
touch /etc/s3ql/configured.flag
}
_make() {
if [ "$S3QL_PASSPHRASE" != "" ]; then
echo $S3QL_PASSPHRASE | mkfs.s3ql --authfile /etc/s3ql/s3ql-b2.auth --max-obj-size $S3QL_MAXOBJSIZE b2://$S3QL_BUCKET/$S3QL_PREFIX
else
mkfs.s3ql --authfile /etc/s3ql/s3ql-b2.auth --max-obj-size $S3QL_MAXOBJSIZE --plain b2://$S3QL_BUCKET/$S3QL_PREFIX
fi
}
trap _term SIGTERM
if [ ! -e /etc/s3ql/configured.flag ]; then
if [ "$S3QL_MODE" = "make" ]; then
_config
_make
elif [ "$S3QL_MODE" = "mount" ]; then
_config
else
echo "Unknown S3QL_MODE."
exit 1
fi
fi
"$@"
while true; do
sleep 5s
done