1# Copyright 2023 Unionman Technology Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13#!/bin/sh 14chdir /data/log 15notifier() { 16 arg=$1 17 if [ -z $arg ];then 18 cem publish -e user.faultlog.dump -c 0 -d "succ" 19 else 20 cem publish -e user.faultlog.dump -c 1 -d $arg 21 fi 22} 23while 24do 25 switch_on=$(param get persist.faultlog.on) 26 #echo $switch_on 27 if [ $switch_on = "true" ];then 28 echo "switch on" 29 path=$(param get persist.faultlog.path) 30 echo "path=$path" 31 if [ -d $path ];then 32 timestamp=$(date +%Y-%m-%d-%H-%M-%S) 33 tar -czf faultlog-$timestamp.gz faultlog 34 if [ $? -ne 0 ];then 35 notifier "tar" 36 fi 37 cp faultlog-$timestamp.gz $path 38 if [ $? -ne 0 ];then 39 notifier "copy" 40 fi 41 rm -f faultlog-$timestamp.gz 42 param set persist.faultlog.on false 43 notifier 44 fi 45 fi 46 sleep 2 47done 48