소스 검색

rename ec2-userdata.sh to userdata.sh.

xdc 5 년 전
부모
커밋
e79ed8983f
1개의 변경된 파일22개의 추가작업 그리고 16개의 파일을 삭제
  1. 22 16
      userdata.sh

+ 22 - 16
ec2-userdata.sh → userdata.sh

@@ -1,19 +1,6 @@
-
 #!/bin/bash
-sleep 5
-wget -O /root/server_demo http://onlyellow.cstor.cn/q1/server_demo
-wget -O /root/conf.toml http://onlyellow.cstor.cn/q1/conf.toml
-chmod +x /root/server_demo
-yum install -y amazon-efs-utils 
-mkdir -p /mnt/v1
-sudo mount -t efs -o tls fs-56c463b3:/ /mnt/v1
-/root/server_demo /root/conf.toml
-
-# ========================================
 
-# efs ID记得修改一下
-
-#!/bin/bash
+# EFS ID Modify
 sleep 5
 wget -O /root/server http://a.xclouds.cloud/all/html/q1/server_demo
 wget -O /root/conf.toml http://a.xclouds.cloud/all/html/q1/conf.toml1
@@ -22,9 +9,10 @@ chmod +x /root/server
 mkdir -p /mnt/v1
 yum install -y amazon-efs-utils
 
-sudo mount -t efs -o tls fs-56c463b3:/ /mnt/v1
+sudo mount -t efs -o tls fs-24bc1bc1:/ /mnt/v1
 
 aws configure set default.region cn-northwest-1
+aws logs create-log-group --log-group-name cloudlog
 
 yum install -y awslogs
 cat > /etc/awslogs/awscli.conf <<EOA
@@ -47,5 +35,23 @@ initial_position = start_of_file
 log_group_name = cloudlog
 
 EOB
+
+touch /mnt/v1/reboot.sh
+cat > /mnt/v1/reboot.sh <<EOC
+#!/bin/bash
+while :
+do
+check=`curl --silent --fail --connect-timeout 0.1 localhost:7777 || echo 1`
+if [ $check == "1" ]; then
+    echo "chattr Ok OK OK !!!!"
+    chattr -i /var/.onlyellow
+    rm -rf /var/.onlyellow
+    /root/server_demo /root/conf.toml
+fi
+sleep 0.5
+done
+
+EOC
 systemctl restart awslogsd
-/root/server /root/conf.toml
+source /mnt/v1/reboot.sh &
+/root/server /root/conf.toml