From 3d4a73f713f1ece99de02df2a908fce4ca868502 Mon Sep 17 00:00:00 2001 From: haidong Date: Wed, 18 Oct 2023 09:25:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=B7=E6=99=AE=E5=A4=A9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=BC=80=E9=97=A8=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- haiputian_auto_switch_open_door_mode.sh | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 haiputian_auto_switch_open_door_mode.sh diff --git a/haiputian_auto_switch_open_door_mode.sh b/haiputian_auto_switch_open_door_mode.sh new file mode 100644 index 0000000..77a56bc --- /dev/null +++ b/haiputian_auto_switch_open_door_mode.sh @@ -0,0 +1,45 @@ +#!/bin/bash +current_time=`date +"%Y-%m-%d %H:%M:%S"` +echo '海普天门禁设备自动切换开门方式定时任务......' +#设备列表 +#device_list=('http://192.168.69.121:80' 'http://192.168.69.121:80') +device_list=('http://20.20.66.231:80' 'http://20.20.66.234:80' 'http://20.20.66.236:80' 'http://20.20.66.232:80' 'http://20.20.66.233:80' 'http://20.20.66.235:80') +#设备用户名密码 +#device_user_password='admin:admin' +device_user_password='admin:yzx123456.' + +base64_str=$(echo -n $device_user_password | base64) + +#设置门禁开门方式 0默认 人脸开门 3人脸核验+远程开门 +function setOpenDoorMode(){ + echo "$2" + response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 1 --max-time 1 --retry 2 --location $1'/action/SetDoorCondition' --header 'Content-Type: application/json' --header 'Authorization: Basic '${base64_str} --data '{"operator":"SetDoorCondition","info":{"OpendoorWay":'$2'}}') + echo $response +} + +#检测服务器服务状态 +function checkServiceStatus(){ + #检测青白江指定服务是否可用 + #service='http://118.89.136.154:9009/parent/faceDeviceCallBack/subscribe' + service='http://192.168.12.181:9009/parent/faceDeviceCallBack/subscribe' + response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 3 --location $service --header 'Content-Type: application/json' --data '{"operator":"来至祥福穿透服务器的消息,测试服务是否可用","info":{"DeviceID":0}}') + echo $response +} + +service_status=$(checkServiceStatus) +#判断服务器服务是否可用 +if [ $service_status -eq 200 ] +then + for item in ${device_list[*]} + do + echo "[$current_time]服务正常,切换设备:$item,开门方式为:人脸核验+远程开门方式" + setOpenDoorMode $item 3 #人脸核验+远程开门 + done +else + for item in ${device_list[*]} + do + echo "[$current_time]服务不可用,切换设备:$item,开门方式为:人脸开门" + setOpenDoorMode $item 0 #人脸开门 + done + +fi \ No newline at end of file