diff --git a/cmake/Package.cmake b/cmake/Package.cmake index 3aa7756..bdaa39d 100644 --- a/cmake/Package.cmake +++ b/cmake/Package.cmake @@ -24,6 +24,7 @@ set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostunInstall install(FILES compose/docker-compose.yml DESTINATION ./compose) install(FILES images_build/client/dign_client/etc/client.conf DESTINATION ./etc) install(FILES service/tsg-diagnose.service DESTINATION /usr/lib/systemd/system) +install(FILES service/tsg-diagnose.conf DESTINATION /usr/lib/tmpfiles.d) install(FILES images_build/server_dns/config/dnsmasq.conf DESTINATION /opt/tsg/tsg-diagnose/etc/) install(DIRECTORY images/ DESTINATION ./images) diff --git a/compose/docker-compose.yml b/compose/docker-compose.yml index 1f04df1..fe30074 100644 --- a/compose/docker-compose.yml +++ b/compose/docker-compose.yml @@ -85,9 +85,6 @@ services: cp -rf /opt/dign_client/etc/certs_import/certs/sets/current/gen/crt/ca-root.crt /usr/local/share/ca-certificates update-ca-certificates cat /opt/dign_client/etc/hosts >> /etc/hosts - echo '0 2 * * * /usr/local/bin/python /opt/dign_client/clear_file_timeout.py' > /etc/crontabs/root - echo '0 2 * * * /usr/local/bin/python /opt/dign_client/clear_file_timeout.py -d /opt/dign_client/log/conn_traffic_status' > /etc/crontabs/root - crond tail -f /dev/null diff --git a/images_build/client/dign_client/bin/clear_file_timeout.py b/images_build/client/dign_client/bin/clear_file_timeout.py deleted file mode 100644 index 7edd369..0000000 --- a/images_build/client/dign_client/bin/clear_file_timeout.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -import sys -import time -import argparse - - -def get_suite_option(): - parser = argparse.ArgumentParser(description="Tsg diagnose Tools - clear tsg diagnose result file", epilog = "Example:help") - parser.add_argument('-t','--timeout', type = int, default = 604800,help='Specify the time to delete files that are not accessed in seconds ,the default is 604800 (7 days)') - parser.add_argument('-d','--dictpath', type = str, default = '/opt/dign_client/log/dign_client', help='Specify the folder to delete files, the default is /opt/dign_client/log/dign_client') - args = parser.parse_args() - return args - - -def clear_dict_file(dictpath, timeout): - try: - files = os.listdir(dictpath) - if not files: - print("The directory not exist, the process will exit") - sys.exit(0) - for file in files: - filePath = dictpath + "/" + file - if os.path.isfile(filePath): - last = int(os.stat(filePath).st_mtime) - now = int(time.time()) - if (now - last >= timeout): - os.remove(filePath) - print(filePath + " was removed!") - elif os.path.isdir(filePath): - clear_dict_file(filePath,timeout) - if not os.listdir(filePath): - os.rmdir(filePath) - except Exception as ex: - print("Process get an exception, will exit, Exception info: ", ex) - sys.stdout.write(str(ex)) - sys.exit(1) - - -if __name__ == '__main__': - args = get_suite_option() - timeout = args.timeout - dictpath = args.dictpath - clear_dict_file(dictpath, timeout) diff --git a/service/tsg-diagnose.conf b/service/tsg-diagnose.conf new file mode 100644 index 0000000..65cfc0c --- /dev/null +++ b/service/tsg-diagnose.conf @@ -0,0 +1,3 @@ +#Type Path Mode User Group Age Argument +d /var/log/tsg-diagnose/ 0755 - - 2d - +L /opt/tsg/tsg-diagnose/log - - - - /var/log/tsg-diagnose \ No newline at end of file