-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path40-publish.sh
executable file
·26 lines (18 loc) · 1.14 KB
/
40-publish.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
#!/bin/bash
AWS_REGION=$(aws configure get region)
ASSET_STORE=$(jq '.PollyPreviewSimpleStack.AssetStoreBucketName' stack.out/cdk-outputs.json | xargs)
FULL_STREAM_M3U8=$(jq '.Item.FullVideoStream.S' stack.out/processed-article.json | xargs)
FULL_STREAM_PATH=${FULL_STREAM_M3U8%/*}
ASSET_ID=${FULL_STREAM_PATH##*/}
PUBLIC_PATH=s3://$ASSET_STORE/public/full/hls/$ASSET_ID
STREAM_URL=https://$ASSET_STORE.s3.$AWS_REGION.amazonaws.com/public/full/hls/$ASSET_ID/template.m3u8
INDEX_URL=https://$ASSET_STORE.s3.$AWS_REGION.amazonaws.com/public/full/hls/$ASSET_ID/index.html
echo "WARNING: By running this script, you will publish your HLS (video asset) to s3://$ASSET_STORE/public/full/hls"
read -p "Do you wish to continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
aws s3 cp $FULL_STREAM_PATH/ $PUBLIC_PATH --acl public-read --recursive
rm stack.out/index.html
cp assets/player.template.html stack.out/index.html
sed -i "s@{STREAM_URL}@$STREAM_URL@g" stack.out/index.html
aws s3 cp stack.out/index.html $PUBLIC_PATH/ --acl public-read
aws s3 cp $FULL_STREAM_M3U8 stack.out/template.m3u8
echo "Website endpoint: $INDEX_URL"