### Setup Local YUM Repository with HTTPD Source: https://github.com/weiyigeek/secopsdev/blob/master/CloudVirtual/K8s/Untitled-1.txt This script prepares a local YUM repository by installing the httpd web server and createrepo. It copies RPM packages from the YUM cache to a web-accessible directory, sets appropriate permissions, and configures httpd to serve the repository. ```shell yum install -y httpd createrepo ## YUM本地仓库搭建 mv /etc/httpd/conf.d/welcome.conf{,.bak} && mkdir /var/www/html/yum/ find /var/cache/yum -name *.rpm -exec cp -a {} /var/www/html/yum/ \; # 权限非常重要否则后面httpd访问下载提示权限不足 cp v${K8SVERSION}.tar.gz /var/www/html/yum/ && chmod +644 /var/www/html/yum/v${K8SVERSION}.tar.gz ``` -------------------------------- ### Install Latest Kernel and Configure Bootloader Source: https://github.com/weiyigeek/secopsdev/blob/master/CloudVirtual/K8s/Untitled-1.txt This script installs the latest mainline kernel (kernel-ml) from elrepo.org, configures the system to boot from it by default using grub2-set-default, and regenerates the GRUB configuration. It also lists available kernels before installation. ```shell echo -e "\e[32m#########\n#系统内核版本升级\n#########\e[0m" rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org yum -y install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm yum --disablerepo="*" --enablerepo=elrepo-kernel repolist yum --disablerepo="*" --enablerepo=elrepo-kernel list kernel* yum -y --enablerepo=elrepo-kernel install kernel-ml-5.7.0-1.x86_64 kernel-ml-devel-5.7.0-1.x86_64 awk -F \' \'$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg sudo grub2-set-default 0 #传统引导 grub2-mkconfig -o /boot/grub2/grub.cfg grubby --default-kernel reboot ``` -------------------------------- ### Install and Configure Java (os-software.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Installs and configures the Java Development Kit (JDK) or Runtime Environment (JRE). This function is part of the os-software.sh script. ```shell # 函数名称: install_java # 函数用途: 安装配置java环境 ``` -------------------------------- ### Ubuntu Initialization and Reinforcement Script Usage Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Provides instructions on how to use the Ubuntu initialization and reinforcement script. It includes steps for granting execute permissions and starting the initialization process. ```bash # 执行权限赋予 chmod +x -R * # 开始初始化加固 Ubuntu22.04-InitializeReinforce.sh --start ``` -------------------------------- ### Install cmatrix using yum and apt Source: https://github.com/weiyigeek/secopsdev/blob/master/Others/杂项/CodeTheRain/Readme.txt Installs the cmatrix terminal animation program. This snippet covers installation commands for RPM-based systems (using yum) and Debian-based systems (using apt). Ensure you have the necessary permissions to run these commands. ```shell yum install cmatrix ``` ```shell apt install cmatrix ``` -------------------------------- ### Install Common Operational Software Source: https://github.com/weiyigeek/secopsdev/blob/master/CloudVirtual/K8s/Untitled-1.txt Installs essential development and operational tools using YUM. This includes compilation dependencies like gcc and openssl-devel, as well as common utilities such as nano, vim, net-tools, tree, htop, wget, and ntpdate for system administration and development. ```shell echo -e "\n############################\n#安装常用的运维软件\n####################################\n" #编译依赖 yum install -y gcc gcc-c++ openssl-devel bzip2-devel #常规软件 yum install -y nano vim net-tools tree unzip htop ncdu bash-completion wget dos2unix ntpdate echo "--[安装安装完成]--" ``` -------------------------------- ### Install Hexo Sitemap Generator and Dependencies Source: https://github.com/weiyigeek/secopsdev/blob/master/Application/Blog/Hexo/Gitalk/Readme.md Installs the hexo-generator-sitemap package for generating sitemaps and other development dependencies like md5, moment, request, and xml-parser using npm. ```bash $ npm i -S hexo-generator-sitemap ``` ```bash $ npm i -D md5 moment request xml-parser ``` -------------------------------- ### Project Startup Command Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md Demonstrates the command-line interface for starting the Python project. It includes arguments for specifying image directories, log directories, IP address, port, and GPU usage. ```python python ./setup.py --imgdir=/imgs --logdir=/logs --ip=0.0.0.0 --port=8000 --gpu=True ``` -------------------------------- ### Project Directory Structure Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Visual representation of the project's file organization, showing the main script, configuration files, examples, and categorized utility scripts. ```bash :~$ tree Ubuntu/ Ubuntu/ ├── Ubuntu22.04-InitializeReinforce.sh ├── config │   └── Ubuntu22.04.conf ├── example │   └── 22.04 └── scripts ├── os-base.sh ├── os-clean.sh ├── os-exceptions.sh ├── os-info.sh ├── os-manual.sh ├── os-network.sh ├── os-optimize.sh ├── os-security.sh ├── os-service.sh └── os-software.sh 4 directories, 12 files ``` -------------------------------- ### Update YUM Repositories and Install Packages Source: https://github.com/weiyigeek/secopsdev/blob/master/CloudVirtual/K8s/Untitled-1.txt This section updates the system's YUM repositories by downloading configurations from Aliyun mirrors for CentOS-7 and EPEL. It cleans the YUM cache, imports GPG keys, and then performs a system update and upgrade, installing EPEL packages. ```shell echo -e "\e[32m#########\n#Yum源设定\n#########\e[0m" curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/CentOS-epel.repo http://mirrors.aliyun.com/repo/epel-7.repo sed -i "s#mirrors.cloud.aliyuncs.com#mirrors.aliyun.com#g" /etc/yum.repos.d/CentOS-Base.repo yum clean all yum makecache rpm --import http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CENTOS-7 yum update -y && yum upgrade -y && yum -y install epel* echo "--[YUM替换更新应用软件完成]--" ``` -------------------------------- ### Install Docker on Ubuntu (os-software.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Installs the latest version of Docker on Ubuntu hosts. This function is part of the os-software.sh script. ```shell ## 函数名称: install_docker ## 函数用途: 在 Ubuntu 主机上安装最新版本的Docker ``` -------------------------------- ### Install and Configure Chrony (os-software.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Installs and configures Chrony, a Network Time Protocol (NTP) client used for time synchronization. This function is part of the os-software.sh script. ```shell # 函数名称: install_chrony # 函数用途: 安装配置 chrony 时间同步服务器 ``` -------------------------------- ### Install Docker Compose on Ubuntu (os-software.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Installs the latest version of Docker Compose on Ubuntu hosts. This function is part of the os-software.sh script. ```shell ## 函数名称: install_cockercompose ## 函数用途: 在 Ubuntu 主机上安装最新版本的Dockercompose ``` -------------------------------- ### Configure Network Interface Source: https://github.com/weiyigeek/secopsdev/blob/master/CloudVirtual/K8s/Untitled-1.txt This script configures static IP address and gateway for a network interface (ifcfg-ens192). It checks for required arguments and the existence of the configuration file, then uses sed to update the IPADDR and GATEWAY settings, followed by restarting the network service. ```bash #!/bin/bash set -e NET_DIR=/etc/sysconfig/network-scripts/ NET_FILENAME=ifcfg-ens192 IPADDR=$1 GATEWAY=$2 if [[ $# -le 1 ]];then echo -e "\e[32m[*]Usage: $0 IP-Address Gateway \e[0m" echo -e "\e[32m[*]Usage: $0 192.168.1.99 192.168.1.1 \e[0m" exit 1 fi if [[ ! -f ${NET_DIR}${NET_FILENAME} ]];then echo -e "\e[33m[*] Not Found ${NET_DIR}${NET_FILENAME}\e[0m" exit 2 fi sed -i 's/^ONBOOT=.*$/ONBOOT="yes"/' ${NET_DIR}${NET_FILENAME} sed -i 's/^BOOTPROTO=.*$/BOOTPROTO="static"/' ${NET_DIR}${NET_FILENAME} sed -i "s/^IPADDR=.*$/IPADDR=${IPADDR}/" ${NET_DIR}${NET_FILENAME} sed -i "s/^GATEWAY=.*$/GATEWAY=${GATEWAY}/" ${NET_DIR}${NET_FILENAME} service network restart && ip addr ``` -------------------------------- ### Project Setup and Execution Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md This snippet shows how to initiate the SecOpsDev project using a Python script. It includes notes on CPU/GPU usage and development server details, such as the running address and debug mode. ```bash python .\setup.py # Using CPU. Note: This module is much faster with a GPU. # * Serving Flask app 'index' (lazy loading) # * Environment: production # WARNING: This is a development server. Do not use it in a production deployment. # Use a production WSGI server instead. # * Debug mode: on # * Running on all addresses (0.0.0.0) # WARNING: This is a development server. Do not use it in a production deployment. # * Running on http://127.0.0.1:8000 # * Running on http://10.20.172.106:8000 (Press CTRL+C to quit) # * Restarting with stat # Using CPU. Note: This module is much faster with a GPU. # * Debugger is active! # * Debugger PIN: 115-313-307 ``` -------------------------------- ### os-service.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Contains functions for managing system services, starting with the 'svc_apport' function. ```APIDOC svc_apport: Manages the system's apport service. ``` -------------------------------- ### Environment Dependencies and Module Installation Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md Lists the necessary Python packages required to run the project, including Flask for the web framework, easyocr for OCR capabilities, and gevent/gevent-websocket for asynchronous operations. ```bash pip install flask pip install easyocr pip install gevent pip install gevent-websocket ``` -------------------------------- ### Disable SELinux and Configure yum-cron Source: https://github.com/weiyigeek/secopsdev/blob/master/CloudVirtual/K8s/Untitled-1.txt This script disables SELinux by modifying its configuration file and enforcing the change. It then installs and configures yum-cron to manage automatic updates, disabling update messages and downloads while enabling caching. ```shell sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/selinux/config setenforce 0 yum install -y yum-cron sed -i "s#keepcache=0#keepcache=1#g" /etc/yum.conf && echo -e "缓存目录:" && grep "cachedir" /etc/yum.conf sed -i "s#update_messages = yes#update_messages = no#g" /etc/yum/yum-cron.conf sed -i "s#download_updates = yes#download_updates = no#g" /etc/yum/yum-cron.conf systemctl enable yum-cron systemctl restart yum-cron ``` -------------------------------- ### Main Script Usage and Options Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Documentation for the primary shell script 'Ubuntu22.04-InitializeReinforce.sh', detailing its command-line arguments for system initialization and security reinforcement tasks. ```APIDOC Usage: ./Ubuntu22.04-InitializeReinforce.sh [--start ] [--network] [--function] [--clear] [--version] [--help] Option: --start Start System initialization and security reinforcement. --network Configure the system network and DNS resolution server. --function PCall the specified shell function. --clear Clear all system logs, cache and backup files. --version Print version and exit. --help Print help and exit. ``` -------------------------------- ### Accessing Reinforced System Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Demonstrates how to connect to a system after initialization and reinforcement using SSH, and how to switch to the root user. ```bash ssh -p 20221 ubuntu@10.10.99.236 su - root ``` -------------------------------- ### os-base.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Provides functions for essential system configurations including setting the hostname, configuring Ubuntu software mirrors, upgrading packages, setting the timezone, displaying a login banner, and managing system reboots. ```APIDOC base_hostname: Sets the system's hostname. ubuntu_mirror: Configures the Ubuntu system's software repository mirrors. ubuntu_software: Upgrades the Ubuntu system kernel and installs regular software. base_timezone: Calibrates system time synchronization and sets the timezone. base_banner: Displays information for remote and local host logins. base_reboot: Determines whether to restart or shut down the server. ``` -------------------------------- ### os-optimize.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Focuses on system optimization by tuning kernel parameters, configuring resource limits for file handle counts, and creating swap partitions. ```APIDOC optimize_kernel: Optimizes system kernel parameters. resources_limits: Configures system resource limits for open file handles. swap_partition: Creates a system swap partition. ``` -------------------------------- ### os-network.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Manages network configuration, including setting the host's IP address and gateway, and configuring the system's DNS resolution servers. ```APIDOC net_config: Configures the host's IP address and gateway. net_dns: Sets the host's DNS resolution server. ``` -------------------------------- ### os-exceptions.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Addresses specific Ubuntu system issues, including a function to resolve problems with normal users' cron jobs not executing and another to fix 'multipath add missing path' errors. ```APIDOC problem_usercrond: Resolves issues where cron jobs for normal users fail to execute. problem_multipath: Fixes the 'ubuntu multipath add missing path' error. ``` -------------------------------- ### os-security.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Implements various security hardening measures, including user account management, SSH policy, password complexity, login policies, command history, GRUB security, firewall rules, disabling Ctrl+Alt+Del, setting a recycle bin alias, and sudo privilege management. ```APIDOC sec_usercheck: Locks or deletes redundant system accounts. sec_userconfig: Sets password policies for users with SSH remote login access. sec_passpolicy: Configures user password complexity policies (e.g., expiration, minimum length, complexity requirements, lockout attempts). sec_sshdpolicy: Sets security policies for the system's SSH service. sec_loginpolicy: Configures user login security policies. sec_historypolicy: Sets security policies for recording user terminal command history. sec_grubpolicy: Secures the system's GRUB configuration to prevent unauthorized password changes via the boot menu. sec_firewallpolicy: Configures system firewall policies; a system reboot is recommended after applying. sec_ctrlaltdel: Disables the Ctrl+Alt+Del key combination for system reboot. sec_recyclebin: Sets an alias for a file deletion recycle bin to prevent accidental file deletion. sec_supolicy: Optionally logs user switching and renames the 'su' command for auditing. sec_privilegepolicy: Configures system user sudo privileges and file/directory creation permissions. ``` -------------------------------- ### Script Function Definitions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Lists all defined shell functions across various script modules, along with a brief description of their purpose, facilitating targeted execution or understanding. ```bash scripts/os-base.sh:26:# 函数名称: base_hostname scripts/os-base.sh-27:# 函数用途: 主机名称设置 -- scripts/os-base.sh:55:# 函数名称: ubuntu_mirror scripts/os-base.sh-56:# 函数用途: ubuntu 系统主机软件仓库镜像源 -- scripts/os-base.sh:126:# 函数名称: ubuntu_software scripts/os-base.sh-127:# 函数用途: ubuntu 系统主机内核版本升级以常规软件安装 -- scripts/os-base.sh:153:# 函数名称: base_timezone scripts/os-base.sh-154:# 函数用途: 主机时间同步校准与时区设置 -- scripts/os-base.sh:192:# 函数名称: base_banner scripts/os-base.sh-193:# 函数用途: 远程本地登陆主机信息展示 -- scripts/os-base.sh:345:# 函数名称: base_reboot scripts/os-base.sh-346:# 函数用途: 是否进行重启或者关闭服务器 -- scripts/os-clean.sh:27:# 函数名称: system_clean scripts/os-clean.sh-28:# 函数用途: 删除安全加固过程临时文件清理为基线镜像做准备 -- scripts/os-exceptions.sh:26:# 函数名称: problem_usercrond scripts/os-exceptions.sh-27:# 函数用途: 解决普通用户定时任务无法定时执行问题 -- scripts/os-exceptions.sh:45:# 函数名称: problem_multipath scripts/os-exceptions.sh-46:# 函数用途: 解决 ubuntu multipath add missing path 错误 -- scripts/os-network.sh:27:# 函数名称: net_config scripts/os-network.sh-28:# 函数用途: 主机IP地址与网关设置 -- scripts/os-network.sh:70:# 函数名称: net_dns scripts/os-network.sh-71:# 函数用途: 设置主机DNS解析服务器 -- scripts/os-optimize.sh:27:# 函数名称: optimize_kernel scripts/os-optimize.sh-28:# 函数用途: 系统内核参数的优化配置 -- scripts/os-optimize.sh:84:# 函数名称: resources_limits scripts/os-optimize.sh-85:# 函数用途: 系统资源文件打开句柄数优化配置 -- scripts/os-optimize.sh:115:# 函数名称: swap_partition scripts/os-optimize.sh-116:# 函数用途: 创建系统swap分区 -- scripts/os-security.sh:27:# 函数名称: sec_usercheck scripts/os-security.sh-28:# 函数用途: 用于锁定或者删除多余的系统账户 -- scripts/os-security.sh:65:# 函数名称: sec_userconfig scripts/os-security.sh-66:# 函数用途: 针对拥有ssh远程登陆权限的用户进行密码口令设置。 -- scripts/os-security.sh:131:# 函数名称: sec_passpolicy scripts/os-security.sh-132:# 函数用途: 用户密码复杂性策略设置 (密码过期周期0~90、到期前15天提示、密码长度至少12、复杂度设置至少有一个大小写、数字、特殊字符、密码三次不能一样、尝试次数为三次) -- scripts/os-security.sh:166:# 函数名称: sec_sshdpolicy scripts/os-security.sh-167:# 函数用途: 系统sshd服务安全策略设置 -- scripts/os-security.sh:194:# 函数名称: sec_loginpolicy scripts/os-security.sh-195:# 函数用途: 用户登陆安全策略设置 -- scripts/os-security.sh:230:# 函数名称: sec_historypolicy scripts/os-security.sh-231:# 函数用途: 用户终端执行的历史命令记录安全策略设置 -- scripts/os-security.sh:261:# 函数名称: sec_grubpolicy scripts/os-security.sh-262:# 函数用途: 系统 GRUB 安全设置防止物理接触从grub菜单中修改密码 -- scripts/os-security.sh:304:# 函数名称: sec_firewallpolicy scripts/os-security.sh-305:# 函数用途: 系统防火墙策略设置, 建议操作完成后重启计算机. -- scripts/os-security.sh:335:# 函数名称: sec_ctrlaltdel scripts/os-security.sh-336:# 函数用途: 禁用 ctrl+alt+del 组合键对系统重启 (必须要配置我曾入过坑) -- scripts/os-security.sh:355:# 函数名称: sec_recyclebin scripts/os-security.sh-356:# 函数用途: 设置文件删除回收站别名(防止误删文件)(必须要配置,我曾入过坑) -- scripts/os-security.sh:405:# 函数名称: sec_supolicy scripts/os-security.sh-406:# 函数用途: 切换用户日志记录和切换命令更改名称为SU(可选) -- scripts/os-security.sh:425:# 函数名称: sec_privilegepolicy scripts/os-security.sh-426:# 函数用途: 系统用户sudo权限与文件目录创建权限策略设置 -- scripts/os-service.sh:26:# 函数名称: svc_apport ``` -------------------------------- ### os-clean.sh Functions Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Contains functions for system cleanup, specifically removing temporary files and cache generated during the security hardening process to prepare for baseline imaging. ```APIDOC system_clean: Deletes temporary files and cache created during security hardening. ``` -------------------------------- ### Kubernetes Deployment Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md Illustrates the process of deploying the application using Kubernetes. It includes commands for creating a namespace, applying a StatefulSet configuration, and checking the status of the deployed pods. ```bash kubectl create ns devtest kubectl apply -f healthcode-sts.yaml kubectl get pod -n devtest ``` -------------------------------- ### Manage Cloud-init Services (os-service.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Disables or uninstalls cloud-init software and services in non-cloud environments. This function is part of the os-service.sh script. ```shell # 函数名称: svc_cloud-init # 函数用途: 非云的环境下禁用或者卸载多余的cloud-init软件及其服务 ``` -------------------------------- ### Docker Image Building Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md Provides commands for building a Docker image for the OCR service. It shows how to navigate to the Dockerfile directory and execute the docker build command with a specific tag. ```bash cd /opt/images/easyocr/ docker build -t harbor.weiyigeek.top/python/easyocr-healthcode:v1.6.2 . ``` -------------------------------- ### Manage Snapd Services (os-service.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Disables or uninstalls snap software and services in environments that do not use snapd containers. This function is part of the os-service.sh script. ```shell # 函数名称: svc_snapd # 函数用途: 不使用snapd容器的环境下禁用或者卸载多余的snap软件及其服务 ``` -------------------------------- ### Disable Debug Shell Service (os-service.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Disables the debug-shell service during system startup. This function is part of the os-service.sh script. ```shell # 函数名称: svc_debugshell # 函数用途: 在系统启动时禁用debug-shell服务 ``` -------------------------------- ### View GPU Server Status with nvidia-smi Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md The nvidia-smi command-line utility displays the status of NVIDIA GPU devices. It provides information on GPU utilization, memory usage, temperature, power consumption, and processes running on each GPU. This output is essential for monitoring and managing GPU resources in a server environment. ```bash nvidia-smi Fri Dec 9 10:08:32 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 465.19.01 Driver Version: 465.19.01 CUDA Version: 11.3 | |-------------------------------+----------------------+----------------------| | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA Tesla V1... Off | 00000000:1B:00.0 Off | 0 | | N/A 41C P0 36W / 250W | 6697MiB / 32510MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------| | 1 NVIDIA Tesla V1... Off | 00000000:1D:00.0 Off | 0 | | N/A 51C P0 53W / 250W | 9489MiB / 32510MiB | 14% Default | | | | N/A | +-------------------------------+----------------------+----------------------| | 2 NVIDIA Tesla V1... Off | 00000000:3D:00.0 Off | 0 | | N/A 53C P0 42W / 250W | 5611MiB / 32510MiB | 20% Default | | | | N/A | +-------------------------------+----------------------+----------------------| | 3 NVIDIA Tesla V1... Off | 00000000:3F:00.0 Off | 0 | | N/A 37C P0 35W / 250W | 10555MiB / 32510MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------| | 4 NVIDIA Tesla V1... Off | 00000000:40:00.0 Off | 0 | | N/A 45C P0 51W / 250W | 5837MiB / 32510MiB | 5% Default | | | | N/A | +-------------------------------+----------------------+----------------------| | 5 NVIDIA Tesla V1... Off | 00000000:41:00.0 Off | 0 | | N/A 37C P0 37W / 250W | 10483MiB / 32510MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 167660 C python 6693MiB | | 1 N/A N/A 166790 C python 9485MiB | | 2 N/A N/A 165941 C python 5607MiB | | 3 N/A N/A 165032 C python 10551MiB | | 4 N/A N/A 164226 C python 5833MiB | | 5 N/A N/A 163344 C python 10479MiB | +-----------------------------------------------------------------------------+ ``` -------------------------------- ### V1 & V2 API: Batch Directory Scan OCR Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md This API endpoint scans all supported image files within a specified directory for OCR processing. It supports both V1 and V2 versions of the tool. ```APIDOC GET /tools/ocr?dir= - Scans and processes all image files within a given directory. - Parameters: - dir: The path to the directory containing image files (e.g., '20220530'). - Note: This endpoint is available in both V1 and V2 versions. - Example: > http://127.0.0.1:8000/tools/ocr?dir=20220530 ``` -------------------------------- ### V1 API: Travel Code OCR (Alternative Path) Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md This snippet shows an alternative V1 API path for processing travel code images, specifically targeting files within a directory structure. ```APIDOC GET /tools/ocr?file= - Processes a specific travel code image file. - Parameters: - file: The path to the travel code image file (e.g., '20220530/0a1e948e90964d42b435d63c9f0aa268.png'). - Note: This is a V1 specific endpoint. - Example: > http://127.0.0.1:8000/tools/ocr?file=20220530/0a1e948e90964d42b435d63c9f0aa268.png ``` -------------------------------- ### V1 & V2 API: Upload OCR Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md This API endpoint allows for the upload of image files for OCR processing. It is used for single file recognition and is available in both V1 and V2 versions. ```APIDOC POST /tools/upload/ocr - Uploads an image file for OCR processing. - This endpoint is used for single file uploads and is available in both V1 and V2 versions. - Example: > http://127.0.0.1:8000/tools/upload/ocr ``` -------------------------------- ### V1 API: Travel Code OCR Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md This API endpoint processes a specified travel code image file using OCR. It extracts details such as travel history and dates. ```APIDOC GET /api/v1/ocr/health?action=xcm&file= - Processes a travel code image file for OCR. - Parameters: - action: Must be 'xcm' for travel code processing. - file: The path to the travel code image file (e.g., '20220530/001c35d7ac9844e78c15783bf7fda815.png'). - Returns: - JSON object containing: - code: HTTP status code (e.g., 200). - msg: A success message (e.g., '成功获取行程码数据.'). - data: An object with: - file: The processed image file path. - type: The recognized travel code status (e.g., '绿色'). - phone: Masked phone number (e.g., '153****2031'). - date: The date associated with the travel code (e.g., '2022.08.09'). - time: The time associated with the travel code (e.g., '08:34:10'). - travel: The travel destination information (e.g., '重庆市'). - Example: > http://127.0.0.1:8000/api/v1/ocr/health?action=xcm&file=20220530/001c35d7ac9844e78c15783bf7fda815.png {"code": 200, "msg": "成功获取行程码数据.", "data": {"file": "20220809/001c35d7ac9844e78c15783bf7fda815.png", "type": "绿色", "phone": "153****2031", "date": "2022.08.09", "time": "08:34:10", "travel": "重庆市"}} ``` -------------------------------- ### Disable Apport Error Reporting (os-service.sh) Source: https://github.com/weiyigeek/secopsdev/blob/master/OperatingSystem/Security/Ubuntu/Readme.md Disables the 'apport' service, which is responsible for error reporting on Ubuntu systems. This function is part of the os-service.sh script. ```shell # 函数用途: 禁用烦人的apport错误报告 ``` -------------------------------- ### V1 API: Health Code OCR Source: https://github.com/weiyigeek/secopsdev/blob/master/Project/Python/EasyOCR/Travelcodeocr/Readme.md This API endpoint is used to perform OCR on a specified health code image file. It returns the recognized status of the health code. ```APIDOC GET /api/v1/ocr/health?action=jkm&file= - Processes a health code image file for OCR. - Parameters: - action: Must be 'jkm' for health code processing. - file: The path to the health code image file (e.g., '20220809/118d180d2dc540109d9ab2e22b1529ea.jpg'). - Returns: - JSON object containing: - code: HTTP status code (e.g., 200). - msg: A success message (e.g., '成功获取健康码图片数据为有健康码状态.'). - data: An object with: - file: The processed image file path. - type: The recognized health code status (e.g., '黄码'). - Example: > http://127.0.0.1:8000/api/v1/ocr/health?action=jkm&file=20220809/118d180d2dc540109d9ab2e22b1529ea.jpg {"code": 200, "msg": "成功获取健康码图片数据为有健康码状态.", "data": {"file": "20220809/118d180d2dc540109d9ab2e22b1529ea.jpg", "type": "黄码"}} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.