|
|
@@ -24,36 +24,9 @@ def lambda_handler(event,context):
|
|
|
|
|
|
|
|
|
# -----------------------------
|
|
|
-
|
|
|
-
|
|
|
-import boto3
|
|
|
-
|
|
|
-client = boto3.client('ssm')
|
|
|
-respond = client.get_parameter(Name='Secret')
|
|
|
-code_ori = respond['Parameter']['Value']
|
|
|
-
|
|
|
-
|
|
|
-def alter(file,old_str,new_str):
|
|
|
- file_data = ""
|
|
|
- with open(file, "r", encoding="utf-8") as f:
|
|
|
- for line in f:
|
|
|
- if old_str in line:
|
|
|
- line = line.replace(line,new_str)
|
|
|
- file_data += line
|
|
|
- with open(file,"w",encoding="utf-8") as f:
|
|
|
- f.write(file_data)
|
|
|
- f.close()
|
|
|
-code_pro = code_ori.replace("'", '')
|
|
|
-code = f'secret_code = "{code_pro}"'
|
|
|
-alter("/conf.toml", "secret_code", cod
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#---------V2============
|
|
|
-
|
|
|
-
|
|
|
import boto3
|
|
|
import time
|
|
|
+import os
|
|
|
client = boto3.client('ssm')
|
|
|
|
|
|
def alter(file,old_str,new_str):
|
|
|
@@ -85,5 +58,34 @@ while True:
|
|
|
if old == code:
|
|
|
print('NO')
|
|
|
else:
|
|
|
- print('OK')
|
|
|
+ # os.popen('killall server_k12')
|
|
|
+ os.popen("kill -9 `lsof -i:7777|awk '{print $2}'|awk 'END {print}'`")
|
|
|
alter("/conf.toml", "secret_code", code)
|
|
|
+ os.system('nohup /server /conf.toml &')
|
|
|
+ print('OK===========')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#===
|
|
|
+
|
|
|
+#!/bin/bash
|
|
|
+
|
|
|
+cat >>/etc/yum.repos.drhel7.repo<<OK
|
|
|
+[rhel7]
|
|
|
+name=this
|
|
|
+baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
|
|
|
+enabled=1
|
|
|
+gpgcheck=0
|
|
|
+OK
|
|
|
+
|
|
|
+yum clean all
|
|
|
+yum makecache
|
|
|
+yum install -y lsof
|
|
|
+
|
|
|
+nohup python3 /secret.py &
|
|
|
+chmod +x /server
|
|
|
+/server /conf.toml
|
|
|
+
|