· 6 years ago · Apr 22, 2019, 03:42 PM
1#!/usr/bin/env bash
2
3function banner_simple() {
4 local msg="* $* *"
5 local edge=`echo "$msg" | sed 's/./*/g'`
6 echo "$edge"
7 echo "`tput bold`$msg`tput sgr0`"
8 echo "$edge"
9 echo
10}
11
12banner_simple "Preparing to mount Amazon S3 bucket"
13
14sudo apt install -y s3fs
15
16read -ep "What is the S3 access key? " ACCESS_KEY
17read -ep "What is the S3 secret key? " SECRET_KEY
18read -ep "What is the S3 bucket name? " BUCKET_NAME
19
20echo "$ACCESS_KEY":"$SECRET_KEY" > ~/.passwd-s3fs
21chmod 600 ~/.passwd-s3fs
22
23mkdir ~/s3-drive
24
25echo "Mounting S3 $BUCKET_NAME bucket at ~/s3-drive, please wait..."
26echo
27s3fs "$BUCKET_NAME" ~/s3-drive
28
29if [ mount | grep -q s3fs ]; then
30 echo `tput setaf 2`Mount Successfull`tput sgr0`
31else
32 echo `tput setaf 1`Mount Failed`tput sgr0`
33fi