#!/bin/bash
sleep 5
mkdir -p /mnt/v1
yum install -y amazon-efs-utils

sudo mount -t efs -o tls fs-24bc1bc1:/ /mnt/v1
aws configure set default.region cn-northwest-1
yum install -y awslogs
cat > /etc/awslogs/awscli.conf <<EOA
[plugins]
cwlogs = cwlogs
[default]
region = cn-northwest-1

EOA
cat > /etc/awslogs/awslogs.conf <<EOB
[general]

state_file = /var/lib/awslogs/agent-state
[/var/log/messages]
datetime_format = %b %d %H:%M:%S
file = /mnt/v1/server.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = cloudlog

EOB

source /mnt/v1/reboot.sh &
systemctl restart awslogsd
/mnt/v1/server /mnt/v1/conf.toml