Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This file is controlled by Chef. Manual changes will be overwritten.
- # Script to upload ddex files to GCS bucket.
- set -e
- LOGFILE=/var/log/inotify.log
- ROOT_DIR="$1"
- UPLOADED_FILE="$2"
- BUCKETNAME=test
- UPLOAD_PATH=$(dirname $(realpath --relative-to="$ROOT_DIR" "$UPLOADED_FILE"))
- gsutil mv "$UPLOADED_FILE" "gs://$BUCKETNAME/$UPLOAD_PATH/" >> $LOGFILE 2>&1
- if [[ $? -eq 0 ]]
- then
- find $ROOT_DIR -mindepth 2 -depth -type d -print0 -exec rmdir {} \; >> $LOGFILE 2>&1
- else
- echo "Cannot delete $UPLOAD_PATH directory as upload was not successful."
- exit
- fi
Add Comment
Please, Sign In to add comment