动态 版块 发帖 消息 我的
Loading...
小绿叶技术博客
小绿叶技术博客
子版块
admin
141
安装 shellgpt 语言工具:https://www.lxlinux.net/13488.html
 1   0  34天前
admin
152
#---- Pcan PcanPro 接线 + 电阻对照表 ----# VGA 接口: . . . . . . . . . 9 8 7 6 5 4 3 2 1 1. V bat + 2. CAN_L 3. GND 4. LIN Data 5. 未定义 6. GND 7. CAN_H 8和9 未定义 软件使用: BASMASER : 顶部导航栏:LIN -> DriverSelection -> PEAK USB -> 导入 ldf 文件 CAN 两根线之间连接一个电阻形成回路(短路电阻): 120 欧姆电阻 色环电阻对照表 棕 红 橙 黄 绿 蓝 紫 灰 白 黑 金 银 1 2 3 4 5 6 7 8 9 0 误差5% 误差 10% 【倍率】 倒数第二环: 最后一环金色 或 银色 的前1位色环位;倍率单位:欧姆 棕 红 橙 黄 绿 蓝 紫 灰 白 黑 10^1=10 10^2=100 10^3=1000 10^4 10^5 10^6 10^7 10^8 10^9 10^0=1 【四色环电阻】 1. 距离较大的一环为误差 2. 第1,2 环 两位有效阻值 第三环为倍率 案例:棕红棕 金 12x 10^1= 120欧姆 【5色环】 倒数第二环为倍率 增加倍率代表:金色 为 0.1倍,倒数1环(第5环)为误差 【3色环】 色环:第1位 十位数 ;第二位 个位数; 第三位 误差
 1   0  39天前
admin
224
接线笔记: j-link 有两种模式: JTAG 和 SWD 模式 一般用 SWD : J-link 串口有个缺口正对向左(j-link 有图文一面向左 立起看) 1: VCC + 2: VCC 3: n/u 4: GND + 5: n/u 6: GND + 7: SWDIO + 8: GND 9: SWCLK + 10: GND 11: N/U 12: GND 13: SWO 14: GND 15: RESET + 16: GND 17: N/C 18: GND 19: N/C 20: GND # + 号是需要接线的 #--- FS32K142H 电路图 ---# 烧录接口电路: 1: 5V 2: SWDIO 3: GND 4: SWDCLK 5: GND 6: RESET FS32K142H 对应 J-link 接线 1 - 1 2 - 7 3 - 4 4 - 9 5 - 6 6 - 16 配置方法: 红色线正对面左第一个进行捆绑 #---------- TEST 板子竖着看,标有 J2 的一边方向向左 (串口针为分界线 短的一头向外,长的一头向内) 第一个引脚为正极,2和3 为接地。(用万用表二极管测试功能,测试连通性,联通的两端为接地) j-link 问题:No Cortex-M SW Device Found 接口线接错了 注意: debug 调试不需要 boot ; 上位机烧录需要debug
 1   0  53天前
admin
130
环境配置nano /etc/profile#### jdk ####export JDK_HOME=/datadisk/eisc/server/path/jdk-20.0.2/binexport PATH=${JDK_HOME}:$PATH#### MVN ####export MVN_HOME=/datadisk/eisc/server/path/apache-maven-4.0.0-alpha-7/binexport PATH=${MVN_HOME}:$PATH# 目录根据实际修改reboot#  重启生效。或者: source /etc/profle ; bash  刷新1. jdkwget work.eisc.cn/ruanjian/ubuntu/deb/server/jdk-20_linux-x64_bin.tar.gz2.mavenwget work.eisc.cn/ruanjian/ubuntu/deb/bin//apache-maven-4.0.0-alpha-7-bin.tar.gzmvn archetype:generate -DgroupId=com.example -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false# 配置 mvn poxnano pom.xml# 在maven 根目录下 写入下面信息<project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.example</groupId>    <artifactId>my-app</artifactId>    <version>1.0-SNAPSHOT</version>    <properties>        <maven.compiler.source>1.8</maven.compiler.source>        <maven.compiler.target>1.8</maven.compiler.target>    </properties>    <dependencies>        <!-- 添加您需要的依赖项 -->    </dependencies></project>mvn install ; mvn clean install#在maven 根目录下 执行命令
 1   0  54天前
admin
150
sudo apt-get install lutris# lutris  游戏模拟器需要 wine32:i386 支持sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install wine32:i386 https://github.com/lutris/dxvk/releases/download/v2.2/dxvk-2.2.tar.xz https://github.com/lutris/dxvk-nvapi/releases/download/v0.6.3/dxvk-nvapi-v0.6.3.tar.xz https://github.com/lutris/vkd3d/releases/download/v2.9/vkd3d-v2.9.tar.xzhttps://github.com/lutris/dgvoodoo2/releases/download/v2.8/dgvoodoo2-v2.8.tar.xzhttps://github.com/lutris/d3d_extras/releases/download/v2/v2.tar.xzgithub.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton8-13/wine-lutris-GE-Proton8-13-x86_64.tar.xzlutris-GE-Proton8-13-x86_64/bin/wine /home/eisc/下载/WeChatSetup.exe# 安装命令卸载 wine :sudo apt remove wine32:i386 -ysudo rm -rf ~/.wine/
 1   0  56天前
admin
141
wget work.eisc.cn//ruanjian/ubuntu/deb/tools/chrome.tar.gz# 研究已经安装 deb 包,使用程序方式打开google自动创建 图标 
 1   0  58天前
admin
163
#include <stdio.h> #include <mysql/mysql.h> // 定义数据库连接信息 #define DB_HOST "localhost" #define DB_USER "root" #define DB_PASS "password" #define DB_NAME "testdb" int main() { MYSQL *conn; // MySQL连接 MYSQL_RES *res; // MySQL查询结果 MYSQL_ROW row; // MySQL行数据 conn = mysql_init(NULL); // 连接到数据库 if (!mysql_real_connect(conn, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(conn)); return 1; } // 查询数据 if (mysql_query(conn, "SELECT * FROM users")) { fprintf(stderr, "Failed to query database: Error: %s\n", mysql_error(conn)); return 1; } res = mysql_use_result(conn); // 输出查询结果 printf("ID\tName\n"); while ((row = mysql_fetch_row(res)) != NULL) { printf("%s\t%s\n", row[0], row[1]); } // 插入数据 if (mysql_query(conn, "INSERT INTO users (id, name) VALUES (1, 'John')")) { fprintf(stderr, "Failed to insert data: Error: %s\n", mysql_error(conn)); return 1; } // 更新数据 if (mysql_query(conn, "UPDATE users SET name='Tom' WHERE id=1")) { fprintf(stderr, "Failed to update data: Error: %s\n", mysql_error(conn)); return 1; } // 删除数据 if (mysql_query(conn, "DELETE FROM users WHERE id=1")) { fprintf(stderr, "Failed to delete data: Error: %s\n", mysql_error(conn)); return 1; } // 释放资源 mysql_free_result(res); mysql_close(conn); return 0; }
 1   0  60天前
admin
161
如果你想在Ubuntu上搭建一个在线流程图的平台,你可以使用开源的项目来实现。其中一个流行的开源项目是draw.io,它提供了一个基于Web的流程图绘制工具。 要在Ubuntu上安装draw.io的源码,你可以按照以下步骤进行操作: 安装Java开发工具包(JDK): sudo apt update sudo apt install default-jdk 安装Apache Maven构建工具: sudo apt install maven 克隆draw.io的源码仓库: git clone https://github.com/jgraph/drawio.git 进入draw.io目录并使用Maven构建项目: cd drawio mvn clean package 构建完成后,在draw.io/target/目录下会生成war文件。将war文件部署到Tomcat或其他Java Web服务器中。 以上步骤会从draw.io的GitHub仓库克隆最新的源码,并使用Maven构建项目。你可以根据自己的需要进行修改和定制。 请注意,这只是一个基本的安装过程,你可能还需要进行其他配置和依赖项的安装,具体取决于你的环境和需求。你可以参考draw.io的官方文档和GitHub仓库以获取更详细的信息和指导。环境配置nano /etc/profile#### jdk ####export JDK_HOME=/datadisk/eisc/server/path/jdk-20.0.2/binexport PATH=${JDK_HOME}:$PATH#### MVN ####export MVN_HOME=/datadisk/eisc/server/path/apache-maven-4.0.0-alpha-7/binexport PATH=${MVN_HOME}:$PATH# 目录根据实际修改reboot#  重启生效。或者: source /etc/profle ; bash  刷新1. jdkwget work.eisc.cn/ruanjian/ubuntu/deb/server/jdk-20_linux-x64_bin.tar.gz2.mavenwget work.eisc.cn/ruanjian/ubuntu/deb/bin//apache-maven-4.0.0-alpha-7-bin.tar.gzmvn archetype:generate -DgroupId=com.example -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false# 配置 mvn poxnano pom.xml# 在maven 根目录下 写入下面信息<project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.example</groupId>    <artifactId>my-app</artifactId>    <version>1.0-SNAPSHOT</version>    <properties>        <maven.compiler.source>1.8</maven.compiler.source>        <maven.compiler.target>1.8</maven.compiler.target>    </properties>    <dependencies>        <!-- 添加您需要的依赖项 -->    </dependencies></project>mvn install ; mvn clean install#在maven 根目录下 执行命令################ 安装在线流程图 ####################git clone https://github.com/jgraph/drawio.gitcd ./frawio/drawio/my-appmvn clean package在目录:./frawio/drawio/my-app/target 生成 tar包
 1   0  60天前
admin
164
在C语言中,当你要传递一个变量的地址而不是变量的值时,你需要使用&操作符。这通常用于传递指针或引用类型的参数。 以下情况下需要使用&操作符: 1. 指针类型: 定义 void foo(int* ptr) 调用 int num = 10; foo(&num); 2. 修改函数外部的变量 void modify(int* ptr){ *ptr = 20; } 调用:int num = 10; modify(&num); 最终将 ptr修改为 10 3. 输入 scanf 函数 int num; scanf("%d", &num); 传递的是基本类型的变量或者数组时,不需要使用&操作符,因为它们会被自动传递为值。例如,`void foo(int num)`,你可以直接传递变量的值来调用它,例如`int num = 10; foo(num);`。 需要注意的是,使用&操作符传递变量的地址时,需要确保接收参数的函数能够处理指针类型的参数。
 1   0  60天前
admin
149
如果要存储超长的文本数据,可以考虑使用动态内存分配来存储文本。在C语言中,可以使用malloc函数来动态分配内存空间,并使用char类型的指针来存储文本数据。 下面是一个示例代码,展示了如何使用动态内存分配来存储超长的文本数据: #include <stdio.h> #include <stdlib.h> int main() { // 假设文本数据长度为10000 int length = 10000; // 动态分配内存空间 char* text = (char*)malloc(length * sizeof(char)); // 检查内存分配是否成功 if (text == NULL) { printf("Failed to allocate memory\n"); return 1; } // 读取文本数据到动态分配的内存空间中 // 这里使用fgets函数从文件中读取文本数据 FILE* file = fopen("text.txt", "r"); if (file == NULL) { printf("Failed to open file\n"); free(text); // 释放动态分配的内存空间 return 1; } fgets(text, length, file); // 关闭文件 fclose(file); // 打印文本数据 printf("%s\n", text); // 释放动态分配的内存空间 free(text); return 0; } 上述代码中,我们首先使用malloc函数动态分配了一个长度为length的字符数组,并将返回的指针赋值给text。然后,我们使用fgets函数从文件中读取文本数据并存储到动态分配的内存空间中。最后,我们使用printf函数打印出文本数据。
 1   0  62天前
admin
178
在C语言中,可以使用printf函数来打印不同类型的数值。下面是一些常见的数据类型及其对应的printf格式说明符: 整数类型: int %d short %hd long %ld long long %lld 无符号整数类型: unsigned int %u unsigned short %hu unsigned long %lu unsigned long long %llu 字符类型: char %c 浮点数类型: float %f double %lf 指针类型: void* %p 以下是示例代码,展示如何使用printf打印不同类型的数值: #include <stdio.h> int main() { int num1 = 10; float num2 = 3.14; char ch = 'A'; char str[] = "Hello"; printf("Integer: %d\n", num1); printf("Float: %f\n", num2); printf("Character: %c\n", ch); printf("String: %s\n", str); return 0; } 在上述示例中,我们定义了一个整数变量num1,一个浮点数变量num2,一个字符变量ch,以及一个字符串数组str。 然后,我们使用printf函数打印了这些变量的值,分别使用了对应的格式说明符。执行上述代码后,将会打印出相应的数值。
 1   0  62天前
admin
177
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/ip.h> #include <netinet/tcp.h> #include <netinet/udp.h> #include <netinet/ip_icmp.h> #define BUFFER_SIZE 4096 void process_packet(unsigned char *buffer, int size) { struct iphdr *ip_header = (struct iphdr *)(buffer); unsigned short ip_header_length = ip_header->ihl * 4; struct tcphdr *tcp_header = (struct tcphdr *)(buffer + ip_header_length); unsigned short tcp_header_length = tcp_header->doff * 4; unsigned char *payload = buffer + ip_header_length + tcp_header_length; int payload_length = size - ip_header_length - tcp_header_length; // 在这里处理报文内容,可以打印报文信息或对报文进行其他操作 printf("Received packet with size: %d\n", size); } int main() { int raw_socket; unsigned char buffer[BUFFER_SIZE]; struct sockaddr_in server_address; int data_size; // 创建原始套接字 raw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_TCP); if (raw_socket < 0) { perror("Failed to create socket"); return 1; } // 绑定地址 server_address.sin_family = AF_INET; server_address.sin_port = 0; server_address.sin_addr.s_addr = INADDR_ANY; if (bind(raw_socket, (struct sockaddr *)&server_address, sizeof(server_address)) < 0) { perror("Failed to bind"); return 1; } // 开始监听 while (1) { data_size = recvfrom(raw_socket, buffer, BUFFER_SIZE, 0, NULL, NULL); if (data_size < 0) { perror("Failed to receive"); return 1; } process_packet(buffer, data_size); } return 0; }
 1   0  64天前
admin
186
##!/bin/python # 解释器路径,linux 下需要写 #!/bin/python import os import re import sys file_path = os.path.abspath(__file__) # 获取当前文件路径 dir_path = os.path.dirname(file_path) # 获取 文件的 路径 print("The current file is at: " + file_path) print("The directory of the current file is at: " + dir_path) #批量修改文件名 #批量修改图片文件名 zidir="1" # 定义子路径 DirPath = os.path.join(dir_path, zidir) # 拼接路径: 变量路径(当前路径)+子路径 print("#------------ 拼接路径: "+str(DirPath)) def renameall(): # 定义函数 fileList = os.listdir(DirPath) # listdir 函数 获取目录和文件 print("修改前:"+str(fileList)) # 输出文件夹中包含的文件 currentpath = os.getcwd() # 获取当前工作目录 os.chdir(DirPath) # chdir 改变当前工作路径 num=1 # 名称变量 for fileName in fileList: # 定义 fileName 是 fileList 数组的所有元素,并for 循环全部遍历 pat=".+\.(jpg|png|gif|py|txt)" # 匹配文件名(后缀文件)正则表达式 pattern = re.findall(pat,fileName) # 再列表 fileName 中查找 后缀名 pat 匹配的文件,最终成为一个列表 os.rename(fileName,(str("eiscSetOK_")+str(num)+'.'+pattern[0])) # 文件重新命名函数 num = num+1 # 改变编号,继续下一项 print("------------------------- file --------------------------") os.chdir(currentpath) # 改回程序运行前的工作目录 sys.stdin.flush() # 刷新 print("修改后:"+str(os.listdir(DirPath))) # 输出修改后文件夹中包含的文件 renameall() # 执行定义的函数 #---------- 修改文件内容 -----------# import os file="eiscSetOK_1.txt" fileset=os.path.join(DirPath,file) # 定义需要修改的文件 def replace_line_with_keyword(file_name, keyword, new_line): with open(file_name, 'r') as file: lines = file.readlines() with open(file_name, 'w') as file: for line in lines: if keyword in line: file.write(new_line + '\n') else: file.write(line) def main(): file_name = fileset keyword = input("请输入要匹配的关键字:") new_line = input("请输入新的行内容:") replace_line_with_keyword(file_name, keyword, new_line) print("文件内容替换成功!") if __name__ == "__main__": main() #----- 在函数中调用其他函数 -----# def calculate_sum(a, b): return a + b def calculate_product(a, b): return a * b def calculate_sum_and_product(a, b): # 定义运行函数,来调用上面两个函数 sum_result = calculate_sum(a, b) # 定义变量 的结果为 执行函数传入数值运行的结果 product_result = calculate_product(a, b) # 返回计算得到的和与积 return sum_result, product_result # 反馈两个变量函数 # 调用calculate_sum_and_product函数,并获取它的返回值 sum_result, product_result = calculate_sum_and_product(5, 3) # 定义两个变量 等于函数传入的数值结算结果 print("The sum is:", sum_result) print("The product is:", product_result)
 1   0  64天前
admin
613
#--- 开启远程桌面 ---#sudo apt install -y xrdp# 方法一安装 xrdp 远程工具,缺点: 图像延迟#方法二: 缺点:锁屏下无法登陆设置 > 共享 > 远程桌面 > 开启远程桌面 和 远程控制, 认证 设置密码设置 > 共享 > 远程登陆 > 开启#--- 合盖不休眠 ---# NR=`cat -n /etc/systemd/logind.conf | grep -w HandleLidSwitch | awk -F" " '{print $1}'`if  [ $NR -gt 0 ];           then          sudo sed -i "$NR s/HandleLidSwitch.*/HandleLidSwitch=lock/g" /etc/systemd/logind.conf ;   sudo sed -i "$NR s/#//g" /etc/systemd/logind.conf;  echo "[ok] set file" ;      else       echo "[error] NR is null";       fi# 修改为 lock 锁屏# if 语句 为了避免错误修改,判断NR的数值大于0 才进行修改# 将 井 号替换为空cat -n /etc/systemd/logind.conf | grep HandleLidSwitch
 2   2  67天前
admin
458
信号由: 名称 name + 信号的数值 status 1 开 0 关等等。 B: Byte: 字节 8 位无符号数 范围 0-255 b: bit: 位 二进制中每个 0 或 1 就是一个位 bit 位说明: 从右 0 开始 向左数 最大为 7 即 0-7 表示 : 7 6 5 4 3 2 1 0 位置 #--- 编码:UTF8 ---# 1个汉字 = 3B = 3x8b = 24b 1个字母 = 1B = 1x8b = 8b 1个数字 = 1B = 1x8b = 8b 计算公式: 2^N - 1 uint8_t : 1 占用1位,0或1 最大 1 转换2进制 1 uint8_t : 2 占用2位,0到3之间的整数 最大 3 转换2进制 11 uint8_t : 3 占用3位,0到7 最大 7 转换2进制 111 = 2^3-1 = 8-1=7 uint8_t : 4 占用4位,0到15 最大 15 转换2进制 1111 uint8_t : 5 占用5位,0到31 uint8_t : 6 占用6位,0到63 uint8_t : 7 占用7位,0到127 在上一位的基础上 x2-1 最多只能表示 8 位二进制数 ,超过8位无效,可以换成 unit16_t 等 (由 10转2进制得来长度 如 7 转2 为 111 占3位) data->name = (can2A5[2]&0x07); // 最大为 111 即 7 即 0x07 但是根据矩阵表 最大为 3 即 二进制 11 模式 为 0 1 2 3 对应吹面,吹面吹脚,吹脚,吹脚吹窗,吹窗 // can2A5报文中 的 第二个字节监听后 (0x07 是16进制 转换2进制为 111 占3位二进制内存 3bit) 三位二进制 data->name = (can2A5[3]&20)>>5 // 此处不是进行与计算,而 20 换算成二进制 0001 0100 占用5位二进制有效 向右移动五位,也就是去掉右边的5位,等于 第6位的结果,就是它的值 数据类型 占用空间 表示范围 说明 uint8_t 8b = 1B 0 到 255 占8位(单位 b) = 占1字节 (单位 B) 8 为由来: 255转二进制:1111 1111 为8 位 uint16_t 16b = 2B 0 到 65535 65535 转 二进制: 1111 1111 1111 1111 正好 16 位 uint32_t 32b = 4B 0 到 4294967295 uint64_t 64b = 8B 0 到 18446744073709551615 占 64 位 = 8 字节 #------- 结构体写入和读取方法 -----------# uint8_t eisc2F1[7]; // 定义 数组为 uint8_t 是 8位类型,但数组有8个元素(从0开始),因此 有8个 8位的类型。 因为 8位=1字节,因此该数组有8个字节大小 typedef struct { uint8_t lock; }eiscdataJGT; // 定义结构体 eiscdataJGT extern eiscdataJGT eiscdata; // 将结构体 eiscdataJGT 写入到内存变量结构体 eiscdata ,可以通过 eiscdata.lock 读取和赋值 eiscdataJGT eiscdata; // 其他c文件声明结构体才能使用结构体变量 void eisc(eiscdataJGT *eisczz){ // 将结构体 继承给指针,可以通过指针方式进行读取和赋值到原结构体 eisczz->lock = (eisc2F1[4]&0x30)>>4; // 最大3: 0x30=0011 0000 右移 4位 0000 0011=3 ,原信号在第五位开始有效。 // 并且 该信号占第5和第6 两位长度二进制 11 ,因此就在第五位。 第五位为1: 1 0000 (状态 1开 ,0关) printf("信号的数值为:%d",eiscdata.lock); // 读取结构体变量的数值 } 8位原始数据: 0000 0000  对应顺序:7 6 5 4 3 2 1 0;  右移:从右往左数;   左移:从左往右数  eisca[0]=0x20;   // 内外循环:eiscdata->_fr = (eisca[0]&0x20)>>5;            // 最大为1:  0x20=0010 0000 右移 5 位 0000 0001=1  目前在第6位上发送了最大值 1 表示开启: 0010 0000 = 0x20 按键按下是外循环  eiscf[3]=0x80;     // 洗涤开  :  eiscdata->xidi = (eiscf[3]&0x80)>>7;       // 最大为1: 0x80=1000 0000 右移 7 位 0000 0001=1  目前在第7位上发送了最大值 1 表示开启: 1000 0000 = 0x80 eisc87[6]=0x3E;     // 天窗开度 eiscdata->eisctc = (eisc87[6]&0xFE)>>1;         // 最大为:0xFE=1111 1110 右移1位 0111 1111=127  目前在第2到7位上发送了 0x3E = 0011 1110 = 62;  62/2=31 结果除以为 31度  eisca[3]=0x34;     // 蓝牙信号:eiscdata->eisctx = (eisca[3]&0x20)>>5;         // 最大1: 0x20=0010 0000 右移5位 0000 0001 目前在第6位发送信号:0010 0000 + 下面设定温度20度组合  // eiscc_temp // 空调设定温度: eiscdata->eisc_temp = (eisctemp[3]&0x1F);  // 最大为31: 0x1F=0001 1111=31 占用 1-5 位 ; 设定温度20度=0001 0100  与蓝牙信号 0010 0000 组合(相或)为:0011 0100=0x34     长度    信号位置eisctemp 1 4               第4位,占一位
 1   0  141天前
admin
239
sudoc=sudo nginx_Compilation_method() { $sudoc chmod 777 -R ./ ./configure --prefix=./ --with-stream --with-http_stub_status_module # nginx 开启 tcp 和 文件浏览模块: --with-stream --with-http_stub_status_module NR=`cat -n ./src/os/unix/ngx_user.c | grep cd.current_salt | awk -F" " '{print $1}'` ; sleep 0.5 $sudoc sed -i "$NR d" ./src/os/unix/ngx_user.c ; sleep 0.5 $sudoc sed -i "s/-Werror/ /g" objs/Makefile ; sleep 0.5 # 先修改 c 文件,再修改make $sudoc mkdir $setdir/logs ; $sudoc chmod 777 $setdir/logs $sudoc make ; sleep 1 # make 会生成 新文件,新文件也需要修改才能编译 $sudoc sed -i "s/-Werror/ /g" objs/Makefile ; sleep 0.5 $sudoc make install nginx_file_list } nginx_file_list() { echo " sudo nano conf/nginx.conf # http 模块外面写 tcp 配置路径: include /www/wwwconf/tcp/*.conf; # http 模块 里面 http{} 写: include /www/wwwconf/http/*.conf; sudo mkdir -p /www/wwwconf/tcp /www/wwwconf/http ; sudo chmod 777 -R /www/wwwconf/* sudo nano /www/wwwconf/http/web.conf # 开启文件浏览器功能 server{ listen 800; #server_name eisc.cn root /datadisk/eisc/download; location / { #root /mnt/software; #我们开始新建的目录 autoindex on; #以列表信息显示目录文件 index index.html index.htm; charset utf-8; } } sudo nano /www/wwwconf/tcp/tcp.conf # tcp 转发 stream { upstream eisc { server 8.219.134.200:1180; } server { listen 1180; proxy_pass eisc; } } " }
 1   0  85天前
admin
232
sudo apt install gnome-tweaks -y sudo apt reinstall -y gnome-shell-extensions sudo reboot # 重启电脑 wget http://work.eisc.cn/ruanjian/ubuntu/gnome/Cupertino-Catalina.tar.gz wget http://work.eisc.cn/ruanjian/ubuntu/gnome/Sierra-light.tar.gz wget http://work.eisc.cn/ruanjian/ubuntu/gnome/Minimal-Conception.tar.gz sudo tar -xzvf Cupertino-Catalina.tar.gz sudo tar -xzvf Sierra-light.tar.gz sudo tar -xzvf Minimal-Conception.tar.gz sudo cp -R Sierra-light /usr/share/themes/ sudo cp -R Minimal-Conception /usr/share/themes/ # 主题+shell sudo cp -R Cupertino-Catalina /usr/share/icons/ # 图标 # 安装后,需要设置 扩展 运用软件 -> 下滑到 User Themes Load shell thems 打开这个功能 gnome-tweaks # 点击外观 shell 选择 Minimal # 点击运用程序 选择 Sierra-light # 点击 图标 选择: Cupertino-Catalina # 窗口标题栏 -> 标题栏按钮 -> 放置 -> 左 # 设置 -> 外观 -> dock -> 面板模式(关) -> 屏幕上的位置 (底部) # 设置 -> Dock > 面板模式 : 将 Dock 延伸至屏幕边缘 -> 关闭
 3   1  58天前
admin
203
nautilus  ./  # 打开当前目录下的文件管理器
 1   0  93天前
admin
212
命令窗口输入命令: nm-connection-editor # wifi 设置 # 需要删除之前创建的 wifi : 光标选中 已创建的 点击 减 号 # 创建:点击 + 号 -> 选择连接类型 -> (硬件 wifi ) -> 创建 -> # 连接名称: eisc -> SSID eisc -> 模式 : 热点wifi -> 频段 5G # 设备:选择网卡 -> wi-Fi 安全性: WPA 及 WPA2 个人 -> 密码: aaaassss # 常规:取消勾选: 自动以优先级连接 # 保存 (热点自动打开) # 设置 -> wifi -> 右上角 三点多选 展开 -> 打开 wifi 教程: https://blog.csdn.net/weixin_48319333/article/details/129901969
 1   0  96天前
admin
202
sudo service NetworkManager stop  ; sudo rm -rf  /var/lib/NetworkManager/NetworkManager.state  ; sudo service NetworkManager start
 1   0  96天前
admin
431
在C语言中,一个文件可以使用不同的编码格式。如果您想将文件从其他编码格式转换为UTF-8编码格式,可以使用以下步骤: 确定原始文件的编码格式。可以使用文本编辑器或专门的编码检测工具来完成。 在C语言中打开原始文件,并使用适当的编码格式读取文件内容。 创建一个新的UTF-8编码格式的文件,并将读取的内容写入该文件中。在写入过程中,必须确保将原始编码格式转换为UTF-8编码格式。 关闭原始文件和新文件,完成文件转换。 下面是一个示例程序,用于将一个以GB2312编码格式保存的文件转换为UTF-8编码格式: #include <stdio.h> #include <stdlib.h> #include <locale.h> int main() { // 设置本地化环境 setlocale(LC_ALL, ""); // 打开原始文件 FILE* fp_in = fopen("input.txt", "rb"); if (!fp_in) { printf("无法打开原始文件\n"); return 1; } // 打开新文件 FILE* fp_out = fopen("output.txt", "wb"); if (!fp_out) { printf("无法创建新文件\n"); return 1; } // 逐个读取原始文件中的字符,并将其转换为UTF-8格式写入新文件中 int ch; while ((ch = fgetc(fp_in)) != EOF) { wchar_t wc = (wchar_t)ch; char utf8[4]; int len = 0; if (wc < 0x80) { utf8[0] = (char)wc; len = 1; } else if (wc < 0x800) { utf8[0] = (char)(0xc0 | (wc >> 6)); utf8[1] = (char)(0x80 | (wc & 0x3f)); len = 2; } else if (wc < 0x10000) { utf8[0] = (char)(0xe0 | (wc >> 12)); utf8[1] = (char)(0x80 | ((wc >> 6) & 0x3f)); utf8[2] = (char)(0x80 | (wc & 0x3f)); len = 3; } else if (wc < 0x110000) { utf8[0] = (char)(0xf0 | (wc >> 18)); utf8[1] = (char)(0x80 | ((wc >> 12) & 0x3f)); utf8[2] = (char)(0x80 | ((wc >> 6) & 0x3f)); utf8[3] = (char)(0x80 | (wc & 0x3f)); len = 4; } fwrite(utf8, 1, len, fp_out); } // 关闭文件 fclose(fp_in); fclose(fp_out); printf("文件转换完成!\n"); return 0; } 请注意,这只是一个示例程序,您需要根据您的具体需求进行修改和调整。同时,该程序只支持将单个字符从其他编码格式转换为UTF-8编码格式,如果文件中包含多字节字符或复杂字符集,您可能需要使用其他更加复杂的算法来完成转换。
 1   0  116天前
admin
381
结构体成员: 为变量只能定义一个字符,定义为指针 可以存放多个字符(字符串)#include <stdio.h> struct Foo { char *a; // 指针可以存放多个字符串,变量只能存一个 int b; double c; }foo1, foo2; //define two structs with three different fields void struct_assign(void) { foo2 = foo1; //structure directly assignment } int main() { foo1.a = "eisc is 结构体字符串 "; foo1.b = 1; foo1.c = 3.14; struct_assign(); // 函数 将结构体 1 赋值 给 2 printf("%s %d %lf\n", foo2.a, foo2.b, foo2.c); // 写入的是 1 读取的是 2 , 由于前赋值相等原因 1 和 2 相等 return 0; }
 1   0  125天前
admin
289
$a$b=$y$k     # 带美元符号的变量  这样赋值会报错:有歧义的重定向eval $a$b=$y$k      # 动态变量的写入:eval 关键字是 shell 中动态变量 给带美元符号的变量赋值,则合规。     # 一般情况: 加美元符号的变量 是获取打印 其值,而不能被定义值     # 等号右边是获取数值 因此美元符号合规。左边是定义变量 shell 不允许变量这种形式定义,加参数 eval 则合规动态变量CmakeFile=$(echo '$'${b}${a})     # 动态变量的读取
 1   0  125天前
admin
322
算术运算符,关系运算符,逻辑运算符,位运算符,赋值运算符 #---- 算术运算符 ----# + - * / % ++ -- // 加减乘除, 取余,自增运算符整数增加1 在循环中使用普遍,减减 自减少 #---- 关系运算符 ----# == != > < >= <= // 在 if 判断中: 相等,不相等,大于,小于,大等于,小等于 条件成立为真 #---- 逻辑运算符 ----# && || ! // 逻辑与 二进制位相乘以结果不为0 为真; 逻辑或 位相加的结果不为0 为真 // 逻辑非 逆转状态, 当为 0 的时候 逻辑非至反为 1 #---- 位运算符 ----# & | ^ // 与 :换算成 2 进制,每一位进行相与(乘积)计算的结果; 或: 二进制相与(相加) 计算 // 异步: 二进制每一位对应位计算,如: 第一位: a 和 b 两个二进制变量。 全0 为0; 有1为1;全1为0: 1^1=0; 0^0=0; 1^1=0; 二进制每一位都按照这个规则计算 << // 二进制 左移: A = 0011 1100 ; 操作 A << 2 整体左移两个位置为: 11 1100 右边补0为 : 1111 0000 >> // 二进制 右移: A = 0011 1100 ; 操作 A >> 2 整体右移两个位置为: 00 1111 左边补0为 : 0000 1111 正数补0 负数补1 #---- 赋值运算符 ----# 定义参数案例: int A=21; int B ; = += -= // 变量等于值; 变量=变量本身+等于符号右边值; 变量=变量本身-等于符号右边值 // B += A 是两层运算:第一层运算为赋值: B=A=21; 第二层运算为 本身等于 本身和 等号右边 加法: B=B+A=21+21=42 *= /= // B *= A 是两层运算:第一层运算为赋值: B=A=21; 第二层运算为 B=B*A=441 %= // B %= A; B=B%A = 21%21 =0; 取余数, 被整除了。余数为0 <<= // 左移位 且赋值运算 >>= // 右移位 且赋值运算 &= // 按位 与 且赋值运算 ^= // 按位异或 且 赋值 |= // 按位或 且赋值
 1   0  146天前
admin
338
#include <stdio.h> #include <string.h> #include <math.h> int s10z16() { int x; printf("请输入10进制数,转为 16 进制: "); scanf("%d", &x); char arr[100] = { 0 }; //因为十六进制中会出现A\B\C\D\E\F等字符,所以保存余数的数组类型应定义为char int i = 0, j = 0; while (x) { arr[i++] = x % 16; x /= 16; } for (j = 0; j < i; j++) { //将取出的余数转换为对应的字符 switch (arr[j]) { case 10:arr[j] = 'A'; break; case 11:arr[j] = 'B'; break; case 12:arr[j] = 'C'; break; case 13:arr[j] = 'D'; break; case 14:arr[j] = 'E'; break; case 15:arr[j] = 'F'; break; default:arr[j] += 48; } } for (j = i - 1; j >= 0; j--) { printf("%c", arr[j]);//逆序打印 } printf("\n"); return 0; } void s16z10() { int a=0; int i=0; printf("请输入16进制数: "); scanf("%x",&a); printf("%d",a); } void s10z2() { int num;int temp;int i=0; int arr[999]; printf("请输入一个十进制数:"); scanf("%d", &num); do { temp=num%2; num=num/2; arr[i++]=temp; } while (num!=0); for (int j = i-1; j>=0; j--) printf("%d",arr[j]); printf("\n"); } int main() { int grade; printf("请选择需要被转换的进制类型 1. 10转2进制; 2. 16转10进制; 3. 10转2进制 : "); scanf("%d", &grade); printf("当前输入的值为: %d \n",grade); /* 局部变量定义 */ switch(grade) { case 1 : printf("当前是十转十六进制\n" ); s10z16(); break; case 2 : printf("十六转十进制\n" ); s16z10(); break; case 3 : printf("十转二进制\n" ); s10z2(); break; default : printf("输入错误,请重新输入...\n" ); } return 0; }
 1   1  147天前
admin
418
#!/bin/bash # 自动化编译 c/c++ dir=`pwd` ; echo "欢迎使用自动化汇编程序,当前路径为: $dir" touchCMake(){ sudo touch CMakeLists.txt ; sudo chmod 777 CMakeLists.txt ; echo " project(eisc) #项目名 cmake_minimum_required(VERSION 3.10) # 编译要求:cmake 要大于最低版本 3.1 set(CMAKE_C_COMPILER "gcc") set(CMAKE_CXX_COMPILER "g++") # 设置编译器, 如果没有配置环境变量,可以改为gcc具体文件路径 include_directories(a) include_directories(a) include_directories(a) # 添加 头文件搜索路径 (mysql.h 搜索路径) #add_executable("xx" xx.c ) add_executable("xunhuan" xunhuan.c ) # 生成可执行文件: 将 test.cpp 编译成 test.exe 可执行文件 # rm -rf ./build ; cmake ./ -Bbuild -G "Unix Makefiles" ; cmake --build build # rm -rf ./build ; cmake ./ -Bbuild ; cmake --build build # 编译到当前目录下的 build 文件夹 # 也可以不用指定 -G " > CMakeLists.txt # 如果 echo 字符串中有 变量,需要加反斜线转义 } autoINCPath(){ incList[0]="include_directories($dir/include/inc/)" incList[1]="include_directories($dir/include/src/)" incList[2]="include_directories($dir/include/)" # 路径为绝对路径,相对路径会报错. 此数组个数与 CMakeLists.txt 中的 include_directories 个数对应 file="CMakeLists.txt" incNumber=`cat -n $file | grep -w include_directories | wc -l` # wc -l 计算个数 if [ "${#incList[*]}" != "$incNumber" ] then echo "$file 文件 include_directories 定义个数 ${#incList[*]} 与 $incNumber 目标修改个数不相等,无法对应修改。" echo "请在 touchCMake 和 autoINCPath 函数, 增加或者 删除 include_directories 关键字个数,以达到与目标修改个数一致。然后重新执行脚本" exit else incI=0; while : do incNumberList=(`cat -n $file | grep -w include_directories | grep -v okset| awk -F" " '{print $1}' `) Number=${#incNumberList[*]} NR=${incNumberList[0]} if [ "$Number" -lt "1" ] then echo "[ok] 当前绝对路径已经全部修正, 正在执行 CMakeLists.txt 自动化编译。 " break fi echo "[runing] 当前游标:$incI 当前修改行:$NR 当前剩余总修改次数: $Number 文件:$file 所有行:${incNumberList[*]} 目标内容:${incList[$incI]} " sed -i "$NR a ${incList[$incI]} # [eisc.cn_okset]" $file sed -i "$NR d " $file # 始终修改第一个元素,然后由于循环再去查找行号 # 错误方式,删除一行后,其他内容行号会变,因此每次删除,需要重新扫描行号 # [okset] 修改了的地方做标记 let "incI++" # 先获取 0 后,再自动增加。而不是 先增加: 0+1 第一次为 1 sleep 0.3 done sleep 2 fi } touchCMake ; autoINCPath rm -rf ./build ; cmake ./ -Bbuild ; cmake --build build ./build/xunhuan
 1   0  169天前
admin
510
#!/bin/bash # 安装微信和qq qqurl="http://work.eisc.cn/ruanjian/ubuntu/deb/work/qq/" weixinurl="http://work.eisc.cn/ruanjian/ubuntu/deb/work/weixin/" dir="/datadisk/eisc/download/weixin" debList=( linuxqq_3.1.1-11223_amd64.deb ukylin-wine_70.6.3.25_amd64.deb ukylin-wechat_3.0.0_amd64.deb ) sudo mkdir -p $dir ; sudo chmod 777 $dir ; cd $dir download_deb(){ for i in ${debList[*]} do debname=`echo $i | awk -F"_" '{print $1}'` debnameInstalled=`sudo dpkg -l | grep $debname` debnameInstalledLength=${#debnameInstalled} if [ $debnameInstalledLength -gt 1 ] then echo "[ok] 该包 $i 已经安装,安装信息: $debnameInstalled" else echo "[runing] 正在检查是否下载安装包: $i" if [ ! -e $i ] then echo "[runing] 当前没有下载,正在下载包:$i" case "$i" in "linuxqq_3.1.1-11223_amd64.deb") wget $qqurl/$i ;; "ukylin-wine_70.6.3.25_amd64.deb") wget $weixinurl/$i ;; "ukylin-wechat_3.0.0_amd64.deb") wget $weixinurl/$i ;; *) echo "该包没有定义下载地址,包: $i" esac else echo "[ok] 已经下载: $i " fi echo "正在安装: $i" sudo apt install -y xdotool ; sudo apt --fix-broken install -y # 安装依赖包 sudo dpkg -i $i fi done } download_deb cd # 一键安装: # wget eisc.cn/file/ubuntu/shell/server/weixin.sh; sudo chmod +x weixin.sh ; ./weixin.sh
 1   0  187天前
admin
435
#include<stdio.h> #define MAX #define MAXIMUM(x,y)(x>y)?x:y #define MINIMUM(x,y) (x>y)?y:x // 理解为: if ( x > y ) return y; else return x; // 符号() 判断 ; 问号 ? 条件成立(then) 返回y的值; 冒号 : 条件不成立(else) 返回x int main() { int a=10,b=20; #ifdef MAX printf("已经使用define 定义 MAX 宏 条件成立, 当前板块代码有效 %d\n",MAXIMUM(a,b)); #else printf("没有定义 MAX 当前板块代码无效 %d\n",MINIMUM(a,b)); #endif // endif 结束判断 宏 #ifndef MIN printf("ifndef 判断没有定义弘(多了一个n), 条件成立,该板块代码有效 MIN %d\n", MINIMUM(a,b)); #else printf("已经定义 MIN 宏, 该板块代码无效 %d\n",MAXIMUM(a,b)); #endif #undef MAX // 取消之前定义的 宏 #ifdef MAX printf("定义有效 %d\n",MAXIMUM(a,b)); #else // else 否则 printf("定义的 MAX 宏 被 undef 取消定义,当前等于没有定义 MAX 宏 %d\n",MINIMUM(a,b)); #endif return 0; }
 1   0  208天前
admin
381
cmake 代码:project(eisc) #项目名 cmake_minimum_required(VERSION 3.10) # 编译要求:cmake 要大于最低版本 3.1 set(CMAKE_C_COMPILER "gcc") set(CMAKE_CXX_COMPILER "g++") # 设置编译器, 如果没有配置环境变量,可以改为gcc具体文件路径 include_directories(/datadisk/eisc/server/mysql/mariadb1011/include/mysql/server/) # include_directories(/datadisk/eisc/server/mysql/mariadb1011/include/mysql/) # 添加 头文件搜索路径 (mysql.h 搜索路径) #add_executable("set" set.cpp) add_executable("sql" sql.cpp) # 生成可执行文件: 将 test.cpp 编译成 test.exe 可执行文件 target_link_libraries(sql /datadisk/eisc/server/mysql/mariadb1011/lib/libmysqlclient.so) # rm -rf ./build ; cmake ./ -Bbuild -G "Unix Makefiles" ; cmake --build build # rm -rf ./build ; cmake ./ -Bbuild ; cmake --build build # 编译到当前目录下的 build 文件夹 # 也可以不用指定 -G c++ 代码#include <stdio.h> #include <stdlib.h> #include <iostream> #include <string> #include "mysql.h" using namespace std; class MysqlDB { private: // private [ˈp raɪ vət] 私有 MYSQL mysql; MYSQL_ROW row; MYSQL_RES *result; MYSQL_FIELD *field; public: MysqlDB() { if( mysql_init( &mysql ) == NULL ) // 判断数据库初始化 { cout << "init error, line: " << __LINE__ << endl; exit(-1); } } ~MysqlDB() // 波浪号是析构函数,删除创建的对象时执行。 不会返回任何值和带参数。作用:跳出程序释放资源 { mysql_close( &mysql ); } void connect( string host, string user, string passwd, string database ) { //成功返回MYSQL指向的指针,失败返回NULL if( !mysql_real_connect( &mysql, host.c_str(), user.c_str(), passwd.c_str(), database.c_str(), 0, NULL, 0 ) ) { cout << "connect error, line: " << __LINE__ << endl; exit(-1); } } void createTB(); void add(); void del(); void update(); void print(); }; void MysqlDB::createTB() { string id, name, sex, birthday, CTtable; do { cout << "请输入创建表信息:\n"; cin >> CTtable; string sql = "create table "+ CTtable +"(id int, name varchar(10), sex varchar(20), birthday varchar(20));"; cout << sql << endl; mysql_query( &mysql, sql.c_str() ); cout << "是否继续(y/n): "; cin >> id; } while( id == "y" ); } void MysqlDB::add() { string id, name, sex, birthday,CTtable; cout << "请输入写入信息:\n"; cin >> id >> name >> sex >> birthday; string sql = "insert into stu(id,name,sex,birthday) values('" + id + "', '" + name + "', '" + sex + "', '" + birthday + "');"; cout << sql << endl; mysql_query( &mysql, sql.c_str() ); } void MysqlDB::del() { string id; do { cout << "请输入删除信息的ID:\n"; cin >> id; string sql = "delete from stu where id='" + id +"';"; cout << sql << endl; mysql_query( &mysql, sql.c_str() ); cout << "是否继续(y/n): "; cin >> id; } while( id == "y" ); } void MysqlDB::update() { string id, filed,value; do { cout << "请输入修改信息ID,字段,值:\n"; cin >> id >> filed >> value; string sql = "update stu set " + filed +"='" + value + "' where ID='" + id + "';"; cout << sql << endl; mysql_query( &mysql, sql.c_str() ); cout << "是否继续(y/n): "; cin >> id; } while( id == "y" ); } void MysqlDB::print() { string sql = "select * from stu;"; //成功返回0 mysql_query( &mysql, sql.c_str() ); //获取查询查询结果;成功返回result的指针,失败返回NULL result = mysql_store_result( &mysql ); if( !result ) { cout << "result error, line : " << __LINE__ << endl; return ; } int num; num = mysql_num_fields( result ); //返回字段个数 for( int i = 0; i < num; i++ ) { field = mysql_fetch_field_direct( result, i ); //返回字段类型 cout << field->name << "\t\t"; //输出字段名 } cout << endl; while( row = mysql_fetch_row( result ), row != NULL ) { for( int i = 0; i < num; i++ ) { cout << row[i] << "\t\t"; } cout << endl; } } int main() { MysqlDB db; // 将 MysqlDB 继承给 db db.connect( "127.0.0.1", "enchantment", "eisc.cn", "enchantment" ); db.print(); db.createTB(); db.print(); db.add(); db.print(); return 0; }
 1   0  216天前
admin
463
#!/bin/bash # ubuntu20 shell 脚本自动配置 gitea git 仓库 # time: 2023.2.26 downdir="/datadisk/eisc/download" ; sudo mkdir -p $downdir ; sudo chmod 777 -R $downdir installdir="/datadisk/eisc/server" ; sudo mkdir -p $installdir # 安装路径不能将所有目录都为 777 , 如: mysql 的 /etc/my.cnf 不能为 777 否则mysql 无法启动 echo " 欢迎使用自动 shell 脚本自动配置 gitea git 仓库 server 源码下载路径:$downdir server 安装路径:$installdir C 2022.12.04 小绿叶技术博客 eisc.cn " sleep 2; down_guanfang_url(){ giteaUrl="https://dl.gitea.com/gitea/1.18.5/gitea-1.18.5-linux-amd64" } down_eisc_url(){ giteaURL="http://work.eisc.cn/ruanjian/ubuntu/c/git/gitea" } down_select(){ read -p "选择下载安装包地址: 1 官方下载 2 小绿叶技术博客下载. 请输入: " selectURL case $selectURL in "1") echo "当前选择官方下载..." ; down_guanfang_url ;; "2") echo "当前选择小绿叶技术博客下载..." ; down_eisc_url ;; *) echo "输入错误,请重新执行脚本! " ; exit ;; esac echo $gitea } gitea_install(){ sudo apt install git supervisor -y git --version if [ ! -e $downdir/gitea/gitea ] then sudo mkdir $downdir/gitea ; sudo chmod 777 $downdir/gitea wget -O $downdir/gitea/gitea $giteaURL else echo "[ok] 已经下载包: $downdir/gitea/gitea " fi if [ ! -e $installdir/gitea/gitea ] then sudo mkdir $installdir/gitea ; sudo chmod 777 $installdir/gitea cp $downdir/gitea/gitea $installdir/gitea/gitea else echo "[ok] 已经安装包: $installdir/gitea/gitea " fi } gitea_user(){ # gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 # gpg --verify $installdir/gitea/gitea.asc $installdir/gitea/gitea # gpg 签名密钥箱,防篡改 sudo adduser \ --system \ --shell /bin/bash \ --gecos 'Git Version Control' \ --group \ --disabled-password \ --home /home/git \ git # 创建gitea用户 sudo mkdir -p /var/lib/gitea/{custom,data,log} sudo chown -R git:git /var/lib/gitea/ sudo chmod -R 750 /var/lib/gitea/ sudo mkdir /etc/gitea sudo chown root:git /etc/gitea sudo chmod 770 /etc/gitea # 创建工作路径 sudo chmod 750 /etc/gitea sudo chmod 640 /etc/gitea/app.ini # 写入权限 } gitea_service(){ # ubuntu 以 systemd 服务方式,自动启动服务软件 # gitea_user # 配置 gitea 用户和目录 sudo touch $systemdDir/$webname ; sudo chmod 777 $systemdDir/$webname sudo chmod +x $giteaRun sudo mkdir -p /var/lib/gitea/ ; sudo chmod 644 /var/lib/gitea/ sudo mkdir -p $installdir/shell ; sudo chmod 777 -R $installdir/shell echo "#!/bin/bash # bash 解释器 一定要在第一行 开头写,否则下面脚本不执行,开机启动不成功。 由于是 service服务,因此此脚本是 root 用户执行 $giteaRun & " > $installdir/shell/gitea_start.sh sudo chmod +x $installdir/shell/gitea_start.sh sudo chown root:root $installdir/shell/gitea_start.sh $giteaRun # 可执行文件 和 脚本属性是 root 用户才能开机启动 #----- 写入 start.service 服务 -----# echo " [Unit] Description=gitea [Service] Type=forking #ExecStart=$installdir/shell/gitea_start.sh ExecStart=/bin/gitea ExecReload=/bin/kill -SIGHUP \$MAINPID ExecStop=/bin/kill -SIGINT \$MAINPID [Install] WantedBy=multi-user.target " > $systemdDir/$webname sudo apt install dos2unix -y sudo dos2unix $systemdDir/$webname # 转为 unix 格式,否则可能出现字符乱码 sudo chmod 644 $systemdDir/$webname sudo systemctl daemon-reload sudo systemctl disable $webname sudo systemctl enable $webname sudo systemctl start $webname # 启动服务名称,不用加路径,配置了 service 相当于配置了环境变量,可以直接启动/停止服务名称 cd ~ # 配置 gitea 开机启动 sudo mkdir -p /home/git/gitea/log/supervisor # 配置日志服务 sudo chmod 777 /etc/supervisor/supervisord.conf echo " [program:gitea] directory=/home/git/go/src/github.com/go-gitea/gitea/ command=/home/git/go/src/github.com/go-gitea/gitea/gitea web autostart=true autorestart=true startsecs=10 stdout_logfile=/var/log/gitea/stdout.log stdout_logfile_maxbytes=1MB stdout_logfile_backups=10 stdout_capture_maxbytes=1MB stderr_logfile=/var/log/gitea/stderr.log stderr_logfile_maxbytes=1MB stderr_logfile_backups=10 stderr_capture_maxbytes=1MB user = git environment = HOME="/home/git", USER="git" " > /etc/supervisor/supervisord.conf sudo chmod 644 /etc/supervisor/supervisord.conf sudo systemctl enable supervisor sudo systemctl start supervisor } gitea_if_service(){ giteaRun="$installdir/gitea/gitea" systemdDir="/usr/lib/systemd/system" webname="gitea.service" if [ ! -e $systemdDir/$webname ] then echo "[runing] 开始配置gitea.service 开机启动..." gitea_service else echo "[ok] 已经配置 gitea.service 开机启动, 是否重新配置 开机启动?" read -p "input y/n? : " xz if [ "$xz" = "y" ] then echo "[runing] 开始配置gitea.service 开机启动..." gitea_service else echo "[ok] 已经配置过gitea 开机启动,不需要重新配置!" fi fi } main(){ down_select gitea_install gitea_if_service } main # echo "" > gitea.sh ; nano gitea.sh ; sudo chmod +x gitea.sh ; ./gitea.sh
 1   0  219天前
admin
897
#!/bin/bash # gb2312 转 utf8 编码 # 开发 : 小绿叶技术博客 eisc.cn # date : 2023.2.27 dir="./" ; echo "当前目录: $dir" sudo chmod 777 -R $dir/* # FileList=(`du -ah $dir | awk -F" " '{print $2}'`) # find ./ -type f | xargs dos2unix # 列出所有文件和目录 # xargs 作用是将管道前面的结果内容(查找所有内容为 f 文件 ) 传递 给后面命令使用 apt_install() { linuxKernel=`cat /etc/os-release | grep -w ID | awk -F"=" '{print $2}'` case "$linuxKernel" in "ubuntu") sudo apt install -y dos2unix ; echo "[ok] 当前系统为: $linuxKernel 是 ubuntu..." ;; "debian") sudo apt install -y dos2unix ; echo "[ok] 当前系统为: $linuxKernel 是 debian..." ;; "centos") sudo yum install -y dos2unix ; echo "[ok] 当前系统为: $linuxKernel 是 centos..." ;; "redhat") sudo yum install -y dos2unix ; echo "[ok] 当前系统为: $linuxKernel 是 redhat..." ;; *) echo "未匹配到系统,你可以更换系统后再试试, 建议系统: ubuntu20 debian centos redhat" ;; esac sleep 1 } run_file() { destBM="GB2312" # 定义转为 目标编码. 可以互相转换 fileTypeUtf8=`file $file | grep $destBM` fileTypeUtf8Length=${#fileTypeUtf8} case "$bm" in "ISO-8859") bm="GB2312" ;; "Non-ISO") bm="GB2312" ;; esac if [ "$fileTypeUtf8Length" -lt "1" ] then echo "[runing] 编码 $bm 转为 $destBM $file 文件类类型: $fileType" # sudo dos2unix $file sudo iconv -c -f $bm -t $destBM $file -o $file.zhuanhuan sudo mv $file.zhuanhuan $file else echo "[ok] 该文件:$file 已经是 $destBM 编码 该文件编码属性字符串长度为: $fileUtf8Length 文件类类型: $fileType" fi } Character_encoding() { for((i=0;i<${#FileList[*]};i++)) do file=${FileList[$i]} fileType=`file $file ` bmFileBZ=0 bmlist=( GB2312 ISO-8859 Non-ISO GBK UTF-8) # GB2312 ISO-8859 GBK 三种编码是同类,填写 for bm in ${bmlist[*]} do bmFile=`file $file | grep $bm` ; bmFileLength=${#bmFile} ; if [ "$bmFileLength" -gt 0 ] then echo "[runing] 当前文件 $file 编码是 $bm 开始处理 " bmFileBZ=1 run_file fi done # if [ "$x"="0" ] && [ "$y" = "0" ] 多个条件判断 if [ "$bmFileBZ" = "0" ] then echo "[warning] 文件编码标记(0/1 未匹配/匹配编码): $bmFileBZ 当前文件 $file 编码非 ( ${bmlist[*]} ) 编码: `file $file`" fi done } list_file() { szFile=( c h ) for szf in ${szFile[*]} do case "$szf" in "c") echo "当前正在处理 .c 文件" ; FileList=(`find $dir -name "*.$szf"`) ; Character_encoding ;; "h") echo "当前正在处理 .h 文件" ; FileList=(`find $dir -name "*.$szf"`) ; Character_encoding ;; esac done } main(){ echo "ISO-8859 Non-ISO 编码等于 GB2312 编码; 重点: ASCI 在 utf8 和 gbk 中都存在,因此不要将 ASCI 编码进行转换 utf8 " ; apt_install list_file } main # rm -rf ss11-a1; unzip ss11-a1.zip ; cp ~/cs/sh/utf8.sh ss11-a1/ ; chmod +x ss11-a1/utf8.sh ; ss11-a1/utf8.sh ; cat -n ss11-a1/src/APP/GetOutValue/GetOutValue.c | grep 1201 # iconv 编码转换脚本一键执行: wget eisc.cn/file/ubuntu/shell/tools/file/utf8.sh ; sudo chmod +x utf8.sh ; ./utf8.sh
 1   0  979天前
admin
2501
######### windos配置   #############用户变量:--------------------------------------Path添加:%JAVA_HOME%\bin%JAVA_HOME%\jre\bin--------------------------------------JAVA_HOME添加包含JRE文件目录下的父文件夹为JDK目录-------------------------------------------系统配置:-------------------------------CLASSPATH配置.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;--------------------------------------JAVA_HOME添加包含JRE文件目录下的父文件夹为JDK目录-------------------------------------------Path添加:%JAVA_HOME%\bin%JAVA_HOME%\jre\bin--------------------------------------下载地址:jdk_1.8.0_151.zip########### ubuntu 配置   ##############下载地址:/datadisk/eisc/www/work/ruanjian/debian/jdk-8u321-linux-x64.tar.gz#debian 和ubuntu 通用tar -xzvf jdk-8u321-linux-x64.tar.gz -C ./# 解压到当前目录sudo nano /etc/profile#编辑环境变量export JAVA_HOME=/datadisk/eisc/server/jdk/jdk1.8.0_321export JRE_HOME=$JAVA_HOME/jreexport CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATHsource /etc/profile#生效环境变量   
 6   1  950天前
admin
526
1. 下载基础包; 2. 配置vscode; 3. cmake 基础 ################### 软件下载 ################### vscode: 官方: https://code.visualstudio.com/Download 其他下载: http://work.eisc.cn/ruanjian/windows/c/ruanjian/VSCodeUserSetup-x64-1.75.1.exe ubuntu vscode: work.eisc.cn/ruanjian/ubuntu/deb/tools/vscode.deb cmake: 官方: https://cmake.org/download/ 其他下载: http://work.eisc.cn/ruanjian/windows/c/ruanjian/cmake-3.26.0-rc4.zip gcc_g++: 其他下载: http://work.eisc.cn/ruanjian/windows/c/ruanjian/windos_mingw64.tar.gz # 该文件中 目录 mingw64\bin\mingw32-make.exe 中的文件 已经重命名为 make.exe 为了解决下面 没有识别到make 命令 问题: CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. -- Configuring incomplete, errors occurred! ################### vscode 基础配置 ################### vscode 配置为中文: 1. 点击 vscode 左侧的扩展图标,打开侧边栏“EXTENSIONS”面板(魔方图标) 2. 点击搜索并安装 chinese 简体中文 3. 安装完成,点击右下角 Restart 重启 vscode vscode 支持 c/c++ 编译环境: 1.vscode 魔方图标搜索安装: C/C++ Extension Pack (Popular extensions for C++ development in Visual Studio Code.) 2.vscode 魔方图标搜索安装: Cmake Tools 3.重启电脑 如果 vscode 左下角还是没有出现 cmake 的功能,使用: Shift+Ctrl+p 弹出搜索 -> 输入cmake -> 点击 cmake 配置,自动弹出提示进行 选择 yes vscode 全屏模式: 1. 键盘 Alt 按键 显示/隐藏 顶部状态栏 2. 顶部状态栏 -> 查看 -> 外观 -> 全屏 3. 快捷按键: F11 vscode 开启变量快速预览 1. 设置图标 -> 设置 -> 搜索 peek definition -> 勾选:Editor: Definition Link Opens In Peek -> 返回代码界面 -> Ctrl + 点击代码中的变量 vscode git 查看历史版本: 扩展里面搜索安装: git graph vscode tab 缩进转空格 : 全选代码 点击右下角空格 弹出选择框 【将缩进转换为空格】 vscode tab 设置为按tab时插入空格: 导航栏 文件-> 首选项 -> 设置 -> 搜索后勾选: Editor:Insert Spaces 配置 gcc c++ : 1. 我的电脑-> 属性 -> 高级系统设置 -> 高级 -> 环境变量 -> 系统变量 -> Path -> 添加上面软件解压的路径,精确到bin目录 -> 重启电脑 2. 搜索安装 C/C++ Extension Pack (Popular extensions for C++ development in Visual Studio Code.) -> 重启电脑 3. 重启电脑后,可以看到 vscode 左下角的 状态栏 图标出现cmake 右边一个图标的扳手 No kit Selected ,点击它 -> 选择 GCC 8.1 如果 vscode 左下角还是没有出现 cmake 的功能,使用: Shift+Ctrl+p 弹出搜索 -> 输入cmake -> 点击 cmake 配置,自动弹出提示进行 选择 yes ################### cmake 基础使用 ################### #--- 编译命令 ---# 点击 vscode 顶部状态栏 -> 终端 -> 新建终端 输入下面命令进行编译 mkdir build ; cd build # 创建 build 编译目录, 并且进入 del * ; cmake ../ -Bbuild -G "Unix Makefiles" ; cmake --build build # 删除build的目录所有文件 # cmake 构建命令 # cmake 编译 #--- cmake 案例 ---# project(eisc) #项目名 cmake_minimum_required(VERSION 3.10) # 编译要求:cmake 要大于最低版本 3.1 set(CMAKE_C_COMPILER "gcc") set(CMAKE_CXX_COMPILER "g++") # 设置编译器, 如果没有配置环境变量,可以改为gcc具体文件路径 include_directories(../../test/include/) include_directories(../../uds/) include_directories(../../include/) include_directories(../../driver/) include_directories(../../core/) # 添加 头文件搜索路径 (.h 搜索路径) add_executable("test.exe" test.cpp) # 生成可执行文件: 将 test.cpp 编译成 test.exe 可执行文件
 1   0  221天前
admin
471
#!/bin/bash # databases out save # developer : eisc.cn # 开发: 小绿叶技术博客; 功能:shell 自动导出数据库,将导出的格式为 : 数据库名+时间.sql echo "linux user: $USER ; Enter the current user sudo password: " ; sudo date ; formatdate=`date +%Y.%m.%d-%H%M%S` ; echo "time year month day Hour branch second: $formatdate " dir=/datadisk/eisc/back/sql sudo mkdir -p $dir ; sudo chmod 777 $dir # 数据库导出文件保存目录, 创建这个目录,和附加权限 DestDir=/datadisk/eisc/back/sql DestDBName=(`ls $DestDir | grep "sql" | grep -vE "tar|gz|zip|sh"`) # 目标服务器,需要导入的数据库文件。根据实际存放目录修改 # user=root # passwd=eisc.cn # dataip=127.0.0.1 # 脚本中配置 数据库用户名 和密码 和数据库链接地址 if [ "$user"="" ] then echo "请输入数据库管理员用户和密码以及ip, 案例:root eisc.cn 127.0.0.1 Please enter the database administrator user and password and ip, case: root eisc.cn 127.0.0.1 " read -p "input: " inputuser else echo "[ok] 已经定义过 user 和 passwd 的值!" fi inputuser=($inputuser) user=${inputuser[0]} passwd=${inputuser[1]} dataip=${inputuser[2]} export_databases(){ databases=(`mysql -u $user -p$passwd -e "show databases;"`) NoOutDatabases=(Database information_schema mysql performance_schema sys ) # 这是系统库,不是项目中的数据库。只需要导出项目库 echo "databases is : ${databases[*]} NoOutDatabases is : ${NoOutDatabases[*]} " sudo tar -czvf $dir/sqlback_$formatdate.tar.gz $dir ; sudo rm -rf $dir/* for i in ${databases[*]} do echo "#-------- database $i -----------# " for o in ${NoOutDatabases[*]} do case "$i" in "$o") echo " [ok] $i : The current database does not need to be exported!" ; OutStatus=0 ; echo "" ;echo "" ;; esac done if [ "$OutStatus" = "1" ] then sql="sudo mysqldump --column-statistics=0 -h $dataip -u $user -p$passwd --databases $i" echo "[runing] shell cmd: $sql" ; echo "" $sql > $dir/$i-$formatdate.sql # mysqldump 不支持有变量的数据库,因此赋值为字符串 # 因为新版的mysqldump默认启用了一个新标志,通过- -column-statistics=0来禁用他 else echo "[ok] $i Database does not need to be saved" fi OutStatus=1 # 状态 为 1 才进行导出数据,由于受到 NoOutDatabases 不导出影响,会被定义为 0. 最后再次将状态更新为正常 1 # 注意: shell if 判断的时候需要在变量和值加双引号,否则异常 done echo "数据库导出保存目录: $dir 将目录 $dir 备份为:sqlback_$formatdate.tar.gz" ls -alh $dir } mysql_database_tools(){ #!/bin/bash # shell 自动创建数据库 用户和密码 sudo apt install libncurses* # 解决mysql 命令报错,缺少库:Couldn't find any package by glob 'libncurses.so.5' sudo apt install mysql-client -y # 安装连接数据库工具 sudo mkdir /var/run/mysqld/ sudo ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock # 解决 mysql 报错,无法进入mysql 。 mariadb 的启动sock 不一样 runmysql=`sudo netstat -nltp | grep 3306 | grep -w tcp | grep mariadb` if [ ${#runmysql} -lt 1 ] then sudo /etc/init.d/mariadb1011 start fi sudo $installdir/mysql/mariadb1011/bin/mysqladmin -u root password eisc.cn # 启动数据库,重置数据库 root 用户密码为: eisc.cn echo "#---------------- 数据库管理工具 ------------# 参考输入案例: create eisc.cn www www 000000 localhost 1 创建 or 删除,输入: create 或 drop 2 数据库 root 用户密码 3 子数据库名 4 子库用户名 5 子库密码 6 开放数据库方式:本地/远程 输入: localhost 或 % 用空格隔开,必须按照顺序输入6个参数!" read -p "请输入:" in_buff buff=( abcd $in_buff); echo "你输入的信息为: ${buff[*]}"; case ${buff[1]} in "create") # mysql -uroot -p${buff[2]} -e "create database ${buff[3]} character set utf8 collate utf8_bin;" mysql -uroot -p${buff[2]} -e "create database ${buff[3]} character set utf8;" mysql -uroot -p${buff[2]} -e "grant all on ${buff[4]}.* to '${buff[4]}'@'${buff[6]}' identified by '${buff[5]}'" mysql -uroot -p${buff[2]} -e "show databases;SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS ListUsername FROM mysql.user where User='${buff[4]}';" ;; "drop") mysql -uroot -p${buff[2]} -e "drop database ${buff[3]}" mysql -uroot -p${buff[2]} -e "drop user '${buff[4]}'@'${buff[6]}'" mysql -uroot -p${buff[2]} -e "show databases;SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS ListUsername FROM mysql.user where User='${buff[4]}';" ;; esac } import_databases(){ dipasswd=eisc.cn # 定义 子库密码 echo "将从文件目录: $DestDir 导入数据库, 注意,不能出现重复的数据库文件。一个数据库保留一个sql 文件。列出该目录的文件,如下:" ; ls $DestDir read -p "是否将文件放置在该目录?y/n:" fzfile if [ "$fzfile" != "y" ] then echo "[ok] 退出! 将文件复制到该目录后,重新执行函数" exit fi echo "如果遇到问题,你可以使用 mysql管理工具来创建数据库和用户, 不使用该工具,会自动创建数据库。" for((s=0;s<${#DestDBName[*]};s++)) do di=`echo ${DestDBName[$s]} | awk -F"-" '{print $1}'` difile=${DestDBName[$s]} ShowDBName=`mysql -h $dataip -u $user -p$passwd -e "show databases" | grep $di ` if [ "$ShowDBName" = "$di"] then echo "[error] Database exists $di " else echo "[ok] runing import data $di" mysql -h $dataip -u $user -p$passwd -e "create database $di character set utf8;" mysql -h $dataip -u $user -p$passwd -e "grant all on $di.* to '$di'@'localhost' identified by '$dipasswd'" mysql -h $dataip -u $user -p$passwd -e "show databases;SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS ListUsername FROM mysql.user where User='$di';" fi mysql -h $dataip -u $user -p$passwd -e "use $di ; source $DestDir/$difile ; show tables;" echo "[ok] import databases $DestDir/$difile " done } set_file_mysqlpasswd(){ webdir=( "/datadisk/eisc/www/www/puyuetian/mysql/config.php" "/datadisk/eisc/www/xibin/puyuetian/mysql/config.php" ) for file in ${webdir[*]} do echo "set in $file" NR=`cat -n $file | grep PASSWORD | grep -v MYSQL | awk -F" " '{print $1}'` sed -i "$NR a \$_G['SQL']['PASSWORD'] = 'eisc.cn';" $file sed -i "$NR d" $file cat -n $file done } main(){ echo " 欢迎使用,小绿叶技术博客 eisc.cn 数据库搬家,数据库导出与导入工具,提供工具功能: 1. 数据库导出 2. 数据库导入 3. 数据库管理工具,创建与删除数据库和用户 请输入功能序号: Welcome to the small green leaf technology blog eisc.cn database move, database export and import tool, providing tool functions: 1. Database export 2. Database import 3. Database management tool, creating and deleting databases and users Please enter the function serial number: " read -p "input number: " tnumber case "$tnumber" in "1") echo "[runing] 1. Database export" ; export_databases ;; "2") echo "[runing] 2. Database import" ; import_databases ;; "3") echo "[runing] 3. Database management tool" ; mysql_database_tools ;; esac set_file_mysqlpasswd } main # 一键下载使用: wget eisc.cn/file/ubuntu/shell/server/mysql_export_import.sh ; chmod +x mysql_export_import.sh ; ./mysql_export_import.sh
 1   0  237天前
admin
500
#include <iostream> #include <cstring> #include <string> #include <stdlib.h> // system 命令使用头文件 #include <fstream> // 读写文件 /*------ mkdir 命令 ------*/ #include <sys/stat.h> #include <sys/types.h> #include <cstddef> using namespace std; // 命名空间, cout end1 等依赖 std 命名空间 //int cishu=1200; //int shijian=300; char DirServer[30]="/datadisk/eisc/server/"; char AnfangDir[99]="anfang"; char logname[20]="eisc_anfang_log.txt"; // 不给长度,系统默认会定义长度,会导致错误,因此需要给长度 char MkdirSh[99]="sudo mkdir -p "; char ChmodSh[99]="sudo chmod 777 -R "; //char eiscshuom[50]="this is eisc anfang xitong + - ="; char eiscshuom[50]="#---------- eisc ------------#"; /*---------- 创建所有服务安装文件夹 -----------*/ int log_run() { strcat( MkdirSh, DirServer); strcat( ChmodSh, DirServer); // 注意:前面定义了变量,需要再函数里面进行赋值追加字符串,否则错误 system(MkdirSh); system(ChmodSh); cout << "\n mkdirsh is : " << MkdirSh ; cout << "\n chmodsh is : " << ChmodSh; return 0; // 终止函数,并且反馈该函数的值为0; return 0 正常退出,return 1 异常退出 , return -1 函数失败 } /*---------- 创建安防文件夹 -----------*/ void mkdir_path(char *p_cMkdir) { int isCreate = mkdir(p_cMkdir,S_IRUSR | S_IWUSR | S_IXUSR | S_IRWXG | S_IRWXO); // 创建文件 指定权限 if( !isCreate ) cout << "\n [ok] create AnfangDir:" << p_cMkdir ; else cout << "\n [fall] create AnfangDir failed! error code: " << p_cMkdir ; } /*---------- 写入日志文件 -----------*/ int W_file() { FILE * fp; fp = fopen (logname, "a+"); // w+ 覆盖并写入 ; a+ 末尾追加字符串 fprintf(fp, "%s %d", eiscshuom, 2023); // 格式化输出流到 fp 指针文件 fclose(fp); // 关闭指针 return(0); } /*---------- 读取日志文件 -----------*/ int R_file ( char *lognamea) { FILE *fp; char c; char buffer[9999]; fp=fopen(lognamea,"r+"); if(!fp) { cout << "[fail] 读取文件为空,或者没有读取到文件: "; cout << "\n 即将退出 R_file 整个函数, 退出效果来源: return -1 \n \n \n "; return -1; } else { cout << "\n [ok] fp 指针获取到文件 非 0 非空,值为: " << lognamea; } while(1) { c=fgetc(fp); // fgetc 从指定流fp 获取下一个字符. 由于循环一次读一个字符。一直读取字符到变量 c if( feof(fp) ) // feof 判断文件是否结束:测试给定流的文件结束符标识 。 文件读完,就 break 退出循环 { break; } cout << c; // 读取到一个字符,打印一个字符 } fseek(fp, 5, SEEK_SET); // 查找 文件开头,指针初始化方向开头: 从 文件流 选择第几个字符位置 fread(buffer, strlen(eiscshuom)+5, 1, fp); // 从文件中读取字符串,读取一个元素,长度为 eiscshuom变量的长度 cout << " \n [ok] 变量 c 获取到fp指针流赋值的字符: \n " << "\n 变量 buffer 从 fp 读取元素个数和数量 结果为: " << buffer << "\n \n " ; // strlen(c)+1 表示统计c 变量的长度还要加1 fclose(fp); return status; // 终止函数,并且反回该函数的值为 0 } /*------------ 判断 R_file 函数 -------------*/ int panduan_xuexi(){ int status=0; if( !R_file(logname)) { cout << "if 默认成立条件是 非0 非空, 感叹号 ! 是非运算 条件取反,相当于 结果为 是 0 是空 条件成立"; cout << "\n [ok] 函数 R_file 返回的值为0 " ; } else { cout << "\n [fall] 函数 R_file 返回的值不为0 "; } return 0; } int main() { log_run(); strcat(DirServer, AnfangDir ); strcpy(AnfangDir,DirServer); cout << "\n AnfangDir 的值为:" << AnfangDir; cout << "\n 我是main 函数 AnfangDir 接收到值:" << AnfangDir; mkdir_path(AnfangDir); W_file(); panduan_xuexi(); return 0; } // rm -rf file ; echo "" > file.cpp ; nano file.cpp ; g++ file.cpp -o file ; chmod +x file; ./file // 软件流程 : 创建安装目录 -> 创建 log.txt 文件 -> 写入eisc -> 开始抓包 -> 等待时间结束抓包 ->读取日志文件 -> 判断 ip 是否大于预设值 /* #include <stdio.h> #include <string.h> int main() { FILE *fp; char buffer[20]; fp = fopen("eisc_anfang_log.txt", "r+"); // fseek(fp, 0, SEEK_SET); fread(buffer, 3, 1, fp); printf("%s\n", buffer); fclose(fp); return(0); } // rm -rf cs ; echo "" > cs.c ; nano cs.c ; gcc cs.c -o cs ; ./cs */
 1   0  245天前
admin
532
#include <iostream> #include <cstring> #include <string> #include <stdlib.h> // system 命令使用头文件 #include <fstream> // 读写文件 /*------ mkdir 命令 ------*/ #include <sys/stat.h> #include <sys/types.h> #include <cstddef> using namespace std; //int cishu=1200; //int shijian=300; char DirServer[30]="/datadisk/eisc/server/"; char AnfangDir[99]="anfang"; char logname[20]="eisc_anfang_log.txt"; // 不给长度,系统默认会定义长度,会导致错误,因此需要给长度 char MkdirSh[99]="sudo mkdir -p "; char ChmodSh[99]="sudo chmod 777 -R "; int log_run() { strcat( MkdirSh, DirServer); strcat( ChmodSh, DirServer); // 注意:前面定义了变量,需要再函数里面进行赋值追加字符串,否则错误 system(MkdirSh); system(ChmodSh); cout << "\n mkdirsh is : " << MkdirSh ; cout << "\n chmodsh is : " << ChmodSh; // system("tcpdump -nn > /datadisk/eisc/server/anfang/sh/log/log.txt &"); return 0; // 终止函数,并且反馈该函数的值为0 } void mkdir_path(char *p_cMkdir) { int isCreate = mkdir(p_cMkdir,S_IRUSR | S_IWUSR | S_IXUSR | S_IRWXG | S_IRWXO); if( !isCreate ) cout << "\n [ok] create AnfangDir:" << p_cMkdir ; else cout << "\n [fall] create AnfangDir failed! error code: " << p_cMkdir << "\n \n" ; } int W_file() { char shuoming[30]="this_is_eisc_anfang_tcpdump"; ofstream setfile; setfile.open(logname); setfile << shuoming; setfile.close(); // 定义 setfile 变量为 ofsteram 输入文件流,它的值为打开文件。 将 字符串变量的值写入文件流变量; 关闭流 } int R_file ( char *lognamea, int status) { char data[999]; ifstream catfile; // ifstream 以读模式打开文件, ofstream 是写模式。 将类型赋值给变量 infile catfile.open(lognamea); // 变量打开文件 cout << "\n Reading_from_the_file: " << lognamea ; catfile >> data; // 将文件流,输入到 变量 data cout << "\n data 变量 获得文件内容: " << data << "\n \n \n 获取到 status 的值为: " << status << "\n \n"; catfile.close(); // 关闭打开的文件 return status; // 终止函数,并且反回该函数的值为0 } int panduan_xuexi(){ int status=0; if( !R_file(logname,status)) { cout << "if 默认成立条件是 非0 非空, 感叹号 ! 是非运算 条件取反,相当于 结果为 是 0 是空 条件成立"; cout << "\n [ok] 函数 R_file 返回的值为0 " ; } else { cout << "\n [fall] 函数 R_file 返回的值不为0 "; } } int main() { log_run(); strcat(DirServer, AnfangDir ); strcpy(AnfangDir,DirServer); cout << "\n AnfangDir 的值为:" << AnfangDir; // memcpy( path, DirServer,99); cout << "\n 我是main 函数 AnfangDir 接收到值:" << AnfangDir; mkdir_path(AnfangDir); W_file(); panduan_xuexi(); }
 1   0  247天前
admin
458
#include <stdio.h> #include <unistd.h> // sleep 函数包索引 int flag = 0; int flag1 =0; int cishu = 0; int jhcs = 3; // bool 是二进制类型; void test(int bit, int val) { // 由于 main 函数,我得到 数值: 1 1 printf("我是控制灯函数..."); // int const Mask = Bits1_GetMsk(bit); if (val){ printf("c 中的 if 默认条件:当前 val 的值不为空,或者不为0 条件成立 ; 我的值是:%d 等于接收都控制信号" , val); } else { printf("val 为 0 或者 为空, if 的默认条件就不成立"); } } void shanshuo(void) { if (flag == 0) { test(0,1); flag=1; // 因为需要实现 闪灯,一会关一会开,因此开启后关闭,实现闪烁 printf(" \n \n 【当前控制灯为 开】 \n 当前 flag 的值为 0 , 我执行函数 写入 1 开启灯 ; 函数控制硬件后,我将其 设置为1 进行变换 \n \n "); } else { test(0,0); flag=0; // 因为 flag 的值不为 0 ,因此将其赋值为 0 ,等于将 1 变换成 0 ,实现开关作用,闪烁 printf(" \n \n 【当前控制灯为 关】 \n 当前 flag 的值不为 0 , 我执行函数 写入 0 关闭灯 ; 函数控制硬件后,我将其 设置为0 进行变换 \n \n "); } } int main() { while(1) { printf("测试无限循环打印"); usleep(200000); cishu++; printf("当前 得到 次数 :%d \n" , cishu); shanshuo(); if (cishu > jhcs ) { printf("当前循环执行闪烁次数:%d 已经超过计划次数: %d 现在退出 闪烁功能 \n " , cishu, jhcs); break ; // 退出本函数,或者退出循环 } else { printf("当前已经执行次数: %d \n", cishu); } } printf("循环函数 停止运行了! "); } /* 1.转换说明符 %a(%A) 浮点数、十六进制数字和p-(P-)记数法(C99) %c 字符 %d 有符号十进制整数 %f 浮点数(包括float和double) %e(%E) 浮点数指数输出[e-(E-)记数法] %g(%G) 浮点数不显无意义的零"0" %i 有符号十进制整数(与%d相同) %u 无符号十进制整数 %o 八进制整数 e.g. 0123 %x(%X) 十六进制整数<?xml:namespace prefix = st1 />() e.g. 0x1234 %p 指针 %s 字符串 %% "%" 参考:https://blog.csdn.net/qq_29874741/article/details/94626531 0 0x0f 0xf0 0x08 --> 0000 1000 #define clrSetReg8Bits(RegName, ClrMask, SetMask) f0 08 (RegName = (RegName & ((byte)(~(byte)(ClrMask)))) | (byte)(SetMask)) 存储器: 当前是与非或计算: 由于前面函数传入:参数 0xf0 0x08u (~(byte)(ClrMask)) : f0 非运算: 原值为1 则非计算 为0 ; 再与 0 与计算 有0 为0 ; 再与 | (byte)(SetMask) 或计算 */
 1   0  263天前
admin
415
 cmd # 进入cmd 命令界面diskpart # 进入磁盘分区工具list volume# 列出磁盘select volume c# 选择 c 盘extend # 扩容 选择的磁盘如果还是不行:1. 安装 winpe :   http://work.eisc.cn/ruanjian/windows/%E5%BF%85%E5%A4%87%E8%BD%AF%E4%BB%B6/WePE64_V2.2.exe下载后安装进系统,也可以安装到 u盘2.  打开傲梅分区助手 ---> 将空闲分区合并到目标分区
 1   0  269天前
admin
460
#include <fstream> #include <iostream> using namespace std; //--- 文件和流 --- // ofstream 输出文件流,用于创建并写入文件; ifstream 输入文件流,用于读取文件; fstream 文件流,同时有前面两种功能 int main () { char data[100]; // 以写模式打开文件, 定义一个文件打开函数 SetFile ofstream SetFile; SetFile.open("1.txt"); cout << "Enter your name: "; cin.getline(data, 100); // 向文件写入用户输入的数据, 前面定义为 打开 1.txt SetFile << data << endl; cout << "Enter your age: "; cin >> data; // 输入到变量 cin.ignore(); // cin.ignore常用功能:清除以回车结束的输入缓冲区的内容,消除上一次输入对下一次输入的影响 // 再次向文件写入用户输入的数据 SetFile << data << endl; // 关闭打开的文件 SetFile.close(); // 以读模式打开文件 ifstream infile; infile.open("1.txt",ios::in); // ios::app 追加模式,写入到文件末尾 ; ios::ate 打开文件定位到末尾 ;ios::in 打开文件用于读取; ios::out 打开文件用于写入 ; ios::trunc 打开文件,存在就被截断,长度为 0 cout << "Reading from the file" << endl; infile >> data; // 在屏幕上写入数据 cout << data << endl; // 再次从文件读取数据,并显示它 infile >> data; cout << data << endl; // 关闭打开的文件 infile.close(); return 0; }
 2   0  278天前
admin
532
wget -O gitea https://dl.gitea.io/gitea/1.17.4/gitea-1.17.4-linux-amd64chmod +x gitea ; ./gitea web参考连接:https://docs.gitea.io/zh-cn/install-from-binary/  Jenkins:   https://www.jenkins.io/zh/doc/book/installing/物联网网关平台:http://www.ithingsboard.com/docs/reference/http-api/node-red:  https://nodered.org/
 1   0  278天前
admin
516
#include <iostream> #include <assert.h> using namespace std; // c++ 类 访问控制和继承,能访问的类型: // 同一个类: public protected [prəˈtektɪd] 受保护 private [ˈpraɪvət] 私有 // 派生类:public protected // 外部类:public class A{ public: // 定义类 A 的公共函数 A 和 fun int a; A(){ a1 = 1; a2 = 2; a3 = 3; a = 4; } void fun(){ cout << a << endl; //正确 cout << a1 << endl; //正确 cout << a2 << endl; //正确 cout << a3 << endl; //正确 } public: int a1; protected: int a2; private: int a3; }; class B : public A{ public: // 派生类 int a; B(int i){ A(); a = i; } void fun(){ cout << a << endl; //正确,public成员 cout << a1 << endl; //正确,基类的public成员,在派生类中仍是public成员。 cout << a2 << endl; //正确,基类的protected成员,在派生类中仍是protected可以被派生类访问。 // cout << a3 << endl; //错误,基类的private成员不能被派生类访问。 } }; int main(){ B b(10); //外部类,只能访问 public cout << b.a << endl; cout << b.a1 << endl; //正确 // cout << b.a2 << endl; //错误,类外不能访问protected成员 // cout << b.a3 << endl; //错误,类外不能访问private成员 return 0; }
 1   0  279天前
admin
616
#!/bin/bash cishu=30 lable=3 set_config_log(){ jieguofile=tongji-$i tongjifile="tongji.txt" charulog=("`n="0x1" ; cat $i | grep "nEventType" |grep -v JT | awk -v awknr="$n" '$NF==awknr' | awk -F"," '{print $4 "," $5}' |uniq -c | sort -n`") charu=(` n="0x1" ; cat $i | grep "nEventType" |grep -v JT | awk -v awknr="$n" '$NF==awknr' | awk -F"," '{print $4 "," $5}' |uniq -c | sort -n | awk -F" " '{print $1}' `) charu=`echo ${charu[*]} | sed "s/ /+/g"` ; charu=$[charu] charulv=`echo "" | awk -v charu="$charu" -v cishu="$cishu" '{printf "%0.2f",charu/cishu*100}'` ; charulv=${charulv:0:4} lablelist=$(n="0x1" ; cat $i | grep "nEventType" |grep -v JT | grep "labelNum = $lable" | awk -v awknr="$n" '$NF==awknr' | awk -F"," '{print $4 "," $5}' |uniq -c | sort -n) lablegs=$(echo $lablelist | awk -F" " '{print $1}') ; lablegs=`echo "" | awk -v lablegs="$lablegs" -v cishu="$cishu" '{printf "%0.2f",lablegs/cishu*100}'` ; lablegs=${lablegs:0:4} bachulog=("`n="0x2" ; cat $i | grep "nEventType" |grep -v JT | awk -v awknr="$n" '$NF==awknr' | awk -F"," '{print $4 "," $5}' |uniq -c | sort -n`") bachu=(` n="0x2" ; cat $i | grep "nEventType" |grep -v JT | awk -v awknr="$n" '$NF==awknr' | awk -F"," '{print $4 "," $5}' |uniq -c | sort -n | awk -F" " '{print $1}' `) bachu=`echo ${bachu[*]} | sed "s/ /+/g"` ; bachu=$[bachu] bachulv=`echo "" | awk -v bachu="$bachu" -v cishu="$cishu" '{printf "%0.2f",bachu/cishu*100}' ` ; bachulv=${bachulv:0:4} echo "#-------------- $i ---------------# " >> $tongjifile echo " 测试次数:$cishu 识别插入次数: $charu 识别插入正确率: $charulv % 识别拔出次数: $bachu 识别拔出识别率:$bachulv % 贴标签个数: $lable 正确识别标签率:$lablegs % " >> $jieguofile echo " 测试次数:$cishu 识别插入次数: $charu 识别插入正确率: $charulv % 识别拔出次数: $bachu 识别拔出识别率:$bachulv % 贴标签个数: $lable 正确识别标签率:$lablegs % " >> $tongjifile echo " " >> $tongjifile echo " #----------- 识别插入日志 -------------# ${charulog[*]} #----------- 识别拔出日志 ------------# ${bachulog[*]} #---------- 识别标签正确日志 ------------# $lablelist " >> $jieguofile } runset(){ file=(`ls | grep log | grep -v tongji`) for i in ${file[*]} do set_config_log done } runset
 5   0  288天前
admin
649
#include <stdio.h> #include <string.h> // 字符串操作函数 :1 strcpy 2 memcpy 3 strncpy 4 memset 5 strcat 6 strlen 7 strcmp // 1 和 2 复制并且替换原变量,1 仅支持字符串; 3 替换字符串开头多少位; 4 将变量二的多少位添加到 变量一的尾部 // 5 字符串末尾追加; 6 计算字符串长度; 7 比较两个字符串,= > < 返回 0 1 -1 int zifu (char aa[],char bb[]) { char str1[99]; memcpy(str1,aa,strlen(aa)); printf("memcpy 函数 将 aa 数组字符串, 长度为 aa 大小 到 str1 得到的值:%s \n \n", str1); // 数组不能直接赋值,只能 cpy 复制。 strcpy 只能复制字符串 遇到符"\0" 结束 。 // memcpy 可以复制任何内容: 如数组。 包含“\0” 可以复制 strncpy(str1,bb,2); printf("strncpy 函数 将 bb 中的 前两位追加到 str1 末尾,值:%s \n \n", str1); memset(str1,aa, strlen(aa)); printf("memset 替换前面 aa 变量数 位为:%s \n aa 的值: %s \n ",str1,aa); char str2[40]; char str3[99]; strcpy (str3,"copy successful"); printf(" strcpy 复制并且覆盖目前 str3 的值: %s \n ",str3); strcpy (str3,str1); printf ("str1: %s\nstr2: %s\n 覆盖函数 strcpy 用str1覆盖后 str3: %s\n",str1,str2,str3); return 0; } void main() { char a[20]="aaaaaaaaaa" ; char b[20]="bbbbbbbbb"; zifu(a,b); // 先定义参数,按照顺序传值给函数并且执行 }
 7   0  292天前
admin
772
1.nginx 开启 tcp 转发   2. 配置nginx负载均衡# nginx  做负载均衡是基于 nginx 的tcp 转发,转发多个目标地址来实现的 # 1. nginx 配置tcpyum install nginx-mod-stream -y           # 安装动态模块ll /usr/lib64/nginx/modules                    # 查看动态模块文件vi /etc/nginx/nginx.conf                          # 设置配置文件重点:需要注释掉动态模块冲突引用:# include /usr/share/nginx/modules/*.conf;# 添加配置:nginx 主配置文件最外层添加,可以第一行顶部顶部添加load_module /usr/lib64/nginx/modules/ngx_stream_module.so;include /www/www/tcp/*.conf;# 设置动态模块的配置文件路径 #  2. 配置nginx负载均衡  stream {  upstream eisc {          ip_hash;          # 会话保持           server 192.168.0.14:8080 weight=3;           server 192.168.0.15:8080 weight=7;          # 权重越高,在被访问的概率越大,分别是30%,70%。          # 如吧不需要配置权重,可以取消weight 参数      }       server {            listen       80;           proxy_pass   eisc;           # 添加web服务 80 端口,请求转发到 eisc 规则      }}#---------- 案例 2 -----------# stream { upstream eisc { server 8.219.134.200:1180; } server { listen 1180; proxy_pass eisc; } } #  3 nginx 配置站点显示文件 server{ listen 800; #server_name kbash.cn www.kbash root /datadisk/eisc/download; location / { #root /mnt/software; #我们开始新建的目录 autoindex on; #以列表信息显示目录文件 index index.html index.htm; charset utf-8; } } 前提条件:nginx 开启tcp 端口转发:https://www.eisc.cn/index.php?c=read&id=978&page=1
 2   0  557天前
admin
1484
 #    系统服务cd  /usr/lib/systemd/system/sudo nano web_start.service# 进入目录,编辑文件写入服务, unit 服务器说明, ExecStart 启动的内容[Unit] Description=start web [Service] Type=forking ExecStart=/datadisk/eisc/server/shell/start.sh ExecReload=/bin/kill -SIGHUP $MAINPID ExecStop=/bin/kill -SIGINT $MAINPID [Install] WantedBy=multi-user.target   sudo systemctl daemon-reload   sudo systemctl disable web_start.service   sudo systemctl enable web_start.service# 重载配置, 先删web除开机启动 ,再添加 服务sudo mkdir -p /datadisk/eisc/server/shell/ ; cd /datadisk/eisc/server/shell/ sudo chown root:root start.sh ; sudo chmod 777 start.shsudo nano /datadisk/eisc/server/shell/start.sh#!/bin/bash # bash 解释器 一定要在第一行 开头写,否则下面脚本不执行,开机启动不成功。 由于是 service服务,因此此脚本是 root 用户执行 /bin/nginx /bin/php-fpm # 可以后台启动: /bin/php-fpm &#----------------------------------------------  其他备份 忽略 ------------------------------------------------------## 重启服务器生效[root@wwweisccn ~]# cat /usr/lib/systemd/system/eisc-logdata.service[Unit]# 服务描述Description=eisc logdate# 在网络初始化之后启动After=network.target[Service]# 服务类型Type=forking# 类型1:oneshot:程序执行完成就自动结束了,没有后台进程,比如执行一个shell# 类型2:forking:需要一个后台守护进程一直在运行,比如运行nginx、apache、sshd# https://blog.csdn.net/seaship/article/details/108235858# 守护进程:http://www.gosanye.com/post/3755.html# 进程退出立即重启Restart=alwaysRestartSec=5# 服务每5秒重新启动一次StartLimitInterval=0# 工作目录WoringDirectory=/root/eisc# 启动命令ExecStart=/root/eisc/date.sh[Install]# 当系统以多用户方式启动时,这个服务需要被自动运行WantedBy=multi-user.target #  小绿叶技术博客 安防系统 cat /usr/lib/systemd/system/eisc-anfang.service[Unit]# 服务描述Description=eisc anfang# 在网络初始化之后启动#After=network.target remote-fs.target nss-lookup.targetAfter=auditd.service systemd-user-sessions.service time-sync.target[Service]#Type=forking# 保留一个守护进程,持续运行,会报错,不加这个参数。#PrivateTmp=true# 工作目录WoringDirectory=/eisc/anfang# 启动命令ExecStart=/eisc/anfang/ip.shRestartSec=30s# 重启服务, 无效,# 需要在脚本里面自己加 无限循环,保持运行生命[Install]# 当系统以多用户方式启动时,这个服务需要被自动运行WantedBy=multi-user.target#----------- 加入开机启动 ------#sudo systemctl enable eisc-anfang.service # 其他说明systemctl start eisc-logdata.service                                 # 启动服务systemctl enable eisc-logdata.service                              # 加入开机启动systemctl disable eisc-logdata                                          # 取消开机启动systemctl status eisc-logdata                                           # 查看改服务的状态#--------------------------------- nginx 服务案例 --------------------------------------#[Unit]Description=The nginx HTTP and reverse proxy serverAfter=network-online.target remote-fs.target nss-lookup.targetWants=network-online.target[Service]Type=forkingPIDFile=/run/nginx.pid# Nginx will fail to start if /run/nginx.pid already exists but has the wrong# SELinux context. This might happen when running `nginx -t` from the cmdline.# https://bugzilla.redhat.com/show_bug.cgi?id=1268621ExecStartPre=/usr/bin/rm -f /run/nginx.pidExecStartPre=/usr/sbin/nginx -tExecStart=/usr/sbin/nginxExecReload=/usr/sbin/nginx -s reloadKillSignal=SIGQUITTimeoutStopSec=5KillMode=processPrivateTmp=true[Install]WantedBy=multi-user.target#-------------------------------------------------------------------------------------#开机启动服务编写进入目录  cd /etc/systemd/system/1:编写属于自己的unit文件,命令为mybash.service,整个文件如下这边以mybash开机运行为例:1.建立服务文件1、vim /lib/systemd/system/mybash.service文件内容如下:[Unit]Description=mybash#  [dɪ ˈs  k rɪ   p  ʃn]   di s k lui p xin  服务的简单描述 After=network.target# 依赖,仅当依赖的服务启动之后再启动自定义的服务单元# Documentation : 服务文档[Service]Type=forking# Type : 启动类型simple、forking、oneshot、notify、dbus# Type=forking  以 fork 方式从父进程创建子进程,创建后父进程会立即退出ExecStart=/etc/nginx start# 启动当前服务的命令ExecReload=/etc/nginx  restart# 重启当前服务的命令ExecStop=/etc/nginx  stop# 停止服务PrivateTmp=true#ExecStart                       # 启动当前服务的命令#ExecStartPre                 # 启动当前服务之前执行的命令#ExecStartPost               # 启动当前服务之后执行的命令#ExecReload                   # 重启当前服务时执行的命令#ExecStop                     # 停止当前服务时执行的命令#ExecStopPost              # 停止当其服务之后执行的命令[Install]WantedBy=multi-user.target################################# 参考资料和说明 ###################################---------- [Unit] ----------## 配置文件的第一个区块Description                        # 简短描述Documentation                 # 文档地址Requires                            # 当前 Unit 依赖的其他 Unit,如果它们没有运行,当前 Unit 会启动失败Wants                                # 与当前 Unit 配合的其他 Unit,如果它们没有运行,当前 Unit 不会启动失败BindsTo                             # 与Requires类似,它指定的 Unit 如果退出,会导致当前 Unit 停止运行Before                               # 如果该字段指定的 Unit 也要启动,那么必须在当前 Unit 之后启动After                                 # 如果该字段指定的 Unit 也要启动,那么必须在当前 Unit 之前启动Conflicts                           # 这里指定的 Unit 不能与当前 Unit 同时运行Condition...                      # 当前 Unit 运行必须满足的条件,否则不会运行Assert...                            # 当前 Unit 运行必须满足的条件,否则会报启动失败[Install]通常是配置文件的最后一个区块,用来定义如何启动,以及是否开机启动。它的主要字段如下。WantedBy:它的值是一个或多个 Target,当前 Unit 激活时(enable)符号链接会放入/etc/systemd/system目录下面以 Target 名 + .wants后缀构成的子目录中RequiredBy:它的值是一个或多个 Target,当前 Unit 激活时,符号链接会放入/etc/systemd/system目录下面以 Target 名 + .required后缀构成的子目录中Alias:当前 Unit 可用于启动的别名Also:当前 Unit 激活(enable)时,会被同时激活的其他 Unit[Service]区块用来 Service 的配置,只有 Service 类型的 Unit 才有这个区块。它的主要字段如下。Type:定义启动时的进程行为。它有以下几种值。Type=simple:默认值,执行ExecStart指定的命令,启动主进程Type=forking:以 fork 方式从父进程创建子进程,创建后父进程会立即退出Type=oneshot:一次性进程,Systemd 会等当前服务退出,再继续往下执行Type=dbus:当前服务通过D-Bus启动Type=notify:当前服务启动完毕,会通知Systemd,再继续往下执行Type=idle:若有其他任务执行完毕,当前服务才会运行ExecStart:启动当前服务的命令ExecStartPre:启动当前服务之前执行的命令ExecStartPost:启动当前服务之后执行的命令ExecReload:重启当前服务时执行的命令ExecStop:停止当前服务时执行的命令ExecStopPost:停止当其服务之后执行的命令RestartSec:自动重启当前服务间隔的秒数Restart:定义何种情况 Systemd 会自动重启当前服务,可能的值包括always(总是重启)、on-success、on-failure、on-abnormal、on-abort、on-watchdogTimeoutSec:定义 Systemd 停止当前服务之前等待的秒数Environment:指定环境变量# https://www.cnblogs.com/aaronLinux/p/6861425.html
 1   0  576天前
admin
656
#include <stdio.h> #include <string.h> // 1.输入和输出如打印字符, 2.各种字符和数组操作 #define Lengtha 30 #define Lengthb 30 // 容器要大于 存放量,否则溢出 struct myIN { char name[Lengtha]; char suzhi[Lengthb]; }; // 定义结构体 名字: myIN 成员: name 和 suzhi ,它们为数组 特征是 中括号,长度为 30 // 作用:变量不用重复定义类型 void kvmlist(void *qstatus,void *qname) { // 定义函数,需要给参数才执行 FILE *fp=NULL; char temp64[64]={0}; char qlist[999]={0}; memcpy(temp64,"virsh list --all",20); // 定义指针变量 默认为空,类型是文件 // 定义两个数组变量初始为0 // memcpy 替换复制内容 fp=popen(temp64,"r"); fread(qlist, 999,1,fp ); pclose(fp); printf(" \n %s \n",qlist); // 由 popen 函数去执行 shell 命令获取虚拟机 // 读取函数: 1.内存块指针; 2.读取每个元素的大小,字节;3.元素个数; 指针文件或流 // pclose 关闭 和 打印 struct myIN dy[3]={ {"rv1126","工程编译主机"},{"win2012","办公windos桌面"},{"www","开发网站"} }; // 结构体直接传值:数组dy 继承结构体 myIN ,有两个成员,数组两个元素对应成员 //---------- 结构体赋值 -----------# struct myIN *csp; csp = &dy; printf(" csp 结构体取出 dy 数据,结构体赋值。 目前只打印第一个名字:%s \n ", csp[0].name ); // 结构体 -> 含义 重新赋值 // dy[1]->name = "0"; // 如果符号前是指针类型,那么用 -> 否则用 . //------------------------ for(int i=0;i<3;i++){ printf("列出主机名称: %s 说明: %s\n", dy[i].name,dy[i].suzhi ); } // dy[i]->name 表示:i 是数数数组角标,结构体数组 第一组成员 中的name 的值 printf("\n \n您需要控制主机:%s 状态为:%s \n 格式:virsh start/shutdown www \n", qname, qstatus); memcpy(temp64,"virsh ",10); strcat(temp64,qstatus); strcat(temp64,qname); printf("\n 复制字符串的结果为:%s \n",temp64); system(temp64); } qemu_img() { char qcow2[99] = {0}; char status[99] = {0}; char qemuml[]={"qemu-img snapshot -"}; FILE *fp=NULL; char qlist[999]; printf("\n \n #----------- 镜像快照管理 ------------# \n \ 请输入管理方式 和镜像 : l 查看 a 恢复 c 创建 d 删除 , 案例: l www.qcow2 \n"); printf("请输入两个参数,用空格隔开: "); scanf("%s %s", status , qcow2 ); // scanf 方式获取键盘输入 printf("控制状态: %s 主机名称:%s 镜像字符长度: %d \n",status,qcow2 ); // scanf 中的 %s 不能有逗号,否则无法接收完全 strcat(qemuml,status); memcpy(qcow2,qemuml,strlen(qemuml)); printf("操作的快照指令为:%s \n", qemuml); // memcpy 替换复制到字符串前面,但是 本身字符被替换 fp=popen(qemuml,"r"); fread(qlist, 999,1,fp ); pclose(fp); printf(" \n 查看当前镜像下的快照:\n %s \n",qlist); } char main(int sl, char *sz[]) // 第一个变量是参数数量,第二个是指针数组,接收输入参数 { printf("程序本身名字也占一个参数位置 sz[0],总参数: %d\n",sl); char a[Lengtha]; char b[Lengtha]; char c[Lengtha]; // 数组才能被数组赋值,此处是数组长度。角标是指针数组 memcpy(a,sz[1],Lengthb); memcpy(b,sz[2],Lengthb); memcpy(c,sz[3],Lengthb); // 定义变量 a b c d 为:数组第 1234 个元素的值 printf("输入的第一个参数a : %s\n 输入的第二个参数b : %s \n 第三个参数: %s \n" ,a,b,c); char qstatus[20]; char qname[20]; memset(qname,' ',2); memset(qstatus,' ',2); strcat(qstatus,b); strcat(qname,c); printf("传递两个参数: qname: %s ; qstatus: %s \n \n", qname,qstatus); kvmlist(qstatus,qname); qemu_img(); return 0; }
 2   0  295天前
admin
653
#include <stdio.h> #include <string.h> #include <time.h> #include <stdlib.h> // popen 函数使用 // 引用函数库,相当于 linux shell 中 apt install xxx 安装包,安装后才能使用这个包中的命令 char shuzu () { char str[99]; // 定义数组元素个数99 没有赋值 strcpy(str,"This is string.h library function"); // 字符串复制: 1.接收字符串变量 str; 2.定义字符串 puts(str); // puts 打印数组内容 memset(str,'3',6); // 替换函数: 1.被替换的数组; 2.替换目标字符串; 3.替换多少个位置; 字符串前12 个被替换成0 puts(str); // 字符串标准输出 char a[99]; strcpy(a,"zifuhcuan biaozhun \\n $a "); puts(a); printf("换行符号,需要加转译: %s\n", a); int aa[3]={1111,22222,999239}; // 定义数组aa 有三个元素,大括号顺序赋值 int n; // 定义循环变量,循环指定打印: aa[1] 到 aa[3] 之间的所有数组 for (n=0;n<3;n++){ printf("打印数组: %d\n", aa[n] ); } return(0); // 该函数执行完,返回 0 } int zhizhen() { FILE *fp; // 定义指针变量 char c[] = "This is runoob"; // 定义数组,元素个数不固定 char dp[20]; fp = fopen("file.txt", "w+"); // fopen 打开文件方式:w+ 读写 fwrite(c, strlen(c) + 1, 1, fp); // write [ raɪ t ] 写;定义写入规则, 将数组 c 中的内容写入到 fp 文件中 // 第1个:被写入的内容;2.写入的元素大小:strlen 计算字符串长度;3.元素个数; 4.指针文件 printf("字符串长度 %d\n", strlen(c)+1); // strlen 计算变量字符串的长度 再 +1 fseek(fp, 0, SEEK_SET); // 写入文件的位置:1.指针文件,2.偏移字节量(0 不偏移),3. 开始偏移写入位置:SEEK_SET 文件开头,SEEK_CUR 指针当前位置, SEEK_END 文件末尾 fread(dp, strlen(c)+1, 1, fp); // 读取函数: 1.内存块指针; 2.读取每个元素的大小,字节;3.元素个数; 指针文件 printf(" 再次读取文件查看内容: %s\n", dp); fclose(fp); // 关闭文件指针 return(0); } int popencs(void) { // popen 执行shell 命令并返回结果 #define BUF_SIZE 1024 // 定义常量 值为1024 char buf[BUF_SIZE]; // 定义数组buf 长度 为 1024 FILE * p = NULL; // 定义指针为空 p = popen("ifconfig enp2s0", "r"); // 读取shell 命令结果: r 为读取, w 写入:通常是创建文件,或者启动服务 if (!p) { fprintf(stderr, "Erro to popen"); } while (fgets(buf, BUF_SIZE, p) != NULL) { // fgets 读取并存储: 1.储存到数组 buf; 2.读取最大字符数 1024 字; 3.对象指针字符流 fprintf(stdout, "%s", buf); // 打印:发送格式化输出流到 stdout } pclose(p); // 关闭文件指针 return 0; } int timehs () { time_t curtime; time(&curtime); printf("当前时间 = %s", ctime(&curtime)); return(0); } // 结构体数组指针 void zhizhenjiegou () { struct jiegou { // 定义结构体名 jg; 成员: sum ,name长度20 ,sex, score 相似于数据库建表 int num; char name[20]; char sex; int age; }; struct jiegou stu[3] = {{10101, "Li Lin", 'M', 18}, {10102, "Zhang Fun", 'M', 19}, {10103, "Wang Min", 'F', 20}}; // 定义结构体 jg 的数组变量 stu 简称:结构体变量 ; 类似于数据库 jg 中的表 stu // 结构体变量 stu 有三组数据,相似于数据库表有三个人的学号,名字等等 struct jiegou *p; // 定义指针p为:结构体(数据库); 三个等价 stu.num 和 (*p).num 和 p->num // p = &stu; 这个是读取内存地址,符号 & printf("No. name sex age\n"); for(p=stu; p<stu+3;p++) // 定义指针为:结构体变量(表)中的元素,循环次数为3次 printf("%5d %-12s %-8c %4d\n", p->num, p->name, p->sex, p->age); // %-12s 左对齐输出字符串, %-2c 左对其输出单个字符 } // c 结构体:https://www.runoob.com/w3cnote/c-structures-intro.html void main() // 定义任意类型 main 函数 { shuzu(); // 执行数组函数 char a[]="开始执行 zhizhen 写入文件函数,前提需要创建 file.txt"; printf(" 字符数组赋值中文 格式 a[] \n %s", a); zhizhen(); // 执行指针函数 popencs(); timehs(); zhizhenjiegou(); }
 1   0  295天前
admin
602
之前 php 探针也正常,网站源码放入后,探针和php程序出现错误 No input file specified 解决方法: 删除网站源码根目录下的文件:.htaccess .user.ini 网站马上恢复正常。这两个文件是宝塔自动生成的防跨站文件。有为静态转发规则。 如果需要自己搭建 lnmp 环境参考: 阿里云:https://developer.aliyun.com/article/1062782 小绿叶技术博客:https://www.eisc.cn/index.php?c=read&id=1118&page=1
 7   0  297天前
admin
1069
#!/bin/bash # ubuntu20 shell 脚本自动编译web安装网站环境 nginx199 php7/8 mariadb1011 以 systemd 方式设置开机启动 # mysql 重置 root 密码,创建 或删除 mysql 子库和子用户 downdir="/datadisk/eisc/download" ; sudo mkdir -p $downdir ; sudo chmod 777 -R $downdir installdir="/datadisk/eisc/server" ; sudo mkdir -p $installdir # 安装路径不能将所有目录都为 777 , 如: mysql 的 /etc/my.cnf 不能为 777 否则mysql 无法启动 www="/datadisk/eisc/www" wwwconf="/datadisk/eisc/www/wwwconf" # 设置web 网站路径 和 nginx conf 子站点路径 echo " 欢迎使用自动安装 网站web 环境shell 脚本, nginx199 php-fpm mariadb10.11 当前需要更新 apt upgrade , 如果遇到弹窗选择包,请回车跳过。不要按 Esc 退出. 建议选择 ubuntu20.04 安装完成重启服务器后,启动web服务命令: sudo nginx199 ; sudo php-fpm743 ; sudo /etc/init.d/mariadb1011 restart 数据库默认登陆: mysql -u root -peisc.cn server 源码下载路径:$downdir server 安装路径:$installdir www 网站路径:$www www nginx conf 子站点路径:$wwwconf C 2022.12.04 小绿叶技术博客 eisc.cn " sleep 3; if [ ! -e /etc/init.d/mariadb1011 ] then sudo apt update ; sudo apt upgrade -y fi down_guanfang_url(){ downNginxUrl="http://nginx.org/download/nginx-1.9.9.tar.gz" downPHPurl="https://www.php.net/distributions" downMariadbUrl="https://archive.mariadb.org//mariadb-10.11.0/bintar-linux-systemd-x86_64/mariadb-10.11.0-linux-systemd-x86_64.tar.gz" # 手动下载数据库:https://mariadb.org/download/ downcgiccURL="http://ftp.gnu.org/gnu/cgicc/cgicc-3.2.19.tar.gz" } down_eisc_url(){ url="http://work.eisc.cn/ruanjian" downNginxUrl="$url/ubuntu/server/nginx-1.9.9.tar.gz" downPHPurl="$url/ubuntu/server/php" downMariadbUrl="$url/ubuntu/server/mariadb-10.11.0-linux-systemd-x86_64.tar.gz" downcgiccURL="$url/ubuntu/server/cgicc-3.2.19.tar.gz" } down_select(){ read -p "选择下载安装包地址: 1 官方下载 2 小绿叶技术博客下载. 请输入: " selectURL case $selectURL in "1") echo "当前选择官方下载..." ; down_guanfang_url ;; "2") echo "当前选择小绿叶技术博客下载..." ; down_eisc_url ;; *) echo "输入错误,请重新执行脚本! " ; exit ;; esac echo $downNginxUrl echo $downPHPurl echo $downMariadbUrl } down_select nginx_install(){ cd $downdir if [ ! -e /bin/nginx199 ] then echo "开始安装nginx 1.9.9" sudo apt install -y build-essential libtool \ libpcre3 libpcre3-dev \ zlib1g-dev openssl libgd-dev \ geoip-database libgeoip-dev # 安装gcc c++ ; pcre ; zlib ssl GD ; GeoIP 依赖库 if [ ! -e $downdir/nginx-1.9.9.tar.gz ] then wget $downNginxUrl fi if [ ! -e $downdir/nginx-1.9.9/configure ] then tar -xzvf nginx-1.9.9.tar.gz fi cd nginx-1.9.9 sudo mkdir -p $installdir/nginx/nginx1.9.9 ; sudo chmod 777 -R mkdir -p $installdir/nginx/nginx1.9.9 ./configure --prefix=$installdir/nginx/nginx1.9.9 sed -i "s/-Werror/ /g" objs/Makefile NR=`cat -n ./src/os/unix/ngx_user.c | grep cd.current_salt | awk -F" " '{print $1}'` sed -i "$NR d" ./src/os/unix/ngx_user.c sudo make && sudo make install sudo ln -s $installdir/nginx/nginx1.9.9/sbin/nginx /bin/nginx199 sudo killall nginx199 ; sudo nginx199 # 重新启动nginx sudo nginx199 ; nginx199 -V else echo "[ok]nginx 1.9.9 已经安装" fi } php_aptupdate(){ sudo apt install -y gcc make openssl curl libssl-dev libxml2-dev libzip-dev libcurl4-openssl-dev \ libpng-dev libjpeg-dev libwebp-dev libonig-dev libsqlite3-dev libsodium-dev libargon2-dev \ libkrb5-dev libbz2-dev libxslt-dev php-mbstring \ build-essential libtool libpcre3 libpcre3-dev zlib1g-dev libgd-dev geoip-database libgeoip-dev # 安装包: No package 'krb5-gssapi' found ; Please reinstall the BZip2 distribution ; No package 'libxslt' found # 报错解决参考:http://t.zoukankan.com/architectforest-p-15714248.html sudo groupadd www ; sudo useradd -g www www -s /bin/false # sudo groupadd www-data ; sudo useradd -g www-data www-data -s /bin/false # 重建用户,并且不允许用户登陆系统 echo " linux nginx + php-fpm 安装参考: https://www.php.net/manual/zh/install.unix.nginx.php " } php_release721(){ phpreleaseMl="php-7.2.1" phpreleaseInstall="php721" phpreleaseBin="php-fpm721" downPHPurl="$downPHPurl/$phpreleaseMl.tar.gz" echo "php 下载地址重新定义为:$downPHPurl" } php_release7433(){ phpreleaseMl="php-7.4.33" phpreleaseInstall="php743" phpreleaseBin="php-fpm743" downPHPurl="$downPHPurl/$phpreleaseMl.tar.gz" echo "php 下载地址重新定义为:$downPHPurl" } php_release811(){ phpreleaseMl="php-8.1.13" phpreleaseInstall="php811" phpreleaseBin="php-fpm811" downPHPurl="$downPHPurl/$phpreleaseMl.tar.gz" echo "php 下载地址重新定义为:$downPHPurl" } php_install(){ cd $downdir if [ ! -e /bin/$phpreleaseBin ] then echo "开始安装 $phpreleaseInstall " php_aptupdate if [ ! -e $downdir/$phpreleaseMl.tar.gz ] then wget $downPHPurl fi if [ ! -e $downdir/$phpreleasedown/configure ] then tar -xzvf $phpreleaseMl.tar.gz fi cd $phpreleaseMl sudo mkdir -p $installdir/php/$phpreleaseInstall ; sudo chmod 777 -R $installdir/php/$phpreleaseInstall ./configure --prefix=$installdir/php/$phpreleaseInstall --with-config-file-path=$installdir/php/$phpreleaseInstall/etc \ --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ --with-iconv-dir --with-freetype --with-jpeg --with-zlib \ --enable-zip \ --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl \ --enable-ftp --enable-gd --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-webp # --with-openssl # 第一行 指定安装路径,和 php.ini 路径为 $installdir/php/php72/etc # 第二行 开启php 的 php-fpm web功能。启动用户名和组 和 重要 开启php 的mysql connect() 函数 功能。 # 第三行 压缩解码工具 否则 php WordPress 无法无法正常启动 报错: is not a valid libtool object # 后面行,暂时没有研究. --with-openssl ubuntu22 编译不过 sudo make ; sudo make install #----------------------- 说明 -------------------# # 安装说明:https://www.php.net/manual/zh/install.php #--with-fpm-user - 设置 FPM 运行的用户身份(默认 - nobody)。 #--with-fpm-group - 设置 FPM 运行时的用户组(默认 - nobody)。 #--with-fpm-systemd - 启用 systemd 集成 (默认 - no)。 #--with-fpm-acl - 使用 POSIX 访问控制列表 (默认 - no)。 #--with-fpm-apparmor - 激活 AppArmor 集成 (默认 - no)。 #--with-fpm-selinux - 激活 SELinux 集成(默认 - no)。 #---------------------- php config ---------------# sudo cp $downdir/$phpreleaseMl/sapi/fpm/php-fpm.service.in /etc/systemd/system/php-fpm.service sudo cp $downdir/$phpreleaseMl/php.ini-development $installdir/php/$phpreleaseInstall/etc/php.ini sudo cp $installdir/php/$phpreleaseInstall/etc/php-fpm.conf.default $installdir/php/$phpreleaseInstall/etc/php-fpm.conf sudo cp $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf.default $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf #---------- 更改用户 NR=`cat -n $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf | grep -w user | grep nobody | awk -F" " '{print $1}'` sudo sed -i "$NR s/nobody/www/g" $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf NR=`cat -n $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf | grep -w group | grep -v listen | grep nobody | awk -F" " '{print $1}'` sudo sed -i "$NR s/nobody/www/g" $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf NR=`cat -n /etc/systemd/system/php-fpm.service | grep ProtectSystem | awk -F" " '{print $1}'` sudo sed -i "$NR s/full/false/g" /etc/systemd/system/php-fpm.service #---------- 解决 No input file specified NR=`cat -n $installdir/php/$phpreleaseInstall/etc/php.ini | grep fix_pathinfo | grep -v provides| awk -F" " '{print $1}'` sudo sed -i "$NR a cgi.fix_pathinfo=1" $installdir/php/$phpreleaseInstall/etc/php.ini sudo sed -i "$NR d" $installdir/php/$phpreleaseInstall/etc/php.ini NR=`cat -n $installdir/php/$phpreleaseInstall/etc/php.ini | grep force_redirect | grep 1| awk -F" " '{print $1}'` sudo sed -i "$NR a cgi.force_redirect=0" $installdir/php/$phpreleaseInstall/etc/php.ini sudo sed -i "$NR d" $installdir/php/$phpreleaseInstall/etc/php.ini #----------- NR=`cat -n $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf | grep "127.0.0.1:9000" | awk -F" " '{print $1}'` # sudo sed -i "$NR a listen = /var/run/$phpreleaseBin.sock" $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf sudo sed -i "$NR a listen = 127.0.0.1:9000" $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf sudo sed -i "$NR d" $installdir/php/$phpreleaseInstall/etc/php-fpm.d/www.conf sudo cp $installdir/php/$phpreleaseInstall/sbin/php-fpm /bin/$phpreleaseBin sudo sudo chmod +x /bin/$phpreleaseBin ; sudo $phpreleaseBin # 重载配置,并且启动php echo "php 安装完成,启动与停止php : sudo killall $phpreleaseBin ; sudo sudo chmod +x /bin/$phpreleaseBin ; sudo $phpreleaseBin " #sudo sed -i "778 s/;//g" /etc/php/7.4/fpm/php.ini #sudo sed -i "778 s/1/0/g" /etc/php/7.4/fpm/php.ini #sudo sed -i "798 s/;//g" /etc/php/7.4/fpm/php.ini # 解决 No input file specified else echo "php 已经安装" fi } php_select(){ echo "请输入您要安装php 的版本: 提供版本: 1. php7.2.1 2. php7.4.33 3. php8.1.13 任意按键取消安装php 并且往下执行... " read -p "请输入版本编号:" selectxh case $selectxh in "1") echo "当前选择php版本 $phpreleaseMl 启动文件为: /bin/$phpreleaseBin " ; php_release721 ; php_install ;; "2") echo "当前选择php版本 $phpreleaseMl 启动文件为: /bin/$phpreleaseBin " ; php_release7433 ; php_install ;; "3") echo "当前选择php版本 $phpreleaseMl 启动文件为: /bin/$phpreleaseBin " ; php_release811 ; php_install ;; *) echo "[ok]退出安装 php " esac } nginx_web_config(){ sudo mkdir -p $wwwconf $www ; sudo chmod 777 -R $www setconf=`cat $installdir/nginx/nginx1.9.9/conf/nginx.conf | grep "$wwwconf" ` if [ ${#setconf} -gt 10 ] then echo "[ok]nginx 已经配置, 子站点目录: $wwwconf/www.conf" else NR=`cat -n $installdir/nginx/nginx1.9.9/conf/nginx.conf | grep http | grep "{" | awk -F" " '{print $1}'` sudo sed -i "$NR a include $wwwconf/*.conf; " $installdir/nginx/nginx1.9.9/conf/nginx.conf echo "<?php phpinfo(); ?>" > $www/www/p.php fi sudo nginx199 -s stop ; sudo nginx199 # 修改php 后重新启动nginx } create_www_conf(){ echo "案例: eisc.cn 114.114.114.114 62000" read -p " 请输入三个参数:" peizhi buff=( $peizhi ) yuming=${buff[0]} # 前端域名,增加到nginx 消息头部 ip=${buff[1]} # 后端服务器ip portmin=${buff[2]} portmin=$[portmin-1] # 设置最小端口,后面网站按照顺序自动加1 declare -A port port["www"]="62010" port["work"]="62011" port["sou"]="62012" port["enchantment"]="62013" port["guzheng"]="62014" port["zhoubao"]="62015" port["xibin"]="62100" cd $wwwconf; sudo chmod 777 -R $wwwconf $wwwconf/* if [ ! -e eiscwwwconf.tar.gz ] then sudo tar -czvf eiscwwwconf.tar.gz * sudo rm -rf `ls | grep -v eiscwwwconf.tar.gz` fi sudo rm -rf `ls | grep -v eiscwwwconf.tar.gz` file=(`ls $www | grep -vE "ssl|wwwconf|wwwroot|*.sh"`) for i in ${file[*]} do ((a++)) b=$[portmin+a] ; portlist[$c]=$b ; ((c++)) # 打印一次变量,接收一个元素存入数组: portlist if [ ! -e $www/$i/cgi-bin ] then sudo mkdir $www/$i/cgi-bin fi case $i in "www") b=${port[www]} ; echo "#------- www 被手动指定固定端口 $b -------#" ;; "work") b=${port[work]} ; echo "#------- work 被手动指定固定端口 $b -------#" ;; "sou") b=${port[sou]} ; echo "#------- sou 被手动指定固定端口 $b -------#";; "enchantment") b=${port[enchantment]} ; echo "#------- enchantment 被手动指定固定端口 $b -------#";; "guzheng") b=${port[guzheng]} ; echo "#------- guzheng 被手动指定固定端口 $b -------#";; "zhoubao") b=${port[zhoubao]} ; echo "#------- zhoubao 被手动指定固定端口 $b -------#";; "xibin") b=${port[xibin]} ; echo "#------- xibin 被手动指定固定端口 $b -------#";; esac echo " $i 创建web网站 的端口: $b 前端域名 + $i.$yuming + 后端ip port + $ip:$b + c++ cgi 解析目录: $i/cgi-bin" echo " $i 创建web网站 的端口: $b 前端域名 + $i.$yuming + 后端ip port + $ip:$b + c++ cgi 解析目录: $i/cgi-bin" >> log_www_conf.txt #--------- 生成前端转发 子站点文件 -----------# sudo mkdir -p $wwwconf/nginxzhuanfa ; sudo chmod 777 $wwwconf/nginxzhuanfa echo " server{ listen 80; server_name $i.$yuming; location / { proxy_pass http://$ip:$b; } } " > $wwwconf/nginxzhuanfa/$i-$b.conf if [ "$i" = "www" ] then echo " server{ listen 80; server_name $i.$yuming $yuming; location / { proxy_pass http://$ip:$b; } } " > $wwwconf/nginxzhuanfa/$i-$b.conf fi #---------- 后端转发子站点 ----------# echo " server { listen $b; root $www/$i; index index.php index.html index.htm index; add_header 'yuming is ' '$i.$yuming'; add_header 'ipport is ' '$ip:$b'; location ~ \.php { # fastcgi_pass unix:/var/run/php-fpm811.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; include fastcgi_params; } location /cgi-bin { fastcgi_pass unix:/var/run/fcgiwrap.socket; include fastcgi.conf; } } " > $wwwconf/$b.$i.conf done echo "[ok]创建网站日志存放在: $wwwconf/log_www_conf.txt" echo "[ok]前端转发 nginx 子文件目录: $wwwconf/nginxzhuanfa" sudo nginx199 -s reload } cgi_install_config(){ cd $downdir dir="$installdir/aspnet" ; sudo mkdir -p $dir; sudo chmod 777 -R $dir ; mkdir -p $dir/conf $dir/www/www sudo apt install -y build-essential libfcgi-dev autoconf libtool automake libtool spawn-fcgi fcgiwrap cgiport=10000 psnet=`sudo netstat -ntlp | grep -w $cgiport ` if [ ${#psnet} -lt 1 ] then spawn-fcgi -f /usr/sbin/fcgiwrap -a 127.0.0.1 -p $cgiport -F 32 -P /tmp/fastcgi-c.pid -u nobody -g nobody # 启动 fi echo "[ok]访问: 127.0.0.1/p.php 查看 效果, 子站点目录:$wwwconf/www.conf " #--- 安装cgicc web模块 ---# if [ ! -e cgicc-3.2.19.tar.gz ] then wget $downcgiccURL fi if [ ! -e $installdir/cgicc/bin/cgicc-config ] then sudo tar -xzvf cgicc-3.2.19.tar.gz ; cd cgicc-3.2.19 ./configure --prefix=/usr sudo make ; sudo make install sudo cp /usr/lib/libcgicc.* /usr/lib64/ fi # g++ -o get get.cpp -lcgicc # 使用 cgicc 编译c++ 方法: g++ 编译c++ 程序; gcc 编译c语言; -o 生成可执行文件 get 被编译的文件:get.cpp 指定库 cgicc } nginx_config_if(){ echo " #----------- 配置子站点nginx ------------# 请输入 前端转发服务器域名,后端服务器公网ip 和 第一个网站端口。有多个网站,端口自动计数加1 。 如果没有域名 和前端服务器,随意输入三个参数,但端口一定为 65536 以内。脚本可以重复执行,重新配置 " read -p "是否进行配置: y 需要配置, 任意按键并回车跳过, 请输入: " ifa if [ "$ifa" = "y" ] then echo "正在进行配置 子站点..." create_www_conf ; cgi_install_config # 配置子站点 else echo "[ok]已经跳过nginx配置子站点!" fi } mariadb_install(){ cd $downdir if [ ! -e /etc/init.d/mariadb1011 ] then echo "开始安装 mariadb-10.11" sudo apt install -y libncurses5 sudo groupadd mysql ; sudo useradd -g mysql mysql -s /bin/false # 创建mysql用户组和用户,不允许登陆系统 if [ ! -e $downdir/mariadb-10.11.0-linux-systemd-x86_64.tar.gz ] then wget $downMariadbUrl fi if [ ! -e $installdir/mysql/mariadb1011/README.md ] then sudo mkdir -p $installdir/mysql ; sudo chmod 777 -R $installdir/mysql sudo tar -xzvf mariadb-10.11.0-linux-systemd-x86_64.tar.gz -C $installdir/mysql/ sudo mv $installdir/mysql/mariadb-10.11.0-linux-systemd-x86_64 $installdir/mysql/mariadb1011 fi # sudo chown -R mysql mariadb-10.11 ; cd mariadb-10.11 # 更改文件属性为mysql组,mysql 用户 cd $installdir/mysql/mariadb1011 sudo mkdir -p $installdir/sqldata ; sudo chmod 777 -R $installdir/sqldata sudo chown -R mysql:mysql $installdir/sqldata ; sudo chmod 777 -R $installdir/sqldata sudo $installdir/mysql/mariadb1011/scripts/mysql_install_db --user=mysql --basedir=$installdir/mysql/mariadb1011 --datadir=$installdir/sqldata # 初始化mariadb sudo cp $installdir/mysql/mariadb1011/support-files/wsrep.cnf /etc/my.cnf sudo chmod 777 /etc/my.cnf echo " [mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M #添加以下配置 basedir=$installdir/mysql/mariadb1011 datadir=$installdir/sqldata " > /etc/my.cnf sudo chmod 644 /etc/my.cnf # my.cnf 权限为 777 不安全,所以mysql无法启动。 sudo cp $installdir/mysql/mariadb1011/support-files/mysql.server /etc/init.d/mysql sudo cp $installdir/mysql/mariadb1011/bin/mysqld /etc/init.d/mysqld sudo ln -s $installdir/mysql/mariadb1011/support-files/mysql.server /etc/init.d/mariadb1011 sudo chmod +x /etc/init.d/mysqld sudo chmod 777 /etc/profile echo " #MARIADB export MARIADB_HOME=$installdir/mysql/mariadb1011 export PATH=$PATH:${MARIADB_HOME}/bin " >> /etc/profile # 设置环境变量,等于:添加执行文件的路径。 先定义 MARIADB_HOME 变量的路径,再引用 sudo chmod 644 /etc/profile source /etc/profile ; bash #---------- 重置 mysql root 密码也是该流程 ---------# sudo killall mariadbd mysqld_safe runmysql=`sudo netstat -nltp | grep 3306 | grep -w tcp | grep mariadb` if [ ${#runmysql} -lt 1 ] then sudo /etc/init.d/mariadb1011 start fi # 重新启动mysql 服务, mysql 启动时候才能进行 mysqladmin 命令 重置密码 sleep 1; sudo $installdir/mysql/mariadb1011/bin/mysqladmin -u root password eisc.cn echo "数据库root 密码为: eisc.cn 使用命令更改密码: " echo "sudo $installdir/mysql/mariadb1011/bin/mysqladmin -u root password eisc.cn" sudo mkdir -p $installdir/back/sql/ ; sudo chmod 777 $installdir/back/sql/ else echo "[ok] mariadb1011 已经安装" fi } mysql_data(){ #------ 修改mysql data 数据目录 -----# sudo chmod 777 /eisc/ mkdir /eisc/data/ sudo chown -R mysql:mysql /eisc/data/ sudo chmod 777 /usr/local/mariadb-10.9.2/data/ sudo cp -r /usr/local/mariadb-10.9.2/data/* /eisc/data/ sudo /usr/local/mariadb-10.9.2/support-files/mysql.server stop sudo /usr/local/mariadb-10.9.2/support-files/mysql.server start } mysql_database(){ #!/bin/bash # shell 自动创建数据库 用户和密码 sudo apt install libncurses* # 解决mysql 命令报错,缺少库:Couldn't find any package by glob 'libncurses.so.5' sudo apt install mysql-client -y # 安装连接数据库工具 sudo mkdir /var/run/mysqld/ sudo ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock # 解决 mysql 报错,无法进入mysql 。 mariadb 的启动sock 不一样 runmysql=`sudo netstat -nltp | grep 3306 | grep -w tcp | grep mariadb` if [ ${#runmysql} -lt 1 ] then sudo /etc/init.d/mariadb1011 start fi sudo $installdir/mysql/mariadb1011/bin/mysqladmin -u root password eisc.cn # 启动数据库,重置数据库 root 用户密码为: eisc.cn echo "#---------------- 数据库管理工具 ------------# 参考输入案例: create eisc.cn www www 000000 localhost 1 创建 or 删除,输入: create 或 drop 2 数据库 root 用户密码 3 子数据库名 4 子库用户名 5 子库密码 6 开放数据库方式:本地/远程 输入: localhost 或 % 用空格隔开,必须按照顺序输入6个参数!" read -p "请输入:" in_buff buff=( abcd $in_buff); echo "你输入的信息为: ${buff[*]}"; case ${buff[1]} in "create") # mysql -uroot -p${buff[2]} -e "create database ${buff[3]} character set utf8 collate utf8_bin;" mysql -uroot -p${buff[2]} -e "create database ${buff[3]} character set utf8;" mysql -uroot -p${buff[2]} -e "grant all on ${buff[4]}.* to '${buff[4]}'@'${buff[6]}' identified by '${buff[5]}'" mysql -uroot -p${buff[2]} -e "show databases;SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS ListUsername FROM mysql.user where User='${buff[4]}';" ;; "drop") mysql -uroot -p${buff[2]} -e "drop database ${buff[3]}" mysql -uroot -p${buff[2]} -e "drop user '${buff[4]}'@'${buff[6]}'" mysql -uroot -p${buff[2]} -e "show databases;SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS ListUsername FROM mysql.user where User='${buff[4]}';" ;; esac } mysql_contor(){ runmysql=`sudo netstat -nltp | grep 3306 | grep -w tcp | grep mariadb` if [ ${#runmysql} -lt 1 ] then sudo /etc/init.d/mariadb1011 start fi # 启动数据库 echo "#---- 数据库 root 密码始终被重置为 eisc.cn ----# 如果需要手动重置为自己想要的密码,命令行手动执行命令: sudo $installdir/mysql/mariadb1011/bin/mysqladmin -u root password eisc.cn 将 eisc.cn 改为自己的密码 " read -p "是否进行数据库管理工作,创建数据库和用户,输入: y/n ? " ins if [ "$ins" = "y" ] then echo "开始管理数据库 ..." mysql_database else echo "[ok]退出数据库管理!" fi } kaiji_web_service(){ # ubuntu 以 systemd 服务方式,自动启动服务软件 systemdDir="/usr/lib/systemd/system" webname="eisc_web_start.service" cd $systemdDir ; sudo touch $webname ; sudo chmod 777 $webname #----- 写入 start.service 服务 -----# echo " [Unit] Description=start web [Service] Type=forking ExecStart=$installdir/shell/start.sh ExecReload=/bin/kill -SIGHUP \$MAINPID ExecStop=/bin/kill -SIGINT \$MAINPID [Install] WantedBy=multi-user.target " > $webname sudo apt install dos2unix -y sudo dos2unix $webname # 转为 unix 格式,否则可能出现字符乱码 sudo chmod 644 $webname sudo systemctl daemon-reload sudo systemctl disable $webname sudo systemctl enable $webname cd } kaiji_start_web_sh(){ read -p "是否继续进行配置 systemd 开机启动? y/n: " kaijisz if [ "$kaijisz" = "y" ] then kaiji_web_service # 启动这个函数 sudo mkdir -p $installdir/shell ; sudo chmod 777 -R $installdir/shell # 将脚本授权给 root 用户 echo "#!/bin/bash # bash 解释器 一定要在第一行 开头写,否则下面脚本不执行,开机启动不成功。 由于是 service服务,因此此脚本是 root 用户执行 $installdir/nginx/nginx1.9.9/sbin/nginx & $installdir/php/php743/sbin/php-fpm & /etc/init.d/mariadb1011 start & /bin/spawn-fcgi -f /usr/sbin/fcgiwrap -a 127.0.0.1 -p 10000 -F 32 -P /tmp/fastcgi-c.pid & touch \$HOME/log_start_web.txt ; chmod 777 \$HOME/log_start_web.txt echo \"服务已经自动自动,时间 \`date \`\" > \$HOME/log_start_web.txt " > $installdir/shell/start.sh echo "#----------------- 查看写入的开机启动脚本 -------------------#" cat $installdir/shell/start.sh sudo chmod +x $installdir/shell/start.sh $installdir/nginx/nginx1.9.9/sbin/nginx $installdir/php/php743/sbin/php-fpm sudo chown root:root $installdir/shell/start.sh ; sudo chmod 777 $installdir/shell/start.sh else echo "[ok]目前不配置systemd " fi } main(){ php_select nginx_install nginx_web_config nginx_config_if # 包含创建 www 子站点 和 c++ cgi mariadb_install # 数据库初始化 ,会中断退出脚本,所以放到最后安装 mysql_contor kaiji_start_web_sh } main # ubuntu20/21/22 一键部署 web 环境: wget eisc.cn/file/ubuntu/shell/server/web.sh ; chmod +x web.sh ; ./web.sh
 11   0  338天前
admin
783
#!/bin/bash # ubuntu 22/21/20/18/16/14 自动切换 apt 阿里云/清华/腾讯/华为/网易163 源; update 更新,自动部署可 kvm 虚拟化,安装google 浏览器;安装 mp4 播放器 # 执行脚本选择对应的 apt 源码,下面 aptubuntu22 为apt 源 内容修改写入到:/etc/apt/sources.list 然后执行 sudo apt update 进行更新 echo "当前需要输入当前用户的密码,需要执行 sudo 命令" ; sudo date aptupdateqinghua(){ # 清华 apt 源手动选择 ubuntu 版本链接:http://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ # 注意:定义变量的时候引号需要换行,否则原本的换行将被替换为空格 aptubuntu23=" # ubuntu23 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-security main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-security main restricted universe multiverse deb http://security.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-proposed main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-proposed main restricted universe multiverse " aptubuntu22=" # ubuntu22 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse " aptubuntu21=" # ubuntu21 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-updates main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-backports main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-security main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-proposed main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-proposed main restricted universe multiverse " aptubuntu20=" # ubuntu20 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse " aptubuntu18=" # ubuntu18 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse " aptubuntu16=" # ubuntu16 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse " aptubuntu14=" # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse " } ubuntu_ntpdate(){ # 更新时间 sudo apt install ntpdate -y sudo timedatectl set-timezone Asia/Shanghai sudo ntpdate -u cn.pool.ntp.org sudo apt-get --fix-broken install -y # 问题:Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution) } ubuntu_release_setApt(){ releaseApt=0; models=`cat /etc/os-release | grep -w NAME | awk -F"\"" '{print $2}'` version=`cat /etc/os-release | grep VERSION_ID | awk -F"\"" '{print $2}' | awk -F"." '{print $1}'` echo "当前机型为:$models 系统版本: $version " echo "select apt update: 1.qinghua 2.Alibaba 3.tencent 4.huawei 5.163 5.exit" ; read -p "select number : " readset case $readset in "1") echo "当前切换到清华源,较慢" ; aptupdateqinghua ;; "2") echo "当前切换到阿里云源" ; aptupdateqinghua ; releaseApt=1 ; destAptUrl="mirrors.aliyun.com" ;; "3") echo "当前切换到腾讯云源" ; aptupdateqinghua ; releaseApt=1 ; destAptUrl="mirrors.tencent.com" ;; "4") echo "当前切换到华为云源" ; aptupdateqinghua ; releaseApt=1 ; destAptUrl="repo.huaweicloud.com" ;; "5") echo "当前切换到网易163源" ; aptupdateqinghua ; releaseApt=1 ; destAptUrl="mirrors.163.com" ;; *) echo "我已经配置 apt 源。正在继续下面任务... " ;; esac case $version in "23") echo "$aptubuntu23" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu22 apt源 " ;; "22") echo "$aptubuntu22" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu22 apt源 " ;; "21") echo "$aptubuntu21" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu21 apt源 " ;; "20") echo "$aptubuntu20" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu20 apt源 " ;; "18") echo "$aptubuntu18" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu18 apt源 " ;; "16") echo "$aptubuntu16" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu16 apt源 " ;; "14") echo "$aptubuntu14" > /etc/apt/sources.list ; echo "当前机型: $models $version 已经写入 aptubuntu14 apt源 " ;; esac if [ $releaseApt = 1 ] then sudo sed -i "s/mirrors.tuna.tsinghua.edu.cn/$destAptUrl/g" /etc/apt/sources.list fi } sudo_install(){ if [ `id -un` != "root" ] then echo "当前不是 root 用户,需要检测 sudo 工具是否安装,并且 获取 sudo " a=`sudo apt list --installed | grep sudo | grep now` if [ ${#a} -lt 1 ] then echo " 当前检测到 您没有安装 sudo 超级权限工具,并且当前也不是 root 用户,没有权限更改apt 源,请切换到root 用户执行本shell 按照操作添加用户的sudo 权限" exit else echo "[ ok ] 当前用户 $USER 已经安装 sudo 工具,并且已经配置获得 sudo 超级权限,继续往下配置..." sudo touch /etc/apt/sources.list sudo chmod 777 -R /etc/apt/* if [ ! -e /etc/apt/sources.list.bak ] then sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak echo "备份文件 在: /etc/apt/sources.list.bak" else echo "已经存在备份文件:/etc/apt/sources.list.bak" fi echo "" > /etc/apt/sources.list ; ubuntu_release_setApt # 文件已经附加了权限,删除后文件权限为默认,而不为 777 。如果删除重写,记得重新附加权限 777 sudo rm -rf /var/lib/dpkg/updates/* # 解决 sudo dpkg --configure -a # to correct the problem ubuntu_ntpdate sudo apt update ; sudo apt update ; sudo apt upgrade -y ; sudo apt list --upgradable echo "切换 apt update 源,更新软件包,和 查看可升级软件包完成" fi else echo "[ok] 当前是 root 用户" if [ ! -e /etc/apt/sources.list.bak ] then cp /etc/apt/sources.list /etc/apt/sources.list.bak echo "备份文件 在: /etc/apt/sources.list.bak" else echo "已经存在备份文件:/etc/apt/sources.list.bak" fi sudo rm -rf /var/lib/dpkg/updates/* # 解决 sudo dpkg --configure -a # to correct the problem ubuntu_release_setApt ; ubuntu_ntpdate ; apt update ; apt install -y sudo if [ ! -e /etc/sudoers.d/stack ] then touch /etc/sudoers.d/stack fi echo "为其他用户添加sudo 权限,多个用户空格个开!" read -p "输入:" readuser userlist=( root $readuser) for i in ${userlist[*]} do catsudo=`cat /etc/sudoers.d/stack | grep $i` if [ ${#catsudo} -lt 27 ] then echo "$i ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack else echo "[ok] 已经添加过用户 $i 的 sudo 权限" fi if [ $i != root ] then echo "useradd $i Please set the password $i: " useradd -m -d /home/$i -s /bin/bash $i; passwd $i fi done sudo apt update ; sudo apt update ; sudo apt upgrade -y ; sudo apt list --upgradable echo "切换 apt update 源,更新软件包,和 查看可升级软件包完成" fi } install_kvm(){ installedkvm=` apt list --installed | grep virtinst` ; Length=${#installedkvm} if [ $Length -gt 1 ] then echo "kvm 已经安装。" else echo "正在安装kvm ... " sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager -y sudo systemctl is-active libvirtd # 验证安装,注意:qemu-kvm 更名为:qemu-system-x86 卸载软件命令:sudo apt autoremove namepackage echo "$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack # 授予当前用户sudo超级权限。 sudo usermod -aG libvirt $USER sudo usermod -aG kvm $USER # $USER 当前用户名,加入组,能够创建和管理虚拟机,否则无权限。然后注销重新登陆 fi } ubuntu_aptupdate(){ echo "select: 1.config ubuntu apt update 2.install kvm qemu 3 exit" read -p "input number: " selectRun case $selectRun in "1") sudo_install ;; "2") install_kvm ;; *) echo "已经跳过此步骤!" ;; esac } apt_install(){ echo "install google , qq , wecat, vscode ?" read -p "input: y/n ?: " ifapt if [ $ifapt = y ] then echo "[runing] install..." wget eisc.cn/file/ubuntu/shell/server/vscode.sh; sudo chmod +x vscode.sh ; ./vscode.sh wget eisc.cn/file/ubuntu/shell/server/weixin.sh; sudo chmod +x weixin.sh ; ./weixin.sh else echo "[ok] 取消安装必备软件! " fi } main(){ ubuntu_aptupdate apt_install } main # 一键部署:wget http://eisc.cn/file/ubuntu/shell/server/ubuntu_aptupdate.sh ; chmod +x ubuntu_aptupdate.sh; ./ubuntu_aptupdate.sh
 1   0  298天前
admin
1278
#!/bin/bash # todesk 远程桌面安装 cd $HOME ; echo "当前路径:`pwd` ; 请输入当前用户的密码: " ; sudo date a=`sudo dpkg -l | grep todesk` if [ "${#a}" -lt "123" ] then if [ ! -e todesk_4.0.0b_amd64.deb ] then wget https://dl.todesk.com/linux/todesk_4.0.0b_amd64.deb fi sudo dpkg -i todesk_4.0.0b_amd64.deb else echo "已经安装 todesk" fi id=`cat /opt/todesk/config/todeskd.conf | grep -E "id" | awk -F"=" '{print $2}' ` ; passwd=`cat /opt/todesk/config/todeskd.conf | grep -E "temppassword" | awk -F"=" '{print $2}' ` ; echo "windows 控制端下载地址:https://www.todesk.com/download.html?dt=4" echo "id 为: $id" echo "passwd 为: $passwd" echo "转明文密码为:" echo -n $passwd | base64 -d echo "" nano todesk.shsudo todesk ; sudo chmod +x todesk.sh ; ./todesk.sh#------------------  dns 检查 --------------------#ifconfig enp1s0sudo netplan apply sudo shutdown -r now 
 1   0  316天前
admin
828
#!/bin/bash # ubuntu vsftpd install userFile="/datadisk/eisc/ftp" # 配置用户的家目录 ftp_install(){ FtpPackageList=( vsftpd db-util ) for i in ${FtpPackageList[*]} do FtpPackage=`sudo apt list --installed | grep $i ` if [ ${#FtpPackage} -lt 10 ] then ./aptUpdate_ubuntu.sh # 更新切换apt 源 sudo dpkg --configure -a ; sudo apt --fix-broken install -y # 解决无法安装软件 sudo apt install $i -y else echo "[ok] $i 已经安装" fi done } ftp_home(){ sudo touch /etc/vsftpd.user_list # 解决 500 CreateUser=`ls -alh /var/ftp | awk -F" " 'NR==2{print $3}'` if [ "$CreateUser" == "ftpvload" ] then echo "[ok] ftp 用户已经创建!" else sudo mkdir -p /var/ftp # -p 自动创建父目录文件夹: sudo useradd vsftpd -M -s /sbin/nologin # 创建 vsftpd 用户: ,如果此目录不存在,则同时使用-m选项,可以创建主目录。 # -s Shell文件 指定用户的登录Shell。 sudo mkdir /etc/vsftpd/ ; sudo chmod 700 /etc/vsftpd sudo touch /etc/vsftpd.user_list sudo useradd ftpvload -d /var/ftp/ -s /sbin/nologin # -d 目录 指定用户主目录 sudo chown -R ftpvload.ftpvload /var/ftp/ # -R 目录拥有者ftpvload:ftpvload 其中 . 可以换成 fi } ftp_conf(){ # 修改ftp主配置文件 userConfig="/etc/vsftpd/vconf" file="/etc/vsftpd.conf" sudo chown -R root:root $userConfig # 重点 ftp 子用户配置目录必须是 root 用户所有; 否则:500 OOPS: config file not owned by correct user, or not a file if [ ! -e $file.bak ] then sudo cp $file $file.bak ; sudo chmod 777 $file fi sudo chmod 777 $file echo " pasv_promiscuous=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=NO anon_mkdir_write_enable=NO dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES chown_uploads=NO xferlog_file=/var/log/vsftpd.log xferlog_std_format=YES async_abor_enable=no ascii_upload_enable=YES ascii_download_enable=YES ftpd_banner=Welcome to FTP Server chroot_local_user=YES ls_recurse_enable=NO listen=YES hide_ids=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=NO guest_enable=YES guest_username=ftpvload virtual_use_local_privs=YES user_config_dir=$userConfig pasv_enable=YES pasv_min_port=63000 pasv_max_port=65535 " > $file } ftp_user_so(){ # 开启虚拟用户功能 pamfile="/etc/pam.d/vsftpd" sudo cp $pamfile $pamfile.bak ; sudo chmod 777 $pamfile echo "注意: 重要子用户配置文件:$pamfile 只需要保留两行, 否则添加子用户无法登陆 auth sufficient /usr/lib/x86_64-linux-gnu/security/pam_userdb.so db=/etc/vsftpd/virtusers account sufficient /usr/lib/x86_64-linux-gnu/security/pam_userdb.so db=/etc/vsftpd/virtusers 当前库文件路径:" sudo find /usr/lib/ -name pam_userdb.so | grep -v "snap" buff=`cat $pamfile | grep /usr/lib/x86_64-linux-gnu/security/pam_userdb.so ` ; buffLength=${#buff} if [ $buffLength -lt 100 ] then if [ ! -e $pamfile.bak ] then sudo cp $pamfile $pamfile.bak fi sudo chmod 777 $pamfile sudo sed -i "s/^/#/g" $pamfile # 在开头添加 # 号全部注释 # sudo find / -name pam_userdb.so | grep lib | grep -v snap sudo echo "auth sufficient /usr/lib/x86_64-linux-gnu/security/pam_userdb.so db=/etc/vsftpd/virtusers account sufficient /usr/lib/x86_64-linux-gnu/security/pam_userdb.so db=/etc/vsftpd/virtusers" > $pamfile userfile="/etc/vsftpd" sudo touch /var/log/vsftpd.log sudo chown vsftpd.vsftpd /var/log/vsftpd.log sudo mkdir $userfile ; sudo chmod 777 $userfile ; sudo mkdir -p $userfile/vconf/ else pamfile="/etc/pam.d/vsftpd" echo "[ok] vsftpd 用户新增配置功能已经设置,设置文件: $pamfile" fi } ftp_user_add(){ ftp_conf ; userConfig=$userConfig # 执行函数,获取ftp 子用户配置目录 sudo touch /etc/vsftpd/vsftpd.user_list sudo chmod 777 -R /etc/vsftpd echo "" echo "创建 ftp 登陆子用户,请输入 ftp 用户和密码,空格个开: " read -p "输入:" userRead buff=($userRead) ; echo "[ok] 正在创建信息为: ${buff[*]} 家目录自动分配到:$userFile/${buff[0]}" if [ ${#buff[*]} == 2 ] then if [ ! -e $userFile/${buff[0]} ] then sudo mkdir $userFile/${buff[0]} sudo chown -R ftpvload.ftpvload $userFile/${buff[0]} else echo "[error] 用户存在,请重新输入! 当前存在的路径:$userFile/${buff[0]} " exit fi else echo "[error] 输入的参数错误,需要输入两个参数,用户 和 密码,如: eisc 123456" exit fi sudo touch /etc/vsftpd/virtusers sudo chmod 777 /etc/vsftpd/virtusers echo -e "${buff[0]}\n${buff[1]}" >> /etc/vsftpd/virtusers sudo chown -R $USER:$USER /etc/vsftpd/virtusers sudo db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db # 使用库,对新增用户生效 sudo chmod 777 $userConfig sudo mkdir -p $userFile/${buff[0]} ; sudo chmod 777 $userFile/${buff[0]} echo " # 允许可写 allow_writeable_chroot=YES #设定支持ASCII模式的上传和下载功能 ascii_upload_enable=YES ascii_download_enable=YES local_root=$userFile/${buff[0]} #指定虚拟用户的具体主路径 anonymous_enable=NO #设定不允许匿名用户访问 write_enable=YES #设定允许写操作 local_umask=022 #设定上传文件权限掩码 anon_upload_enable=NO #设定不允许匿名用户上传 anon_mkdir_write_enable=NO #设定不允许匿名用户建立目录 idle_session_timeout=600 #设定空闲连接超时时间 data_connection_timeout=120 #设定单次连续传输最大时间 max_clients=10 #设定并发客户端访问个数 max_per_ip=5 #设定单个客户端的最大线程数,这个配置主要来照顾Flashget、迅雷等多线程下载软件 #local_max_rate=50000 #设定该用户的最大传输速率,单位b/s" >> $userConfig/${buff[0]} protlist=( "20:21" "63000:65535" ) for i in ${protlist[*]} do onport=`sudo iptables -L -n --line-numbers | grep ACCEPT | grep -v Chain | grep $i` ; onportLength=${#onport} if [ $onportLength -lt 10 ] then sudo iptables -A INPUT -p tcp --dport $i -j ACCEPT echo "[ok] 正在添加 ftp 主动 和 被动 模式端口:$i " else echo "[ok] 已经添加过端口 $i " fi done sudo iptables -L -n --line-numbers | grep ACCEPT sudo systemctl restart vsftpd } ftp_drop(){ read -p "清输入用户:" readu sudo rm -rf /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db /datadisk/eisc/ftp/* /etc/vsftpd/vconf/* } main(){ ftp_install ; ftp_home ; ftp_conf ; ftp_user_so ; ftp_user_add sudo chown -R root:root $userConfig # 子用户配置文件目录,需要归 root 用户所有 } main # sudo apt install -y lftp # lftp 192.168.122.1 -u rv11xx,000000 # 登陆ftp -u 跟上账户和密码 # wget -nH -m ftp://eisc:000000@eisc.cn/* # 下载ftp 根目录下的所有文件,并且检查本地是否为最新,不是就覆盖 # http://eisc.cn/index.php?c=read&id=430&page=1ubuntu20/21/22  一键部署 vsftpd 服务    wget eisc.cn/file/ubuntu/shell/server/vsftpd.sh ; chmod +x vsftpd.sh ; ./vsftpd.sh  
 2   1  323天前
admin
1062
# 创建共享内存, w.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/shm.h> // 共享内存函数 #include <string.h> #include <signal.h> #include <errno.h> struct Msg { int flag; // flag 的数值 0为读,1为写 char content[104]; }; // 声明结构体 Msg 里面的 变量定义类型, 下次给变量赋值,直接引用当前结构体赋值,不用定义类型 int shmid; void *pshm; void Handle(int s) { // 定义一个无类型函数,属性是 s 由其他函数传值过来, if (s == 2) // 判断s 的值 绝对等于2 { shmdt(pshm); // 将共享内存地址抽离 shmctl(shmid, IPC_RMID, 0); // 删除共享内存 exit(0); } } // 共享内存 4 函数定义; // shmget() 创建共享内存,返回内存 shmid; 参数: 1.起名 2.内存地址大小 3.为0 是读取内存。创建内存要 填写权限 。 // 共享内存参数: IPC_CREAT 区别 IPC_EXCL 都是不存在就创建共享内存,区别 creat 是存在共享就打开, excl是存在就产生错误 // shmat() 返回内存空间地址并挂载, 1. 挂载到内存上的id 2.填0/null 自动找位置,3.标志位 // shmdt 删除挂载 参数:shmat 返回值。 成功返回0,失败返回-1 // shmctrl 删除内存 int gongxiang() { signal(2, Handle); // signal.h是C标准函数库中的信号处理部分 ,按ctrl+c键退出时会处理这个消息,进行共享内存卸载、删除操作,最后exit(0)退出程序 key_t key = ftok(".", 0x1); // ftok 生成key数值,参数1 路径,参数2数字 1-255 之间,数字会加在key数值的前面 printf(" \n key 获取的数值:%x \n", key); // x 以16进制打印。 d 十进制; o 八进制 shmid = shmget(key, 100, IPC_CREAT | IPC_EXCL | 0666); // key 为 ftok 的返回值 ; 字节大小 100 ; shmflg:文件权限 // 创建共享内存,成功返回共享内存的ID,出错返回-1 // IPC_CREAT | IPC_EXCL则可以创建一个新的,唯一的共享内存,如果共享内存已存在,返回一个错误。*/ pshm = shmat(shmid, 0, 0); // shmat 附加好的内存地址,出错返回-1 // 共享内存标识符 ID 号; 映射到地址; 0 可读写, SHM_RDONLY 只读 if (*(int *)pshm == -1) { // 查看挂接是否成功如果出错返回-1,报错 printf("shmat error!\n"); exit(0); } memset(pshm, 0, 100); //初始化: 替换 0 的位置 为 100 struct Msg *msg = (struct Msg *)pshm; msg->flag = 1; // 定义msg 结构体中的变量 flag 成员的数值 为1 是写入 while (1) { if (msg->flag == 1) { //当为1时写消息,此时读文件中不能操作此共享内存 printf("请输入内容至共享内存:"); scanf("%s", msg->content); msg->flag = 0; //当写消息后flag置为0,让读文件开始执行读操作,此时写文件不能进行写操作 } else { sleep(1); } } return 0; } int main(){ gongxiang(); } // ftok 说明:https://wenku.baidu.com/view/eac76f2e5b1b6bd97f192279168884868762b804.html?_wkts_=1667455715129&bdQuery=c+ftok+%E5%87%BD%E6%95%B0 // 参考案例:https://blog.csdn.net/arv002/article/details/109830080 // 共享内存函数说明:https://blog.csdn.net/weixin_35710880/article/details/117180126 # 读取共享内存 //read.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/shm.h> #include <string.h> #include <signal.h> // 共享内存 4 函数定义; // shmget() 创建共享内存,返回内存 shmid; 参数: 1.起名 2.内存地址大小 3.为0 是读取内存。创建内存要 填写权限 。 // 共享内存参数: IPC_CREAT 区别 IPC_EXCL 都是不存在就创建共享内存,区别 creat 是存在共享就打开, excl是存在就产生错误 // shmat() 返回内存空间地址并挂载, 1. 挂载到内存上的id 2.填0/null 自动找位置,3.标志位 // shmdt 删除挂载 参数:shmat 返回值。 成功返回0,失败返回-1 // shmctrl 删除内存 struct Msg { int flag; char content[104]; }; // 定义结构体,下次引用不用定义变量类型 int main() { key_t key = ftok(".", 2); int shmid = shmget(key, 0, 0); // 参数3 为0 是读取共享内存 void *pshm = shmat(shmid, 0, 0); //挂接操作,成功返回指向共享存储段的指针,出错返回-1 if (*(int *)pshm == -1) { //查看挂接是否成功如果出错返回-1,报错 printf("shmat error!\n"); exit(0); } struct Msg * msg = (struct Msg *)pshm; while (1) { if (msg->flag == 0) { //当为0时读消息,此时写文件中不能操作此共享内存 printf("从共享内存收到 : %s\n", msg->content); msg->flag = 1; } else { sleep(1); } } return 0; }
 34   0  333天前
admin
807
#!/bin/bash scp_txt(){ sshuser=root sship=eisc.cn sshdata=/root/*.txt scpdata=/datadisk/download/linshifile/ download="$sshuser@$sship:$sshdata $scpdata" } scp_img(){ sshuser=root sship=eisc.cn sshdata=/*.jpg scpdata=/datadisk/download/linshifile/ download="$sshuser@$sship:$sshdata $scpdata" } sshscp(){ passwd='123456' # 定义服务器密码 set timeout 20 /usr/bin/expect << JIEsu spawn scp $download expect { "*yes/no" { send "yes\r"; exp_continue } "*password:" { send "$passwd\r" } } expect eof JIEsu } main(){ echo "下载图片 1 下载日志 2 图片日志都下载 3 " read -p "请选择:" select case $slect in "1") scp_img # 执行函数,需要下载什么内容 ;; "2") scp_txt ;; "3") scp_img ; sshscp scp_txt ; sshscp ;; esac } main
 4   0  335天前
admin
1336
#!/bin/bashread -p "套餐一:写字+看书套餐二:玩游戏+写程序代码强哥请选择您的套餐:" taocan a1="套餐一:写字+看书"b1="套餐二:玩游戏+写程序代码"site=$taocan # 给变量赋值case "$site" in # case  [ke?s] 情况;处理变量 $site in 是下面的值   "1") echo "===========================您选择了:$a1" # 值为r 就打印字符串   ;; # 字句结束,往下匹配   "2") echo "===========================您选择了:$b1"   ;;   *) echo "===========================输入错误请重新输入!"   ;;esac
 10   0  1236天前
admin
1461
 expect  [ɪkˈspɛkt] 预期;自动化插件与linux交互命令 spawn启动指定进程---expect获取指定关键字---send向指定程序发送指定字符---执行完成退出.1.   expect 常用命令spawn                交互程序开始后面跟命令或者指定程序expect              获取匹配信息匹配成功则执行expect后面的程序动作send exp_send        用于发送指定的字符串信息exp_continue        在expect中多次匹配就需要用到send_user            用来打印输出 相当于shell中的echoexit                退出expect脚本eof                  expect执行结束 退出set                  定义变量puts                输出变量set timeout          设置超时时间interact      允许用户交互2.   ssh登录远程主机并且执行命令#!/bin/bashyum install -y expect                # 安装交互工具包set timeout 30                # 设置匹配字符的等待时间/usr/bin/expect << EOF                # 执行交互程序,通过EOF 打包给程序spawn ssh root@eisc.cn                # 进行远程连接服务器expect "password:"                # 匹配密码提示send "000000\r"                # 输入密码并换行expect "#"                # 登录成功后匹配符号 #send "echo '登录成功' \r"                # 执行打印命令并换行expect eof                # 匹配结束# exit                # 退出EOF                # 总打包结束3.   ssh远程登录主机执行命令,在shell脚本中执行expect命令,执行方法sh 2.sh、bash 2.sh 或./2.sh都可以执行#!/bin/bashpasswd='tytyt123456' # 定义一个变量为字符串 # -EOF 输入多行命令    # 调用命令的路径:/usr/bin/expect <<-EOF /usr/bin/expect <<-EOF spawn ssh saneri@192.168.56.103 df -Th # 执行两个命令 # 定义一个函数,名字为: expectexpect { "*yes/no" { send "yes\r"; exp_continue }"*password:" { send "$passwd\r" }}expect eof # 将函数名字放出来执行,并结束匹配EOF #  总结束4.   expect执行多条命令#!/usr/bin/expect -fset timeout 10spawn sudo su - root # 切换用户expect "*password*" # 匹配包含字符password后send "123456\r" # 输入123456 并 /r 确定  也可以 \n  换行确定 # 新增用户命令: useradd eiscexpect "#*"send "ls\r"send "exit\r"expect eof5.   创建ssh key,将id_rsa和id_rsa.pub文件分发到各台主机上面。1.创建主机配置文件[root@localhost script]# cat host 192.168.1.10 root 123456192.168.1.20 root 123456192.168.1.30 root 123456[root@localhost script]# lscopykey.sh  hosts2.编写copykey.sh脚本,自动生成密钥并分发key.[root@localhost script]# vim copykey.sh#!/bin/bash# 判断id_rsa密钥文件是否存在if [ ! -f ~/.ssh/id_rsa ];then ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsaelse echo "id_rsa has created ..."fi#分发到各个节点,这里分发到host文件中的主机中.while read line  do    user=`echo $line | cut -d " " -f 2`    ip=`echo $line | cut -d " " -f 1`    passwd=`echo $line | cut -d " " -f 3`        expect <<EOF      set timeout 10      spawn ssh-copy-id $user@$ip      expect {        "yes/no" { send "yes\n";exp_continue }        "password" { send "$passwd\n" }      }     expect "password" { send "$passwd\n" }EOF  done <  hosts6.    shell调用expect执行多行命令.#!/bin/bash ip=eisc.cnuser=rootpassword=www.eisc.cnexpect <<EOF      set timeout 10     spawn ssh $user@$ip     expect {  # 多个匹配用大括号来省略单词expect        "yes/no" { send "yes\n";exp_continue }         "password" { send "$password\n" }    }     expect "]#" { send "useradd hehe\n" }  # 匹配符号   ]#    为登陆后的界面    expect "]#" { send "touch /tmp/test.txt\n" }     expect "]#" { send "exit\n" } expect eof  EOF   #./ssh5.sh 192.168.1.10 root 123456
 1   0  1220天前
admin
914
# 选择使用的通道:echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list# Stableecho "deb https://download.sublimetext.com/ apt/dev/" | sudo tee /etc/apt/sources.list.d/sublime-text.list# Dev sudo apt-get update# 更新提示:由于没有公钥,无法验证下列签名: NO_PUBKEY F57D4F59BD3DF454sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com  F75D4F59BD3DF454# 添加公钥 sudo apt-get install sublime-text# 更新apt源 和 安装文本编辑工具#------------- 安装方案2 --------------------#ubuntu 文本编辑工具  Sublime Text 下载地址  deb :  https://www.sublimetext.com/3    https://download.sublimetext.com/sublime-text_build-3211_amd64.deb dpkg -i sublime-text_build-3211_amd64.deb# 安装subl  1.txt# 使用方法: 自动弹出编辑框
 25   0  543天前
admin
941
#!/bin/bashapt install ntfs-3g -y                         # ubuntu/debian 安装 ntfs 分区挂载工具yum install -y ntfs-3g                       # centos 安装 ntfs 工具    mkdir -p /myfolder#  创建挂载目录    mount -t ntfs-3g /dev/sda1 /myfolder# 将 磁盘:/dev/sda1    挂载 到目标据经:/myfolderfor((i=1; i<=6; i++))  do    mkdir -p /myfolder/disk/$i#  创建挂载目录    mount -t ntfs-3g /dev/sda$i /myfolder/disk/$i # 将 磁盘:/dev/sda1    其中$i 是数数,有6分区,顺序挂载 到目标据经:/myfolder/disk/1   done
 4   0  535天前
admin
938
#---------- 安装桌面和远程桌面 ------#apt-get install xrdp  ubuntu-desktop# xrdp 是 windos 远程ubuntusudo apt install -y openssh-server# ssh登录#------ 中文输入法 -------#sudo apt install fcitx-binsudo apt-get install fcitx-table#  fcitx 框架可能对其他部署环境有冲突,可以不安装,选择ubuntu 自带的Chinese(ping yin)# 安装Fcitx输入框架,相关的依赖库和框架都会自动安装上下载搜狗输入法intel cpu选择x86:https://pinyin.sogou.com/linux/?r=pinyinsudo dpkg -i sougou.deb设置为中文:ubuntu 右上角 电源右边的 三角形图标 【设置/settings】 ---> Region & Languge ---> input source ---> 点击 + 号 ---> 点击 Chinese ---> Chinese (intelligent Pinyin)# --------- 安装中文语言 ----------#设置为中文:ubuntu 右上角 电源右边的 三角形图标 【设置/settings】 ---> Region & Languge ---> Manage installed Languwges ---> 点击进入:第一个方框:运用到整个系统第二个方框:勾选需要安装的语言,没有勾选的会被删除第三方方框:键盘输入系统:选择 Ibus如果输入法无法正常切换: apt remove -y ubuntu-desktop && apt install -y ubuntu-desktop# 使用root 用户重新安装桌面
 1   1  627天前
admin
926
   find . -type f -name "*" | xargs grep "1" -name 支持 通配符, 我的目录下只有三个文件, 所以也可以不带
 1   0  538天前
admin
950
l #  安装c 语言环境sudo apt-get install g++             # 安装C语言环境 ,或者 #  apt install -y gcc-arm-linux-gnueabihf gcc gcc-aarch64-linux-gnu mtools lib32gcc-7-dev g++-7 libstdc++-7-devgcc -v                                           # 验证安装的 C 语言是否成功vi eisc.c                                         # 编写C语言程序#include<stdio.h>int main(){    int num;     printf("输入一个数字 : ");    scanf("%d",&num);     (num%2==0)?printf("偶数"):printf("奇数");}gcc eisc.c  -o eisc.o                                     # 编译C语言为输出后的 eisc.o 文件./eisc.o                                                         # 执行编译后的C语言 C 语言基础:http://c.biancheng.net/c/
 8   0  543天前
admin
1117
l #    ubuntu 安装 kvmsudo apt-get update# 更新yum sudo apt-get upgrade# 更新内核软件# ubuntu清华 apt 源:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/rebootsudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager -y# 以普通用户安装kvmsudo systemctl is-active libvirtd# 验证echo "eisc ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack   # 切换到root用户 授予eisc用户sudo超级权限。如果是其他用户,可以将eisc改为实际用户sudo usermod -aG libvirt $USERsudo usermod -aG kvm $USER# $USER 当前用户名,加入组,能够创建和管理虚拟机,否则无权限。然后注销重新登陆#--------- 网络设置 -----------#brctl show                                          # 列出网桥和接口,“ virbr0”网桥未添加任何物理接口。“ virbr0-nic”是虚拟设备,没有流量通过该虚拟设备。该设备的唯一目的是避免更改“ virbr0”网桥的MAC地址#---------- 安装桌面和远程桌面 ------#apt-get install xrdp  ubuntu-desktopapt-get install dconf-editorsudo apt install -y openssh-server# ssh登录 #    相关说明qemu-kvm -为KVM管理程序提供硬件仿真的软件。libvirt-daemon-system -用于将libvirt守护程序作为系统服务运行的配置文件。libvirt-clients -用于管理虚拟化平台的软件。bridge-utils -一组用于配置以太网桥的命令行工具。virtinst -一组用于创建虚拟机的命令行工具。virt-manager -易于使用的GUI界面和支持命令行工具,用于通过libvirt管理虚拟
 6   0  547天前
admin
1621
1.  ubuntu 配置静态 ip ;   2. 修改为 动态ip  ;  3. ubuntu20 阿里云 apt 源 ;  4. ubuntu20 清华 apt 源。 apt update 与 apt upgrade 区别:只查看更新,和 更新软件包    #    修改为静态指定ipip a                           # 通过ip a 查看网卡名字,然后再下面配置中将 eth0 改为正确的网卡名【ubuntu20 版本配置】nano /etc/netplan/01-network-manager-all.yamlnetwork: ethernets: enp1s0: addresses: [192.168.122.80/24] dhcp4: no optional: true gateway4: 192.168.122.1 nameservers: addresses: [192.168.122.1,223.5.5.5] version: 2 renderer: NetworkManager【ubuntu22 版本配置】解决报错: Ubuntu 22.10 netplan `gateway4` has been deprecatednetwork: ethernets: enp1s0: addresses: - 192.168.122.80/24 dhcp4: false gateway4: 192.168.122.1 nameservers: addresses: - 192.168.122.1 search: [] version: 2   # renderer 可不加,部分服务器加上这个参数网卡无法启动  # 223.5.5.5  网络速度慢只有1M/s 速度,建议dns 修改为网关一个ipsudo netplan apply                       # 生效配置 #    修改动态获取ipvi /etc/netplan/01-network-manager-all.yaml network:  ethernets:    eth0:      dhcp4: true  version: 2sudo netplan apply                       # 生效配置 #    ubuntu20 阿里云 apt 源阿里云源 选择系统版本, 镜像仓库:https://developer.aliyun.com/mirror/vi /etc/apt/sources.listdeb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse #    ubuntu20 清华 apt 源清华apt 源选择版本:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/vi /etc/apt/sources.list# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse# 预发布软件源,不建议启用# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverseapt update        # 命令更新软件源(只检查不更新)apt upgrade      # 更新已安装的软件包
 1   0  547天前
admin
1112
debian 安装docker   网段 仓库地址, 拉取 nacos #    安装dockerapt updateapt install ca-certificates curl software-properties-common gnupg2 curl -y# 安装docker 依赖echo "deb [arch=amd64] http://mirrors.ustc.edu.cn/docker-ce/linux/debian buster stable" >> /etc/apt/sources.list#  docker 的源 ,不能有空格curl -fsSL http://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | apt-key add -# 添加gpg密匙apt-get install docker-ce# 安装dockersystemctl start docker# 启动docker#-------- docker 修改网段 -----#echo "{"registry-mirrors": ["https://hub-mirror.c.163.com"],"bip": "111.111.111.1/24"}" >  /etc/docker/daemon.jsonsystemctl daemon-reload ; systemctl restart docker      # 重启docker# bip 指定网段为:网段掩码位,如 24 错误将会导致docker无法重启  #    拉取,并配置nacosdocker拉取nacos镜像 docker search nacos                               # 搜索nacos源docker pull nacos/nacos-server            # 拉取nacos镜像mkdir -p /mydata/nacos/logs/# 新建logs目录mkdir -p /mydata/nacos/init.d/docker run --name nacos -p 8848:8848 \--privileged=true \--restart=always \-e JVM_XMS=256m \-e JVM_XMX=256m \-e MODE=standalone \-e PREFER_HOST_MODE=hostname \-v /mydata/nacos/logs:/home/nacos/logs \-d nacos/nacos-serverdebian安装docker:https://www.cnblogs.com/surplus/p/11367556.htmldocker 拉取nacos:https://www.cnblogs.com/leasing/p/15410095.html安装 nacos 集群:https://nacos.io/zh-cn/docs/cluster-mode-quick-start.htmlnacos 集群配置:https://blog.51cto.com/u_10950710/3157514nacos 默认登录信息:http://tx.kbash.cn:8848/nacos/#/login账户/密码:nacos/nacos# nacos 的数据库是集成的,不需要改数据库
 1   0  574天前
admin
1216
date +%Y-%m-%d-%H:%M:%S                      # 获取当前年月日时分秒date -d "-1 day"  +%Y-%m-%d                       # 获取时间并再当前时间减去一天,格式化时间为 年月日date -d '2 days ago'                                         # 显示2天前的时间date -d '3 month 1 day'                                  # 显示3月零1天以后的时间date -d '25 Dec' +%j                                       # 显示12月25日在当年的哪一天date -d '30 second ago'                                  # 显示30秒前的时间date -d "-3 month"                                        # 前三个月date -d "+3 year"                                           # 三年后date -d `date +%y%m01`                               # 本月第一天#--------------------- 其他说明 -----------------------#%%  一个文字的 %  %a  当前locale 的星期名缩写(例如: 日,代表星期日)  %A  当前locale 的星期名全称 (如:星期日)  %b  当前locale 的月名缩写 (如:一,代表一月)  %B  当前locale 的月名全称 (如:一月)  %c  当前locale 的日期和时间 (如:2005年3月3日 星期四 23:05:25)  %C  世纪;比如 %Y,通常为省略当前年份的后两位数字(例如:20)  %d  按月计的日期(例如:01)  %D  按月计的日期;等于%m/%d/%y  %e  按月计的日期,添加空格,等于%_d  %F  完整日期格式,等价于 %Y-%m-%d  %g  ISO-8601 格式年份的最后两位 (参见%G)  %G  ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用  %h  等于%b  %H  小时(00-23)  %I  小时(00-12)  %j  按年计的日期(001-366)  %k   hour, space padded ( 0..23); same as %_H  %l   hour, space padded ( 1..12); same as %_I  %m   month (01..12)  %M   minute (00..59)  %n  换行  %N  纳秒(000000000-999999999)  %p  当前locale 下的"上午"或者"下午",未知时输出为空  %P  与%p 类似,但是输出小写字母  %r  当前locale 下的 12 小时时钟时间 (如:11:11:04 下午)  %R  24 小时时间的时和分,等价于 %H:%M  %s  自UTC 时间 1970-01-01 00:00:00 以来所经过的秒数  %S  秒(00-60)  %t  输出制表符 Tab  %T  时间,等于%H:%M:%S  %u  星期,1 代表星期一  %U  一年中的第几周,以周日为每星期第一天(00-53)  %V  ISO-8601 格式规范下的一年中第几周,以周一为每星期第一天(01-53)  %w  一星期中的第几日(0-6),0 代表周一  %W  一年中的第几周,以周一为每星期第一天(00-53)  %x  当前locale 下的日期描述 (如:12/31/99)  %X  当前locale 下的时间描述 (如:23:13:48)  %y  年份最后两位数位 (00-99)  %Y  年份  %z +hhmm        数字时区(例如,-0400)  %:z +hh:mm      数字时区(例如,-04:00)  %::z +hh:mm:ss  数字时区(例如,-04:00:00)  %:::z           数字时区带有必要的精度 (例如,-04,+05:30)  %Z          按字母表排序的时区缩写 (例如,EDT)
 1   0  564天前
admin
897
 java 进程运行总是中断 502  cat /etc/security/limits.d/20-nproc.conf *          soft    nproc     4096root       soft    nproc     unlimited# 查看root 用户的进程是最大,但是 * 号,所有用户的进程数 为 4096   可以修改为 60000 ,然后重启服务器
 1   0  571天前
admin
998
nginx 自动ssl证书配置 #    1. 安装ssl 证书软件yum install -y snapdapt install snapd# 1.安装snapd yum reinstall -y snapd# 重新安装 snapd,确保您的 snapd 版本是最新的systemctl enable --now snapd.socket# 安装后,需要启用管理主 snap 通信套接字的systemd单元snap install core;# 安装核心如果报错请检查第一步snap refresh core   # 刷新核心 snap install --classic certbot# 安装证书机器人# sudo apt-get remove certbot、sudo dnf remove certbot或sudo yum remove certbot。# 如果您使用apt、dnf或yum等操作系统包管理器安装了任何 Certbot 包 ,则应在安装 Certbot snap 之前将其删除,以确保在运行命令 certbot 时使用的是 snap,而不是从您的操作系统包安装经理。 ln -s /var/lib/snapd/snap /snap# 软连接(快捷方式)已经安装的软件 snap 到 要求的路径snap :经典限制要求在/snap或symlink下使用快照snap install --classic certbot# 安装证书机器人ln -s /snap/bin/certbot /usr/bin/certbot# 将证书机器人安装目录创建快捷方式到 运行目录  /usr/bin/certbot  (软连接)# 删除快捷方式,删除软连接  rm -rf /usr/bin/certbot #    2. ubuntu 证书#!/bin/bash # 自动申请ssl 证书 InstallSnapd() { sudo apt install snapd -y sudo systemctl enable --now snapd.socket sudo snap install core sudo snap refresh core sudo snap install --classic certbot sudo ln -s /var/lib/snapd/snap /snap sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot } RequestSSL() { certbot certonly --nginx # 只获取证书 }  #    2. 申请ssl 证书# certbot --nginx# 自动配置nginx ssl 证书,会修改nginx 配置文件,输入电子邮箱,后回车确认# 运行此命令以获取证书并让 Certbot 自动编辑您的 Nginx 配置以提供服务,只需一步即可打开 HTTPS 访问certbot certonly --nginx# 我们选择只获得nginx 证书,手动配置,将来源的ssl 证书删除,然后将自动下载的ssl 创建软链接(快捷方式)到原来的ssl 文件# 1: Keep the existing certificate for now# 暂时保留现有证书# 2: Renew & replace the certificate (may be subject to CA rate limits)# 更新和更换证书(可能受CA费率限制)  2# agree in order to register with the ACME server. Do you agree?# 同意在ACME服务器上注册。你同意吗?  y# Would you be willing, once your first certificate is successfully issued, toshare your email address with the Electronic Frontier Foundation,# 一旦您的第一份证书成功颁发,您是否愿意分享你的电子邮件地址与电子前沿基金会,成立Let's Encrypt项目的合作伙伴和机器人  no# Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel):# 选择以逗号和/或空格分隔的适当数字,或保留输入 空白选择显示的所有选项(输入“c”取消):# Successfully received certificate.# Certificate is saved at: /etc/letsencrypt/live/www.eisc.cn/fullchain.pem# Key is saved at:         /etc/letsencrypt/live/www.eisc.cn/privkey.pem# 证书的位置如上图,自动修改nginx 子站点的 ssl 路径,每三个月自动更新ssl # 由于是链接的国外  R3 证书颁发机构,可能存在失败的情况,需要重试 rm -rf /eisc/www/ssl/eisc/eisc.pemrm -rf /eisc/www/ssl/eisc/eisc.key# 删除原有ssl 证书文件ln -s /etc/letsencrypt/live/www.eisc.cn/fullchain.pem /eisc/www/ssl/eisc/eisc.pemln -s /etc/letsencrypt/live/www.eisc.cn/privkey.pem /eisc/www/ssl/eisc/eisc.keynginx -s reload# 重载nginx 配置文件教程来源:https://www.cnblogs.com/hushuning/p/14842251.html #    查看 nginx 配置信息server{listen 443 ssl;server_name www.eisc.cn eisc.cn;    ssl_certificate /etc/letsencrypt/live/eisc.cn/fullchain.pem; # managed by Certbot    ssl_certificate_key /etc/letsencrypt/live/eisc.cn/privkey.pem; # managed by Certbot     #ssl on;    ssl_session_timeout 5m;    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;    ssl_prefer_server_ciphers on;location / {proxy_pass https://eisc.cn;index index.php index.html;#------------- 可见ip ------------#     proxy_set_header Host $host;     proxy_set_header X-Real-IP $remote_addr;     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}server{    if ($host = eisc.cn) {        return 301 https://$host$request_uri;    } # managed by Certbot    if ($host = www.eisc.cn) {        return 301 https://$host$request_uri;    } # managed by Certbotlisten 80;server_name www.eisc.cn eisc.cn;    return 404; # managed by Certbot
 1   0  576天前
admin
984
yum install nginx-mod-stream -y           # 安装动态模块ll /usr/lib64/nginx/modules                    # 查看动态模块文件vi /etc/nginx/nginx.conf                          # 设置配置文件重点:需要注释掉动态模块冲突引用:# include /usr/share/nginx/modules/*.conf;# 添加配置:nginx 主配置文件最外层添加,  在 nginx 的 http 板块外面添加,不能写到首行load_module /usr/lib64/nginx/modules/ngx_stream_module.so;include /www/www/tcp/*.conf;# 设置动态模块的配置文件路径 在 nginx 的 http 板块外面添加#------------------------- tcp 转发 ---------------------------#vi /www/www/tcp/8000.conf               # 编辑配置文件stream {    upstream bt { server 10.111.111.2:8888;  }    # 设置函数 tcp 转发名称:bt     # 转发目的地端口:10.111.111.2:8888;    server { listen       8000;  server_name  eisc.cn; proxy_pass   bt; }}    # web 配置
 1   0  629天前
admin
979
 #--- 代理服务器(外层nginx) ---#nginx 子站点配置文件: /www/www/wwwconf/www.conf#分站子站转发配置,再server 板块的 location 方法里面server{listen 80;server_name work.eisc.cn;location / {     proxy_pass http://work.eisc.cn;     #--- 将ip 记录下来,传递给后端服务器 ---#     proxy_set_header Host $host;     proxy_set_header X-Real-IP $remote_addr;     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  }}nginx -s reload                          # nginx 配置生效,或者重启nginx #---  web 服务器(后端 nginx)---#nginx  主配置文件,非子站点:# 再 http 板块:案例下面位置处:        fastcgi_connect_timeout 300;        fastcgi_send_timeout 300;        fastcgi_read_timeout 300;        fastcgi_buffer_size 64k;        fastcgi_buffers 4 64k;        fastcgi_busy_buffers_size 128k;        fastcgi_temp_file_write_size 256k;        fastcgi_intercept_errors on;#--------- 配置可见ip ---------# set_real_ip_from 10.111.111.1; real_ip_header X-Forwarded-For;# 填写实际的内网请求来源 ip # 作用: 将内网ip 进行替换成客户端实际 ip#------------------------------# #---  nginx 主配置文件案例 ---#user  www www;worker_processes auto;error_log  /www/wwwlogs/nginx_error.log  crit;pid        /www/server/nginx/logs/nginx.pid;worker_rlimit_nofile 51200;events    {        use epoll;        worker_connections 51200;        multi_accept on;    }http    {        include       mime.types;                #include luawaf.conf;                include proxy.conf;        default_type  application/octet-stream;        server_names_hash_bucket_size 512;        client_header_buffer_size 32k;        large_client_header_buffers 4 32k;        client_max_body_size 50m;        sendfile   on;        tcp_nopush on;        keepalive_timeout 60;        tcp_nodelay on;        fastcgi_connect_timeout 300;        fastcgi_send_timeout 300;        fastcgi_read_timeout 300;        fastcgi_buffer_size 64k;        fastcgi_buffers 4 64k;        fastcgi_busy_buffers_size 128k;        fastcgi_temp_file_write_size 256k;        fastcgi_intercept_errors on;        #--------- 配置可见ip ---------# set_real_ip_from 10.111.111.1; real_ip_header X-Forwarded-For;#---------------  开启gzip 压缩  ---------------#        gzip on;        gzip_min_length  1k;        gzip_buffers     4 16k;        gzip_http_version 1.1;        gzip_comp_level 2;        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;        gzip_vary on;        gzip_proxied   expired no-cache no-store private auth;        gzip_disable   "MSIE [1-6]\.";        limit_conn_zone $binary_remote_addr zone=perip:10m;                limit_conn_zone $server_name zone=perserver:10m;#---------------------------------------------------#        server_tokens off;        access_log off;             # 关闭日志include /www/wwwroot/wwwconf/*.conf;}阿里云配置教程: https://help.aliyun.com/document_detail/54007.html第三方教程:https://www.cnblogs.com/wangxu01/articles/11243496.html
 1   0  635天前
admin
937
grep "Out of memory" /var/log/messages查看系统日志方法:运行egrep -i -r 'killed process' /var/log命令,结果如下:
 1   0  593天前
admin
988
#!/bin/bash# centos7 重装yumcatlogdata="/eisc/yum"mkdir -p $catlogdata ; rm -rf $catlogdata/*;     # 创建下载目录,并清空目录curldown="http://mirrors.163.com/centos/7/os/x86_64/Packages"                                                 # 定义下载连接变量rpm -aq|grep yum|xargs rpm -e --nodeps           # 卸载yumwgetrun(){curl $curldown/wget-1.14-18.el7_6.1.x86_64.rpm > wget.rpmrpm -ivh wget.rpm}; wgetrun                                       # 解决wget 问题rpmb=("python-iniparse-0.4-9.el7.noarch.rpm ""python-pycurl-7.19.0-19.el7.x86_64.rpm""python-2.7.5-89.el7.x86_64.rpm" "python-urlgrabber-3.10-10.el7.noarch.rpm""python-libs-2.7.5-89.el7.x86_64.rpm" "yum-metadata-parser-1.1.4-10.el7.x86_64.rpm" "yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm""yum-3.4.3-168.el7.centos.noarch.rpm");                                              # 定义数组变量要下载的包for i in ${rpmb[*]}    do        wget $curldown/$i -O $catlogdata/$i        echo "下载文件:$curldown/$i 到: $catlogdata/$i"    donerpm -ivh $catlogdata/yum-metadata-parser-1.1.4-10.el7.x86_64.rpmrpm -ivh $catlogdata/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpmrpm -ivh $catlogdata/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm $catlogdata/yum-3.4.3-168.el7.centos.noarch.rpm                                               # 两个包要一起安装相互依赖                                               # centos7 重装yum:https://www.cnblogs.com/DiZhang/p/12544744.htmlwget eisc.cn/file/shell/centos-yum.sh ; sh centos-yum.sh                                               # centos 切换yum 源                                                                                              yum install yum-utils -y                       # 解决:发现 XX 个已存在的 RPM 数据库问题 
 1   0  595天前
admin
2388
#---ssl 301 转跳 ---#    if ($server_port = 80){          rewrite ^(/2.php)$ http://www.eisc.cn$1 permanent;       }#--- 目录301 转跳 ---#设置 301 转跳, location /ccb/ {    return 301 http://work.eisc.cn;    proxy_pass http://eisc.cn/cs;    index  index.html index.htm;}# 说明:讲不带www 转到带www的,需要将不带www 的单独一个server 子站点配置转跳到 https://wwwreturn 301 https://www.eisc.cn$request_uri;# 设置 302 重定向 location /ccb/ {    rewrite /ccb/activity(.*)$ https://www.baidu.com break;    proxy_pass http://192.168.118.14/;    index  index.html index.htm;}#----------------------------   nginx 转发 反向代理 -----------------------------# # nginx 子站点tcp转发server{listen 80 ;listen 443;server_name kbash.cn www.kbash.cn;location / {     proxy_pass http://82.157.148.144:80;     index index.php index.html;  }}#------------- nginx https 转发 -------------## 注意如果需要配置ssl 需要再nginx 主配置http 模块文件加入ssl 证书配置,否则子站点无法设置ssl ,将会报错ssl_certificate    /www/www/ssl/www/eisc.pem; ssl_certificate_key    /www/www/ssl/www/eisc.key; # 需要已经存在的任意证书文件#------------- https 站点 ----------#server{listen 443 ssl;server_name eisc.cn www.eisc.cn;#----------------  ssl 证书  ----------------------ssl_certificate    /www/www/ssl/www/eisc.pem; ssl_certificate_key    /www/www/ssl/www/eisc.key;     #ssl on;    ssl_session_timeout 5m;    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;    ssl_prefer_server_ciphers on;    add_header jiedian "eisc.cn-ceshi";    add_header "开发商"  "小绿叶技术博客eisc.cn";    add_header "节点"  "小绿叶总站--总部";location / {     proxy_pass http://eisc.cn;    }}#---------------------------------------------------------------------#1 nginx修改root映射修改root映射实现nginx目录访问重定向是最简单的方式, 推荐采用这一种.location  /image {    root   /folderName;}2 通过nginx rewrite内部跳转实现访问重定向nginx配置代码示例:location /image {    rewrite ^/image/(.*)$     /folderName/image/$1 last;}3 nginx设置别名alias映射实现配置示例:location  /image  {    alias  /folderName/image;  #这里写绝对路径}4 通过nginx的permanent 301绝对跳转实现配置示例:location /image {    rewrite ^/image/(.*)$   http://dashidan.com/folderName/image/$1;}5 通过判断uri实现页面跳转配置示例:if ( $request_uri ~* ^(/image)){    rewrite ^/image/(.*)$ /folderName/image/$1 last;}原文链接:https://blog.csdn.net/sinbadfreedom/article/details/79494702tcp 转发:https://www.cnblogs.com/baolin2200/p/7803511.html
 83   1  653天前
admin
3978
忘记登陆密码,重置密码,安装教程-网卡多ip配置============  centos 6 和 7重置密码 ===================  centos 6.8  =====1.开机按Esc  或者 e 按键进入启动选择,再按 e 进入选择修改,然后出现 root kernel initrd 这三行开头的选择信息2.光标指向 kernel 这一行,按 e 进入修改  将 rhgb quiet 修改添加空格和1 为 rhgb quiet 1 或者 修改为:   rhgb quiet single3.Esc 返回上一级,按 b 键启动系统系统4. 命令 passwd 进行修改密码,然后 reboot  重启=======  centos 7  ======1.重启系统进入 提示等待几秒后启动系统的这个界面,按e键修改2.进入修改面板,有几行开头为:if else fi initrd16;    有两行开头为:linux16 和 initrd16; 我们修改linux16 行中的: 删除 rhgb quiet 和后面的内容如:UTF什么的,(也有些用户没有后面的UTF) 删除之后在其后添加   rd.break enforcing=0   再然后按Ctrl 加 X   保存,就进入命令窗口3. 输入命令: mount -o remount,rw /sysroot #重新挂载系统为写入 chroot /sysroot #改变文件系统的root # 进入用户界面下修改文件 passwd # 设置密码touch /.autorelabel # 引导前重新标记所有文件exit # 退出# mount -o remount,ro / # 不需要执行:重新挂载为只读exit # 退出后会重启#-------------   中毒后无法修改密码error:  ------------#linux_pe挂载后进入系统,或者开机启动时按e修改,进入破解页面mount /dev/vda1 /mnt      # 挂载系统盘chroot /mnt                       # 进入系统passwd root                       # 修改密码,无法修改报错 errorchattr -i /etc/*shadow /etc/passwd /etc/groupchattr -a /etc/*shadow /etc/passwd /etc/group                                         # 设置权限lsattr /etc/*shadow /etc/passwd /etc/group                                            # 查看权限                                          # 权限全部显示为横杠 ------------- /etc/gshadowpasswd root                       # 再次修改---------------------------  centos 安装教程  ---------------------------centos分区方案策略:http://eisc.cn/index.php?c=read&id=153&page=1安装时磁盘:勾选 l will configure partitioning 我要自己分区,删除原有的 LVM 分区后将LVM更换为 Standard partition 标准分区,Dbne 再回来分区Accept Changes  [əkˈsept ˈtʃeɪndʒɪz] 接受更改在安装时:config 配置网卡,右上角的开关打开,配置网卡ipv4将DHCP更改为Manual(手动) add添加多个IPliunx多个ip:以配置DNS一样似:DNS1和DNS2样式;IPADDR1=IPADDR2=NETMASK1=NETMASK2=GATEWAY1=GATEWAY2=DNS1=8.8.8.8# dns 禁止出现dns0  需要大等于0,否则网卡不通================  ubuntu  ================-----------  重置密码  ---------1. 开机时:按ESC  后按键 e或者进入下面启动选项,选择removable device进入修改启动removable devices [rɪˈmuːvəbl dɪˈvaɪsɪz] 可移动设备或者Shift  按键选择第二个是高级选项:ubuntu 高级选项然后选择第三个,括号里有:recovery mode再然后按键e 进入启动编辑或者重启系统进入选择界面 ,按键 e   直接进入编辑不同机器有不同方式,可以三种都试一下2. 已经进入了修改界面之后在行:linux /boot/     行末 先删除 ro 和后面的内容 添加内容 quiet splash rw init=/bin/bash3.  Crtl + X 重启后箭头向下选择括号里有(recovery mode)为高级选项然后即可自动进入超级管理界面4. 输入passwd  更新密码出现password updates successfully即更改成功,输入shutdown 或直接重启虚拟机即可。若出现下面的问题 passwd: Authentication token manipulation error passwd: password unchanged  网上说是因为recovery mode下的根分区是以只读的方式挂载的,所以需要重新挂载,输入下面的指令即可:  #> mount -rw -o remount /到此,问题解决了,重启即可ubuntu server 16 安装教程: https://blog.csdn.net/weixin_43397326/article/details/83186427ubuntu 安装教程:https://blog.csdn.net/zhengchaooo/article/details/80145744如果无法分区:返回上一级,选择选择:    27.您的时区对吗?(Is this time zone correct?):Yes        * (卸载正在使用的分区)unmount partitions that are in use? : Yes        * (删除现有的逻辑卷数据)Remove existing logical volume data:Yes        * (用于引导分区的卷组的数量)amount of volume group to use for guided partitioning: ?--------   ubuntu vi 编辑:  -------(1)下面介绍一下几种光标的控制和移动(在一般模式下操作)k 向上移动 h 向左移动j 向下移动 l 向右移动h :左移一个字符 l :光标右移一个字符space:右移一个字符 Backspace:光标左移一个字符k:光标上移一行 j:光标下移一行Enter :光标下移一行w或W :光标右移一个字至字首b或B :光标左移一个字至字首e或E :光标右移一个字至字尾x 删除当前光标下的字符X 删除光标前面的字符dw 删除从当前光标到单词结尾的字符d^ 删除从当前光标到行首的字符d$ 删除从当前光标到行尾的字符D 删除从当前光标到行尾的字符dd 删除当前光标所在的行其它常用命令;ndw或ndW:删除光标处开始及其后的n-1个字do:删至行首d$:删至行尾ndd:删除当前行及其后n-1行x或X:删除一个字符,x删除光标后的,而X删除光标前的Ctrl+u:删除输入方式下所输入的文本配置网卡多个ip地址:在vi 模式下可以按 Delete 键,删除字符vi /etc/network/interfaces # ubuntu 16 路径# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto enp6s0f0iface enp6s0f0 inet static address 192.168.1.9 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 8.8.8.8iface enp6s0f0 inet static address 192.168.1.10iface enp6s0f0 inet static address 192.168.1.11#==========================sudo /etc/init.d/networking  restart # 重启网卡,然后ip add查看操作用户:cat /etc/group  # 列出用户cat /etc/group | grep ^e # grep 过滤选择, ^ 开头字符为e的用户sudo useradd username -m # 创建用户sudo passwd username # 设置密码su username # 切换用户ps -ef | grep eisc # 显示进程pid ,grep 过滤eisc名字的进程kill -9 eisc # 终止pid -9 参数;进程为eisc的进程。sudo userdel -r eisc # 删除用户eisccat /etc/issue # 查看版本号===========  ubuntu 18  ============vi /etc/netplan/50-cloud-init.yaml # ubuntu 18 路径enp6s0f0:            addresses:       - 9.0.0.9/24       - 10.0.0.10/24       - 11.0.0.11/24            dhcp4: false            gateway4: 1.1.1.254            nameservers:                addresses:                - 8.8.8.8                search: sudo netplan apply # 重启网卡===============  debian  ================忘记密码修改密码:1.重启进入开机选择界面,按键  e  后修改启动文件,2.将 linux /boot 开头的行的 末尾 ro quiet 及其后面的内容更改为    rw single init=/bin/bash3.命令:mount -a4.命令:passwd root 修改你为你的新密码5.重启,或关掉电源,完成-------------------安装教程:debian下载:http://mirrors.hust.edu.cn/debian-cd/9.8.0/amd64/iso-cd/安装教程:https://ywnz.com/linuxaz/2591.html启动后其中选择第二个为 install 最小安装安装load installer components from cd # 从CD加载安装组件install the base system # 安装基本系统guided use entire disk # 引导使用整个磁盘primary ˈprīm(ə)rē, # 主:主分区finish partitioning and write changes to disk # 完成分区并将更改写入磁盘write the changs to disks # 将更改写入磁盘 yes'device for boot loader installation # 用于引导加载程序安装的设备 : /dev/sda等待校验,然后就可以选择自己要安装的 ssh 包了a network mirror can be used to supplement the software that is included onthe CD-ROM # 可以使用网络镜像来补充CD-ROM附带的软件 # 选择否选择安装,按空格勾选,除了ssh 其余全部取消install the grub boot loader to the master boot record # 最后一部:将grub引导加载程序安装到主引导记录中,是,否则无法启动编辑文本使用:vimapt-get install -y vimvim /etc/network/interfaces # 配置网卡多个IPauto ens192:1 # 机器本身的是 allow-hotelug ens192,直接修改为auto # 多ip 格式:auto ens192 # ens192:1 其中 :1 表示新增ip  auto ens192:1 inet static address 43.242.34.245/24 gateway 43.242.34.254auto eno2 # 内网,直接在这个文档里编辑iface eno2 inet static address 192.168.1.4/24/etc/init.d/networking restart # 重启网卡service networking restart手动安装 ssh apt-get install openssh-clientapt-get install openssh-serverps -e |grep sshvi /etc/ssh/sshd_configPermitRootLogin  without-password #  修改前PermitRootLogin yes # 修改后 /etc/init.d/ssh restart # 重启service ssh restart---------------  esxi  -------------------esxi6.7序列号:       HV4WC-01087-1ZJ48-031XP-9A843需要关闭 ssh 与 esxi shell步骤:首页>>>F2>>>输入密码后回车>>>Troubleshooting Options>>>回车切换开启/关闭:右边状态栏查看当前状态 is只需要配置一个IPadd选择网卡新安装和重置密码,只有第六步不同ESXI root密码忘记,重置root密码    第一步、放入安装时候的光盘进行光盘引导,按回车键下一步  第二步、同意霸王条款,按F11,下一步:第三步、安装程序自动搜索安装磁盘 wKiom1aLjpaAj_aiAACJZu37C80110.png第四步、直接选择要安装的磁盘,就是早起安装的那个磁盘 第五步、安装程序会自动检测选择的硬盘上是否安装过系统,从而进行判断此次安装是升级还是安装第六步、由于之前安装过此系统,那么会有如下选项,解释分别如下:            (1)升级此系统,保留VSMF数据(包括用户信息),因此选择此选项无用            (2)安装此系统,保留VSMF数据(安装系统,清除账户信息,不会丢失数据)            (3)安装此系统,清楚所有VSMF数据(此操作会清空所有数据文件)                                                                  故而选择第二种安装方案                                                                第七步、设置新的密码第八步、设置好密码后,系统手机信息,就有进度条开始走了第九步、安装完成后,系统提示“成功”,reboot后继续安装大功告成,可以使用客户端使用新的密码进行登录了。linux修改 ssh 远程端口:https://www.eisc.cn/index.php?c=read&id=154&page=1
 2   0  1450天前
admin
2322
#!/bin/bashcentos6d(){release=`cat /etc/redhat-release  |grep release | awk -F" " '{print $3}' | awk -F"." '{print $1}'` ; echo "centos 版本为: $release "case "$release" in"6") echo " 当前匹配centos 版本为 6"repo="/etc/yum.repos.d/centos6-epel.repo"if [ ! -e $repo ]; then                 # -e 判断文件存在;参考:Shell if 条件判断文件或目录yum install -y wgetcd /etc/yum.repos.d/mkdir bakmv * bakwget work.eisc.cn/ruanjian/rpm/yumrepo/centos6-epel.repowget work.eisc.cn/ruanjian/rpm/yumrepo/centos6.repoyum clean all                           # 清除原有缓存yum makecache                      # 生成新的缓存                                                # make cache [me?k]  [ka?]  制作 缓存{ka xi}yum  list                                       # 校验yumcdelseecho "yum已经切换"fi;;*) echo "低版本未匹配到,正在匹配红帽版本配置yum !!!"redhat8d;;esac}centos7(){repo="/etc/yum.repos.d/epel-7.repo"if [ ! -e $repo ]; then                 # -e 判断文件存在;参考:Shell if 条件判断文件或目录yum install -y wgetcd /etc/yum.repos.d/mkdir bakmv * bakwget work.eisc.cn/ruanjian/rpm/yumrepo/Centos-7.repowget work.eisc.cn/ruanjian/rpm/yumrepo/epel-7.repo# wget http://mirrors.aliyun.com/repo/Centos-7.repo# wget http://mirrors.aliyun.com/repo/epel-7.repo                                                # 移动两个文件到 目录#wget http://mirrors.163.com/.help/CentOS7-Base-163.repo#sed -i  's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo# sed -i  's/$releasever/7/g' /etc/yum.repos.d/*                                                # yum源没有对应版本包匹配;修改yum为centos7yum clean all                           # 清除原有缓存yum makecache                      # 生成新的缓存                                                # make cache [me?k]  [ka?]  制作 缓存{ka xi}yum  list                                       # 校验yumcdelseecho "yum已经切换"fi}centos8(){repo="/etc/yum.repos.d/Centos-8.repo"if [ ! -e $repo ]; thencd /etc/yum.repos.d/mkdir bakmv * bakwget work.eisc.cn/ruanjian/rpm/yumrepo/centos8/centos8.repowget work.eisc.cn/ruanjian/rpm/yumrepo/centos8/epel.repoyum clean all #清理缓存yum makecache #更新源elseecho "yum已经切换"fi}redhat8d(){release=`cat /etc/redhat-release  |grep release | awk -F" " '{print $6}' | awk -F"." '{print $1}'` ; echo "redhat 版本为: $release "case "$release" in"8") echo " 当前匹配redhat 版本为 8"repo="/etc/yum.repos.d/Centos-8.repo"if [ ! -e $repo ]; thencd /etc/yum.repos.d/mkdir bakmv * bakwget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repowget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.reposed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g'  /etc/yum.repos.d/Centos-vault-8.5.2111.repo &&  sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.reposed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repoyum clean all && yum makecacheelseecho "yum已经切换"fi;;*) echo "红帽版本未匹配到,退出!!!";;esac}release=`cat /etc/redhat-release  |grep release | awk -F" " '{print $4}' | awk -F"." '{print $1}'` ; echo "centos 版本为: $release "case "$release" in"6") echo " 当前匹配centos 版本为 6"centos6;;"7") echo " 当前匹配centos 版本为 7"centos7;;"8") echo "当前匹配centos 版本为 8"centos8;;*) echo "您的centos过于老旧,正在匹配低版本"centos6d;;esac# 清华 apt 源:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/# centos 6 切换yum: https://help.aliyun.com/document_detail/193569.htm# 一键切换yum执行: wget www.eisc.cn/file/shell/centos-yum.sh ; sh centos-yum.sh# 感谢网友提供yum解决方案:https://developer.aliyun.com/article/748336# 阿里巴巴开源镜像站,镜像仓库:  https://developer.aliyun.com/mirror/# 阿里云linux系统镜像: https://mirrors.aliyun.com/centos-vault/1. /etc/yum.repos.d 文件夹里面的文件全部移动到其他目录,重新部署 yum2. 辛苦切换一下yum :https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11Pi5Ktu#---------- alibaba3 -----------#mkdir /yumbackmv /etc/yum.repos.d/* /yumbackwget work.eisc.cn/ruanjian/rpm/yumrepo/alibaba3/AliYun.repo -O /etc/yum.repos.d/al3.repowget work.eisc.cn/ruanjian/rpm/yumrepo/alibaba3/epel.repo -O /etc/yum.repos.d/epel3.repoyum clear all ; yum list#--------- centos8 停止维护,更换yum  -------------#停止维护公告:https://help.aliyun.com/noticelist/articleid/1060980265.html更换yum:https://help.aliyun.com/document_detail/405635.html迁移服务器系统:https://help.aliyun.com/document_detail/370865.htm?spm=a2c4g.11186623.0.0.58863201lhpfjW#task-2156316
 1   9  544天前
admin
1374
# 301 访问2.php文件转跳到另一个网站的2.php文件, 删除$1 就不指定文件名, 如果是https 方式 就要将80改为443在nginx配置文件的 server() 板块进行添加    if ($server_port = 80){          rewrite ^(/2.php)$ http://www.eisc.cn$1 permanent;       }
 7   0  819天前
admin
1300
#!/bin/bashfolder="/eisc/yum"          # 定义下载目录mkdir -p $folder            # 创建下载目录wgetfile=(https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.i686.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpmhttps://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm)iffile="$folder/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm"                            # 定义已经存在的文件if [ ! -e $iffile ]         # 判断文件 ! 不存在,then 开始  then       for ((i=0;i<${#wgetfile[*]};i++))                         # i初始为0 数组角标从0开始                                       # i 范围为 0 到  小于数组个数值,这个区间自增加                                       # 数组 [*] 符号*指定所有,可以改为0从第一个角标,1表示第二个                                       # 不加#号表示展示数组元素          do             wget -P $folder  ${wgetfile[$i]}                                 # wget -P 文件夹   被下载的文件       done  else        echo "安装文件已经下载!"fi#------- 安装 -------#rpmfile=(`ls $folder`)for((i=0;i<${#rpmfile[*]};i++  )) dorpm -ivh --force --nodeps $folder/${rpmfile[$i]}donecentos7 下载链接:https://mirrors.aliyun.com/centos-vault/7.0.1406/os/x86_64/Packages/脚本执行:wget www.eisc.cn/file/shell/yumnocommand6.sh ; sh yumnocommand6.sh
 1   0  735天前
admin
1323
#------ 301 转跳 ----## 301 访问2.php文件转跳到另一个网站的2.php文件, 删除$1 就不指定文件名,  如果是https 方式 就要将80改为443在nginx配置文件的  server()  板块进行添加    if ($server_port = 80){          rewrite ^(/2.php)$ http://www.eisc.cn$1 permanent;       }#----  nginx 转发 反向解析代理--# # nginx 子站点tcp转发server{listen 80;listen 443;server_name www.kbash.cn;location / {     proxy_pass http://47.105.46.67;     index index.php index.html;  }}nginx -s reload        # 重载nginx配置#-------------------------等待研究--------------------------------------##PROXY-START/location  ~* \.(gif|png|jpg|css|js|woff|woff2)${    proxy_pass http://eisc.cn;    proxy_set_header Host tx.kbash.cn;    proxy_set_header X-Real-IP $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header REMOTE-HOST $remote_addr;    expires 12h;}location /{    proxy_pass http://eisc.cn;    proxy_set_header Host tx.kbash.cn;    proxy_set_header X-Real-IP $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header REMOTE-HOST $remote_addr;        add_header X-Cache $upstream_cache_status;        #Set Nginx Cache            add_header Cache-Control no-cache;}#PROXY-END/#-------------------------------   官方案例    ---------------------------------------#worker_processes auto;error_log /var/log/nginx/error.log info;events {    worker_connections  1024;}stream {    upstream backend {        hash $remote_addr consistent;        server backend1.example.com:12345 weight=5;        server 127.0.0.1:12345            max_fails=3 fail_timeout=30s;        server unix:/tmp/backend3;    }    server {        listen 12345;        proxy_connect_timeout 1s;        proxy_timeout 3s;        proxy_pass backend;    }    server {        listen [::1]:12345;        proxy_pass unix:/tmp/stream.socket;    }}#-------------------------    已成功案例    ---------------------------------user www-data;worker_processes auto;pid /run/nginx.pid;include /etc/nginx/modules-enabled/*.conf;events {worker_connections 768;# multi_accept on;}stream{log_format proxy '$remote_addr [$time_local] ''$status "$upstream_addr"';upstream ipctcp_proxy {hash $remote_addr consistent;server eisc.cn:80 weight=5 max_fails=3 fail_timeout=30s;server eisc.cn:37 weight=5 max_fails=3 fail_timeout=30s;server eisc.cn:55 weight=5 max_fails=3 fail_timeout=30s;}server{error_log /var/log/nginx/error.log;access_log /var/log/nginx/access.log proxy;listen 80;listen 8080;listen 37;listen 55;proxy_connect_timeout 1s;proxy_timeout 3s;proxy_pass ipctcp_proxy;}}
 1   1  670天前
admin
1617
1.ssh keys 自行配置,2. 集群配置ssh 密钥  3.阿里云密钥配置 #     使用密匙秘钥登录服务器chmod 600 1.pem                                # 使用密匙 1.pem 登录,需要加权限 401 读和执行,                                                            # 7=4+2+1 = r + w  + x   读+写+执行;   Read(4)  Write(2)  eXecute(1)ssh -i /root/1.pem root@10.1.1.1         # 使用密匙登录服务器 #     配置远程服务器 sshd 服务开启 密钥和密码登录  流程:再本机生成密匙---> 将本地密匙 发送给远程服务器授权  --->  本地使用这个密匙远程免密登录目的服务器1. 生成的公共密钥保存在/.ssh/id_rsa.pub  私有密钥保存在 /.ssh/id_rsa   复制   .ssh/id_rsa.pub   文本内容到目标服务器2. 目标服务器:用户家目录创建文件:.ssh/authorized_keys    3. 权限:chmod 600 .ssh/authorized_keys    # vim /etc/ssh/sshd_config                     # 修改sshd 配置文件PasswordAuthentication no                     #     [ˈpɑ ːs  wɜː d      ɔːˌ θen tɪˈ keɪ ʃn]  o fen ti k xin  密码 验证,登录  yes  或者 no                                                                  ChallengeResponseAuthentication no      # yes改为noRSAAuthentication yes                             # 去掉前面的注释PubkeyAuthentication yes                        # 去掉前面的注释AuthorizedKeysFile .ssh/authorized_keys   # 去掉前面的注释echo "RSAAuthentication yesPubkeyAuthentication yes# 开启密钥登录PermitRootLogin yes开密码登录" >> /etc/ssh/sshd_config                                               # 配置sshd 密钥和密码登录systemctl restart sshd            # 重启ssh服务chmod 700 ~/ ; chmod 700 ~/.ssh ; chmod 600 ~/.ssh/authorized_keys                                                # 文件权限,本地和服务器都需要配置#----------------------------        本地配置ssh密钥,发送到远程服务器进行免密登录         -------------------------------#echo "# 生成密匙对:请一直回车,生成默认空的密匙,也可以参考生成密匙说明"ssh-keygen -t rsa                             # 在本地生成密钥 # 生成密匙对:一直回车;其中id_rsa 是私钥,id_rsa.pub是公钥                                                        # 密钥和私钥是成对存在的,缺一不可echo "使用ssh秘钥分发 将本地密钥发送给远程服务器授权识别"ssh-copy-id -i /root/.ssh/id_rsa.pub root@43.255.28.59 # 对方主机地址IPssh root@10.111.111.80                 # 免密直接登录服务器 #    ssh keys 生成秘钥说明#------  命令生成 密匙种类 一直回车确认 ------#ssh-keygen -b 4096                          # RSA    无需 -t 指定,-b 指定安全尺寸范围: 1024~16348                                                          # 注意:使用更长的密钥存在收益递减。安全性比 RSA-2048 所提供的更强,应该做的是改用椭圆曲线密码学 ECDSAssh-keygen -t ed25519                     # [dʒen]  jie m  消息,密钥消息#----------- 案例:    ssh-keygen -t rsa      -----------#Generating public/private ed25519 key pair.                                                                           # [ˈdʒe nə reɪ tɪŋ]   jie lou rei ting 生成  [ˈpʌ b lɪk] /  [ˈp raɪ vɪt]  公共私有   [kiː]  [per]  密匙  (一),  两对Enter file in which to save the key (/root/.ssh/id_ed25519):                                              # [ˈentər]  en tou 输入 ( 开始)  文件 [faɪl]  [ɪn]  在  [wɪtʃ]   [tu ] 其中  保存这个密钥 {the 形容词翻译可以省略}                                              # 输入保存密钥的文件。自定义文件名和路径                                              # 注意:密钥文件名不能重复,否则会覆盖原来的密钥Created directory '/root/.ssh'.                                               #  [k ri ˈeɪ tɪ d]  kui ei tei te 创建  [də ˈre k tə ri]  dou ruai ke tou rui  目录Enter passphrase (empty for no passphrase):                                                # 输入 pass  [f reɪ z]  短语,密码短语   [ˈe m pti] en m d 空的  为 没有密码短语。类似于密码加密,建议输入Enter same passphrase again:                                               #  输入 [seɪ m] 相同 密码短语   [əˈ ɡen] ou gen  再一次Your identification has been saved in /root/.ssh/id_ed25519.                                                # 您的 [aɪˌ den tɪ fɪˈkeɪ ʃn]  ai den ti fei k xin 标识  [biːn] 曾经,has been 已经。保存在Your public key has been saved in /root/.ssh/id_ed25519.pub. The key fingerprint is:              #  [ði] 这个  [kiː] k i   密匙,关键,  [ˈfɪŋɡəprɪnt] shen ge p len t 指纹              SHA256:xdq0kS22xfwTBo4d3BKD7uUXxtWS/ikPQEQsH7O1lEA root@localhost.localdomainThe key's randomart image is: #    3. 阿里云密匙对配置  ECS 管理---网络与安全---密匙对---创建密匙对---查找创建的密匙对,绑定ECS实例控制台操作重启ECS生效参考:https://wangdoc.com/ssh/key.html
 1   1  700天前
admin
1256
#----  方案一,通过数据库修改管理后他域名 ---#第一步、进入数据库管理,大部分都是phpmyadmin管理,不是的也没事,反正进入到数据库管理就行,找到wp_options数据库表,如下图第二步、编辑选项名称siteurl和home后面的那个地址,如下图第三步、比如我老域名是www.liuhai.net,我现在要改成新域名www.baidu.com,改好选择保存,点执行后如下图通过数据库该域名http://www.liuhai.net/1239.html#----- 其它无效方法 直接忽略----------#找到wordpress中使用的模板中的function.php文件,查找路径如:/wwwroot/wp-content/themes/模板文件/function.phphttps://jingyan.baidu.com/article/afd8f4deaaae0334e386e955.html方法二:重命名登录页找到wp-login.php 更改为自定义的文件名,为了演示的需要,笔者更改为ilovelogin.php然后把ilovelogin.php里面所有wp-login全部替换为ilovelogin然后访问:http://localhost/w/ilovelogin.php 即可访问登录找到你现在所使用的主题,在主题目录中找到functions.php,在这个文件中加入以下代码:update_option(‘siteurl’,’http://你的新域名’);update_option(‘home’,’http://你的新域名’);
 1   0  668天前
admin
1146
#----- 创建专有网络和交换机 ------------##--- 已经存在ecs ---#1. 进入 ecs 服务器 控制台 --- 点击左侧 【实例】 --- 点击顶部切换 【地域】--- 点击实例id 进入ecs 服务器 --- 可以查看 cpu 内存 ip 等信息 --- 下拉 找到【网络信息】 --- 绑定辅助弹性网卡 右边的三个点展开选项 --- 管理ipv6 --- 弹窗出来ipv6 地址 --- 分配新ipv6  --- 弹窗关闭后,复制专有网络id :vpc****2. 开通ipv6 带宽: IPv6网关管理控制台 --- 顶部切换到服务器所在地域 ---- ctrl +f  与 ctrl +v 定位vpc 位置 --- 点击定位左边的 :网关 id 进入 ---- 看到 ipv6 公网带宽 --- 右边点击 : 【开通公网带宽】3. 重点:服务器内部配置 配置IPv6地址 驱动:wget https://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/rhel/ecs-utils-ipv6?spm=a2c4g.11186623.0.0.486d6b17mxAJEC -O ipv6                                                             # centos 下载驱动:大写O 下载文件保存为 ipv6 文件名# wget https://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/debian/ecs-utils-ipv6?spm=a2c4g.11186623.0.0.486d6b17mxAJEC -O ipv6                                                            # ubuntu/Debian: 下载这个驱动chmod +x ipv6                                     # 附加执行权限./ipv6                                                    # 执行当前目录下的这个脚本4. 添加安全组规则 ---- 进入ecs 实例 --- 切换地域 ---- 进入ecs 实例 ---- 点击安全组 ---- 如果有多个安全组 建议移除后保留一个 ---点击 【配置规则】--- 入方向手动添加 --- 协议类型 点击选择 ipv6 ---  点击端口范围选择全部  ---  授权对象 : ::/05. 测试ipv6 : ping6 aliyun.comcurl -6 aliyun.com#-----------------------------------  其他注意项 -----------------------------##---  如果没有 ecs  ----#1. 登录: 专有网络控制台2. 顶部选择 地域 --- 创建专有网络--- 名称自定义(只能大小写,不能加特殊符号如:-)3. 左侧导航栏交换机 --- 点击实例id 进入 --- 往下拉云资源管理 --- ecs 加号新增#--- 删除 vpc 专有网络 ----#先删除交换机--- 再 安全组 切换地域 找到并勾选删除 --- 最后删除vpc专有网络 专有网络控制台说明:专有网络的地域和要部署的云资源的地域必须相同,本文选择华北5(呼和浩特)。说明 目前,仅以下地域支持开通IPv6网段:华北1(青岛)、华北2(北京)、华北3(张家口)、华北5(呼和浩特)、华北6(乌兰察布)、华东1(杭州)、华东2(上海)、华南1(深圳)、华南2(河源)、华南3(广州)、西南1(成都)、中国(香港)、新加坡、美国(弗吉尼亚)、德国(法兰克福)。
 1   0  661天前
admin
1574
1.手动安装,2.脚本自动安装 1.手动安装yum install -y ntpdate # 安装时间工具timedatectl set-timezone Asia/Shanghai # 设置时区:亚洲/上海systemctl restart ntpdate # 重新启动ntpsystemctl enable ntpdate # 添加开机启动; system [ˈsɪstəm] 系统; enable [ɛˈnebəl] 启动;  cat /etc/redhat-release  # 查看系统版本yum install -y wget # 下载工具rpm -Uvh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm # -U upgrade [ʌpˈɡreɪd] 改进  # -v verbose [vəːˈbəʊs] 沉长的;provide more detailed output   [prəˈvʌɪd] [mɔr] [ˈdiːteɪld]  [ˈaʊtpʊt] 提供更详细的输出 # -h hash [haʃ] 在...什么(打撒,混杂);print hash marks as package installs  [mɑːks]标记 [ˈpakɪdʒ] [ɪnˈstɔːl]安装包 ;在软件包安装时打印散列标记wget -rndp /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # wget -O 下载文件到指定目录;此处是替换原有文件systemctl stop firewalld # 关闭防火墙 firewall  [ˈfaɪrwɑl]setenforce 0 # 临时关闭selinux;永久关闭:sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config ; rebootyum -y install httpd mariadb mariadb-server php php-mysql php-bcmath php-mbstring zabbix-server-mysql zabbix-web-mysql zabbix-agent # 安装mariadb  等软件sed -i s/index.html/index.php/g /etc/httpd/conf/httpd.conf # 修改默认访问文件;  find / -name "httpd.conf" | grep "etc"  # 查找 etc目录下的这个文件 # httpd.conf 修改 index 添加运用:x-httpd-php .php  去过滤grep Add cat -n `find / -name "httpd.conf" | grep etc` | grep "AddType application"  # cat -n 查看文件显示行号;`find / -name "httpd.conf" | grep etc` 反单引号是执行结果为一个整体变量;find 查找文件路径 # grep 查找sed -i "272 a\AddType application/x-httpd-php .php" /etc/httpd/conf/httpd.conf # 添加运用的位置 ; a\ 是在指定272行下面插入字符 # 由上个查看行号有四行,任意位置可以添加,我这里是272行cat -n /etc/php.ini | grep "date.timezone" # 查看时间区域行号;我这里是878行sed -i "878 a\date.timezone = Asia/Shanghai" /etc/php.ini systemctl start mariadb # 重启mariadb数据库systemctl enable mariadb # enable [ɛˈnebəl] 启动;开机启动mysql  # 默认没有密码,直接mysql 进入数据库;设置密码后需要 mysql -uroot -p密码  进入数据库set password = password('eisccn') ;   # 设置密码create database zabbix character set utf8 collate utf8_bin; # create  [kriˈet] 创建 ;database [ˈdædəˌbeɪs] 数据库;character [ˈkɛrɪktər] 字符,设置字符类型,collate [kəˈlet] 核对字符 # 登陆数据库,创建库编码为utf8grant all on zabbix.* to 'zabbix'@'localhost' identified by '123' # grant [grænt] 授权;all 所有,on 在...上;    授予zabbix账户在 localhost [ləʊkæl'həʊst] 本机的所有权限; identified [aɪ'dentɪfaɪd] 识别(设置密码) # identified [aɪ'dentɪfaɪd] 标识;by 由 123密码:设置zabbix 的 DBPassword # 123 是密码,需要单引号,数据库账户和本机需要find / -name "create.sql.gz" # 查找数据库文件路径zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz | mysql -uzabbix -p123 zabbix # 将查到的文件导入数据库账户 zabbix 下的库名zabbix下cat -n /etc/zabbix/zabbix_server.conf | grep DBPassword # 查看到是124行sed -i "$NRuser a\DBPassword=123" /etc/zabbix/zabbix_server.conf # 配置密码/usr/bin/systemctl restart httpd zabbix-server zabbix-agent/usr/bin/systemctl enable httpd zabbix-server zabbix-agent # enable [ɛˈnebəl] 启动; 开机启动#################################添加主机####################################rpm -Uvh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpmyum list # 更新yumyum -y install zabbix-agentread -p "请输入Zabbix-serve的ip地址:" server_IPsed -i s/127.0.0.1/$server_IP/g /etc/zabbix/zabbix_agentd.conf /bin/systemctl restart zabbix-agent.service网页操作:ZABBIX 顶部导航栏 ---> 配置 --- 主机群组 --- 创建主机群组 --- 定义名称:ceshi  --- 点击添加ZABBIX 顶部导航栏 ---> 配置 --- 主机 --- 创建主机 ---主机名称:zabbix_ceshi 群组: 选择刚创建的 ceshiagent代理程序的接口: 被监控的主机IP地址, 端口10050  保存ZABBIX 顶部导航栏 ---> 配置 --- 主机 --- 模版 --- 选择模板 Template OS Linux by Zabbix agent --- 更新ps aux | grep zabbix # 查看服务是否启动yum install -y telnet # 端口测试工具telnet x.x.x.x 10050 # 测试端口是否联通再到首页查看状态##########################################邮件报警ping监控###################################################systemctl stop firewalld # 关闭防火墙yum install fping -y  # 在server和proxy端均安装fpingFpingLocation=/usr/sbin/fping  # 在server和proxy端的配置文件里面打开注释telnet hc1.ssh.gs 10050 # ping 端口ZABBIX 顶部导航栏 ---> 配置 --- 主机群组 --- 点击刚刚创建的用户组里的用户zabbix_cesshi --- 监控项 --- 创建监控项名称:ping test类型:简单检查键值:icmpping[43.225.156.172,2,1000,68,3000]主机接口:默认信息类型:数字更新间隔:30s自定义时间间隔:类型:灵活    间隔:50s    期间:默认历史数据保留时长:90d储存时间 :365d查看值:不变应用集:无保存ZABBIX 顶部导航栏 ---> 配置 --- 主机群组 --- 点击刚刚创建的用户组里的用户zabbix_cesshi --- 监控项 --- 触发器 --- 创建触发器名称:fping严重性:警告表达式:选择 ping test保存ZABBIX 顶部导航栏 ---> 配置 --- 主机群组 --- 点击刚刚创建的用户组里的用户zabbix_cesshi --- 图形 --- 创建图形名称:fping监控项 --- 添加 --- ping test添加保存##########################################实现邮件报警功能 server 端口配置###################################################yum install mailx -y # 安装linux邮件工具,在控制节点:server 端进行操作; agent 是被监控端vi /etc/mail.rcset bsdcompatset sendcharsets=iso-8859-1,utf-8set from=xitong-mail@eisc.cnset smtp=smtp://smtp.exmail.qq.comset smtp-auth-user=xitong-mail@eisc.cnset smtp-auth-password=xxxxxxset smtp-auth=login # 编辑邮件登陆配置信息echo "这是一封测试邮件" | mail -s "zabbix" xxx@eisc.cn # 测试邮件发送是否正常mkdir -p /data/zabbix_server/data/alertscripts # 创建发邮件发警的脚本所在目录zabbix=`find / -name "zabbix_server.conf"` # 查找zabbix配置文件目录,将结果赋值给zabbix变量cat -n $zabbix | grep "AlertScriptsPath" # 查看需要更改的位置sed -i "517 s/AlertScriptsPath.*/AlertScriptsPath=\/data\/zabbix_server\/data\/alertscripts/g" $zabbix # 517 指定517行的内容进行修改 # sed 修改, 将AlertScriptsPath.*  后面的所有内容修改为:AlertScriptsPath=/data/zabbix_server/data/alertscripts   特殊符号 /,用转译 \systemctl restart zabbix-server.service # 重启服务 vi /data/zabbix_server/data/alertscripts/mailx.sh # 编写发邮件脚本#!/bin/bash#echo "$3" | mail -s "$2" "$1"FILE=/tmp/mailtmp${RANDOM}.txttouch $FILEecho "$3" >$FILEdos2unix -k $FILEmailx -v -s "$2" "$1" < $FILErm -rf $FILEchmod +x /data/zabbix_server/data/alertscripts/mailx.shchown zabbix:zabbix /data/zabbix_server/data/alertscripts/mailx.sh # 脚本增加执行权限sudo -u zabbix /data/zabbix_server/data/alertscripts/mailx.sh xxx@eisc.cn "zabbix alert" "/etc/passwd is changed" # 测试一封邮件# zabbix页面配置webZABBIX 顶部导航栏 ---> 管理 ---> 报警媒介类型 ---> 创建媒体类型 ---> 名称:agent 报警器类型:脚本脚本名称:mailx.sh脚本参数(增加三个):{ALERT.SENDTO}{ALERT.SUBJECT}{ALERT.MESSAGE}# 创建用户 email 导航栏 --- 管理 --- 用户 --- 右上角创建用户 --- 别名:email 选择群组: Zabbix administrators密码:aaaassss保存# 创建用户组导航栏 --- 管理 --- 用户群组 --- 右上角创建用户群组组名:emailgroup用户(点击选择):email 再点击二级栏目的权限为读写保存# 配置用户报警媒介:导航栏 --- 管理 --- 报警媒介类型 --- 创建媒体类型 --- 类型选择脚本名称:Email脚本类型:脚本脚本名称:mail.sh# 点击添加,保存# alert [əˈlərt] 报警 ;   to send   [sɛnd tu] 发送到 ;  message  [ˈmɛsɪdʒ] 消息#用户配置 ZABBIX 顶部导航栏 ---> 管理 --->  用户 ---> Admin ---> 报警媒介 ---> 添加 ---> 类型:agent 报警器接受人: xxx@eisc.cn启用时间默认如果存在严重性则使用:全选勾选已启用点击添加# 配置动作ZABBIX 顶部导航栏 ---> 配置 --->  动作 ---> 创建动作 名称: tcping新的触发条件:  主机 等于  test_centos选择后,再点击已启用上面的【添加】再点击【操作】暂停操作以制止问题操作【新的】发送到用户群组:【添加】【emailgroup】   【zabbix administrator】发送到用户: 【admin】 【email】点击蓝色【添加】上面的【添加】再点击【恢复操作】操作【新的】发送到用户群组:【添加】【emailgroup】   【zabbix administrator】发送到用户: 【admin】 【email】点击蓝色【添加】上面的【添加】再点击下已启用下面的【添加】 总添加完成ZABBIX 顶部导航栏 ---> 管理 --- 用户 --- Admin --- 报警媒介 --- 添加 : 填写收件人:xxx@eisc.cn 2.脚本安装#!/bin/bash###################check network###################echo '正在检测网络是否和zabbix官方通畅......'ping -c 2 www.zabbix.com > /dev/null # 将ping -c 2  拼两次的消息结果重定向到空洞/dev/null,清除消息记录if [ $? != 0 ];then # $? 是上一个程序执行是否成功的标志,如果执行成功则$? 为0,否则 不为0 echo "请检查网络!" exit # 运行到此情况(网络异常ping不通);就全局退出脚本 [ˈɛgzɪt] exit 出口else echo "网络正常!" # 正常情况不仅仅打印一句话,然后继续往下执行fi###################set yum#################################yum install -y ntpdate ntpdate -u cn.pool.ntp.org timedatectl set-timezone Asia/Shanghai #  systemctl start ntpd # start [stɑrt] 开始;开始执行 systemctl enable ntpd # enable [ɛˈnebəl] 启动;加入开启启动#时间矫正rm -rf /var/run/yum.pid # yum.pid 作用:防止启动多个进程副本;此处不需要yum -y install wgetsystem=`cat /etc/redhat-release | awk -F "." '{print $1}'` # release [riˈlis] 发布; system [ˈsɪstəm] 系统  # 查看系统版本,awk字段处理以点为分隔符:打印第一列;将结果赋值给变量 systemif [ "$system" == 'CentOS Linux release 7' ];then # if 判断变量 字符串绝对等于 指定字符串,then 然后执行    rpm -Uvh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm # U更新,升级rpm ;v表示显示安装过程,h表示显示进度    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # wget -O 下载文件到指定目录;此处是替换原有文件    systemctl stop firewalld # 关闭防火墙 firewall  [ˈfaɪrwɑl]setenforce 0 # 临时关闭selinuxsed -i "s/SELINUX\=.*/SELINUX=disabled/g" /etc/selinux/config #永久关闭selinux ; disabled [dɪˈsebəld] 废除;  config [kən'fɪg] 配置,设置elif [ "$system" == 'CentOS release 6' ];then    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo # base [bes] 基地;mirror [ˈmirəz] 镜像,镜子    rpm -Uvh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm    service iptables stopsetenforce 0 # 临时关闭selinuxsed -i "s/SELINUX\=.*/SELINUX=disabled/g" /etc/selinux/config #永久关闭selinux ; disabled [dɪˈsebəld] 废除;  config [kən'fɪg] 配置,设置fi##################install###############################eth=`ip a| grep "BROADCAST" | awk -F ":" 'NR==1{print $2}' | sed "s/ //g"` ; echo "网卡名为:"$eth ;                                                                                 # 命令 ip a 查看网卡 过滤;broadcast  [ˈbrɔːdkɑːst] >广播;字段的行                                                                                 # awk -F ":" 以冒号为分隔符 ; 选择第一行,第二列,sed删除空格 # 符号  ; 分号表示第一条命令结束,第二条开始ethCatalog=$(find / -name "*$eth" | grep "/etc/" | sed "s/ //g" ) ;  echo "网卡路径为: "  $ethCatalog # catalog [ˈkætəlɔg] 目录 # find 查找网卡名称的路径,grep 过滤/etc 目录下网卡名称。sed删除空格ip=$(cat $ethCatalog | grep IPADDR | awk -F "=" 'NR==1{print $2}' | sed "s/ //g") ; echo "IP地址为: " $ip                                                                                # 查看网卡文件,过滤IPADDR的行,awk -F"=" 分隔符是冒号,打印第一行第二列sleep 5 # 等待5秒钟;sleep [slip] 睡眠server(){yum -y install httpd mariadb mariadb-server php php-mysql php-bcmath php-mbstringyum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent # 安装mariadb  等软件sed -i s/index.html/index.php/g /etc/httpd/conf/httpd.conf # 修改默认访问文件#######################修改配置文件################### sed -i "N;286i\AddType application/x-httpd-php .php" /etc/httpd/conf/httpd.conf# sed -i "N;880i\date.timezone = Asia/Shanghai" /etc/php.iniNRhttpd=$(cat -n /etc/httpd/conf/httpd.conf | grep "AddType application/x-gzip .gz .tgz" | awk -F" " '{print $1}' | sed "s/ //g") # add type  [æd] [taɪp] 添加类型; application [ˌæpləˈkeʃən] 运用; # cat -n 查看文件内容并显示行号 # grep 匹配字符串所在行的整行内容 # awk -F" " 字段处理指定分隔符为空格,打印第一列;删除空格echo "根据字符串查找的文本中的行号:"$NRsed -i "/AddType application\/x-httpd-php .php/d" /etc/httpd/conf/httpd.conf # 在写入前,先删除将要插入的字符串,保证不会重复插入sed -i "$NRhttpd a\AddType application/x-httpd-php .php" /etc/httpd/conf/httpd.conf # $NR a\  根据查找到行号,的下一行插入字符串 # i\  是上一行插入字符串NRdate=`cat -n /etc/php.ini | grep ";date.timezone =" | awk -F" " '{print $1}' | sed "s/ //g"` ; echo $NRdatesed -i "/Asia\/Shanghai/d" /etc/php.inised -i "$NRdate a\date.timezone = Asia/Shanghai" /etc/php.ini  # 其中符号 ;  表示注释符号。####################################################/usr/bin/systemctl start mariadb # 重启mariadb数据库/usr/bin/systemctl enable mariadb # enable [ɛˈnebəl] 启动;开机启动mysql -e "set password = password('WWWeisccn111@#')" # 进入数据库设置密码mysql -uroot -pWWWeisccn111@# -e "create database zabbix character set utf8 collate utf8_bin;" # create  [kriˈet] 创建 ;database [ˈdædəˌbeɪs] 数据库;character [ˈkɛrɪktər] 字符,设置字符类型,collate [kəˈlet] 核对字符 # 登陆数据库,创建库编码为utf8mysql -uroot -pWWWeisccn111@# -e "grant all on zabbix.* to 'zabbix'@'localhost' identified by '123'" # grant [grænt] 授权;all 所有,on 在...上;    授予zabbix账户在 localhost [ləʊkæl'həʊst] 本机的所有权限; identified [aɪ'dentɪfaɪd] 识别(设置密码) # identified [aɪ'dentɪfaɪd] 标识;by 由 123密码:设置zabbix 的 DBPassword # 123 是密码,需要单引号,数据库账户和本机需要# 此处已经修改bugfind查看数据库文件createmysql=$(find / -name "create.sql.gz") ; echo "$createmysql 数据库文件导入中,请耐心等待!" # 查找文件路径并打印/usr/bin/zcat $createmysql | mysql -uzabbix -p123 zabbix # 导入数据库,登陆数据,用户名zabbix 密码123,并且进入数据库zabbix # zcat 查看压缩包的文件,管道到登陆数据库里面去执行# sed -i "N;110i\DBPassword=123" /etc/zabbix/zabbix_server.conf  # 配置zabbix密码NRuser=`cat -n /etc/zabbix/zabbix_server.conf | grep "DBUser=zabbix" |awk '{print $1}' | sed "s/ //g"` ; echo $NRusersed -i "/DBPassword=123/d" /etc/zabbix/zabbix_server.confsed -i "$NRuser a\DBPassword=123" /etc/zabbix/zabbix_server.conf/usr/bin/systemctl restart httpd zabbix-server zabbix-agent/usr/bin/systemctl enable httpd zabbix-server zabbix-agent # enable [ɛˈnebəl] 启动; 开机启动echo "请用浏览器访问:http://$ip/zabbix安装配置:数据库名:zabbix数据库用户:zabbix密码:123登陆账户/密码:Admin/zabbix"}agent(){yum -y install zabbix-agentread -p "请输入Zabbix-serve的ip地址:" server_IPsed -i s/127.0.0.1/$server_IP/g /etc/zabbix/zabbix_agentd.conf /bin/systemctl restart zabbix-agent.service}##################install menu###########################MYDATE=`date +%d/%m/%y` # 定义一个时间变量:格式化字符为:十进制日期,月份,年份抹除100THIS_HOST=`hostname -s`USER=`whoami`while :do  tput clear  echo " # cat 与echo 相似,这里打印显示一段话;由 aMAYDAY  开始,也由它来结束;---------------------------------------------------------User:$USER            Host:$THIS_HOST        Date:$MYDATE# cat 这里直接打印字符串和变量的值---------------------------------------------------------            1:安装 zabbix-server和zabbix-agent            2:只安装 zabbix-agent     H:帮助            Q:退出---------------------------------------------------------" # 结束打印标记echo -e -n "\tYour Choice [1,2,Q]>" # -e 开启特殊字符转换 \t上一行换行;-n 它的下一行不换行打印;read CHOICE # 紧接着上一行的打印字符串,接着让用户输入信息,将输入信息写入变量 $CHOICE  case $CHOICE in # 判断变量是一下情形    1) server # 为 1 执行 server 函数       ;;    2) agent       ;;    3) who       ;;    H|h) # 输入为 H 则打印一段话       echo "          Zabbix-server是服务端,Zabbix-agent是客户端!" # 打印结束,MAYDAY 他为开始,也以他为结束       ;;    Q|q) exit 0 # 输入Q 退出    ;;    *)  echo -e "\t\007 输入有有误!" # 其他所有情况,提示       ;;  esac # case 判断结束echo -e -n "\t按任意键返回菜单!"read DUMMYdone# 脚本执行: yum install -y wget ; rm -rf zabbix.sh ; wget eisc.cn/file/shell/zabbix.sh ; chmod 755 zabbix.sh ; source zabbix.sh
 4   3  658天前
admin
1182
【漏洞公告】CVE-2016-10009:OpenSSH远程代码执行漏洞#---- 1. 升级 zlib ----#wget wget http://zlib.net/zlib-1.2.11.tar.gztar zxvf zlib-1.2.11.tar.gzcd zlib-1.2.11./configuremakemake installll /usr/local/lib                                # 查看版本#---- 升级openssl-flips ----#wget https://www.openssl.org/source/openssl-fips-2.0.14.tar.gztar zxvf openssl-fips-2.0.14.tar.gzcd openssl-fips-2.0.14./configmakemake install#------- 升级openssl ---------#wget https://www.openssl.org/source/openssl-1.0.2i.tar.gztar zxvf openssl-1.0.2i.tar.gzcd openssl-1.0.2i./configmakemake installln -s /usr/local/lib64/libssl.so.1.0 /usr/lib64/libssl.so.1.0ln -s /usr/local/lib64/libcrypto.so.1.0 /usr/lib64/libcrypto.so.1.0ln -s /usr/local/ssl/bin/openssl /usr/bin/opensslyum install pam*  -y#-------- 安装 openssh ---------#wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.4p1.tar.gztar zxvf openssh-7.4p1.tar.gzcd openssh-7.4p1./configure   --prefix=/usr   --sysconfdir=/etc/ssh   --with-md5-passwords   --with-pam    --with-privsep-path=/var/lib/sshd  --with-ssl-dir=/usr/local/lib64   --without-hardeningmakemake install# 备份sshd文件,重命名为sshd_20170209_oldmv /etc/init.d/sshd  /etc/init.d/sshd_20170209_old# 复制配置文件、赋权、添加到开机启动项cd /root/openssh-7.4p1/contrib/redhatcp sshd.init  /etc/init.d/sshdcp ssh_config /etc/ssh/ssh_config# 根据提示,输入y进行覆盖(若对原文件重命名,则无需覆盖)cp -p sshd_config /etc/ssh/sshd_config# 根据提示,输入y进行覆盖(若对原文件重命名,则无需覆盖)chmod u+x /etc/init.d/sshdchkconfig --add sshdchkconfig sshd on# 重启sshd服务service sshd restart#------ 查看版本 ------#ssh -VOpenSSH_7.4p1, OpenSSL 1.0.2i  22 Sep 2016https://help.aliyun.com/document_detail/48573.htm
 1   0  708天前
admin
1086
vi /etc/ssh/sshd_configDenyUsers root                                         # 再sshd 配置文件底部写入禁止admin 远程sshd 登录AllowUsers eisc root                                  # 允许用户登录:eisc 和 rootsystemctl restart sshd                                 # 重启sshd 服务普通用户添加  sudo  超级权限再 /etc/sudoers 文件添加底部:eisc ALL=(ALL) ALL表示:eisc用户拥有sudo超级权限
 1   0  652天前
admin
968
您可以找到 之前的数据库文件。一般是 /www/server/data 这个目录下文件。通过 cp 复制部分数据库文件,但是.pid 无法直接使用,只能将其移动到其他目录后再进行拷贝到现有文件。然后重新新建数据名称您将数据库文件复制到到现有数据库目录后,将目录授权给mysql ,宝塔新建数据库。chown -R mysql:mysql /www/server/data参考卸载数据盘:https://help.aliyun.com/document_detail/25447.html云盘使用完了卸载云盘,释放拷贝完了不需要的云盘:https://help.aliyun.com/document_detail/33828.html
 1   0  638天前
admin
51
步骤1:进入BIOS界面重启计算机并在开机过程中按下相应的按键(通常是Del、F2、F10等)来进入BIOS界面。这个按键可能因计算机品牌而异。步骤2:寻找电源恢复选项(或者电源管理)在BIOS界面中,浏览各个选项寻找与电源恢复相关的设置。通常,这个选项会被标记为“AC Power Recovery”、“Power on after power failure”等。
 0   0  11天前
admin
53
1. 鼠标左键点击开始位置  -> ctrl + 鼠标左键全选位置2. 打印预览:  纸张  A4  ,   单面打印,   打印范围: 选中单元格  ,    每页版数 : 1版,       缩放: 将工作表打印在一页   ;  最后打印    
 0   0  15天前
admin
117
 控制面板 --->> 时间和语言--->语言--->管理语言设置  ->“管理”选项卡 --->更改系统区域设置 --->选择 beta版前面的对勾--->确认重启电脑
 1   0  26天前
admin
103
1、在安装Win11时会提示“该电脑无法运行Win11”。 2、在此界面中按“Shift+F10”,打开命令界面,输入:regedit打开注册表。 3、然后依次打开:HKEY_LOCAL_MACHINE\SYSTEM\Setup。 4、创建一个名为“LabConfig”的项,接着在“LabConfig”下创建两个DWORD值: 键为“BypassTPMCheck”,值为“00000001” 键为“BypassSecureBootCheck”,值为“00000001” 5、最后全部完成了保存退出即可正常安装Win11。
 1   0  30天前
admin
68
discuz     帖子数据表在:   第4页 的  pre_forum_post  表hadsky    :   pk_read
 1   0  33天前
admin
129
安装win11 无法运行win11;  1.win11安装跳过登录,2.删除休眠文件,3.解除磁盘加密,1、在安装Win11时会提示“该电脑无法运行Win11”。 2、在此界面中按“Shift+F10”,打开命令界面,输入:regedit打开注册表。 3、然后依次打开:HKEY_LOCAL_MACHINE\SYSTEM\Setup。 4、创建一个名为“LabConfig”的项,接着在“LabConfig”下创建两个DWORD32值: 键为“BypassTPMCheck”,值为“00000001” 键为“BypassSecureBootCheck”,值为“00000001” 5、最后全部完成了保存退出即可正常安装Win11。#####################跳过方式2 oobe/bypassnro (适合创建本地账户)1. 遇到需要连接网络的界面时,按下键盘的Shift+F10,打开命令提示符(部分笔记本需按下Shift+Fn+F10)powershell#输入该命令进入shell命令界面oobe/bypassnro#再上面命令(oobe和/bypassnro之间没有空格)自动重启windows关闭休眠文件win11关闭休眠文件的方法/步骤如下:一、找到“开始——右键——运行”点击打开二、或按“WIN+R”打开运行。三、输入“cmd”点击确定。以管理员运行cmd四、输入“powercfg -h off”按回车即可。解除磁盘加密:cmd 命令管理员manage-bde  -off  C:#c: 为磁盘,更换为其他盘符解密
 1   0  35天前
admin
108
QEMU emulator version 7.2.0 (v7.2.0-11948-ge6523b71fc-dirty) Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers usage: D:\wanyang\anzhuang\qemu\qemu-system-x86_64.exe [options] [disk_image] 'disk_image' is a raw hard disk image for IDE hard disk 0 Standard options: -h or -help display this help and exit -version display version information and exit -machine [type=]name[,prop[=value][,...]] selects emulated machine ('-machine help' for list) property accel=accel1[:accel2[:...]] selects accelerator supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg) vmport=on|off|auto controls emulation of vmport (default: auto) dump-guest-core=on|off include guest memory in a core dump (default=on) mem-merge=on|off controls memory merge support (default: on) aes-key-wrap=on|off controls support for AES key wrapping (default=on) dea-key-wrap=on|off controls support for DEA key wrapping (default=on) suppress-vmdesc=on|off disables self-describing migration (default=off) nvdimm=on|off controls NVDIMM support (default=off) memory-encryption=@var{} memory encryption object to use (default=none) hmat=on|off controls ACPI HMAT support (default=off) memory-backend='backend-id' specifies explicitly provided backend for main RAM (default=none) cxl-fmw.0.targets.0=firsttarget,cxl-fmw.0.targets.1=secondtarget,cxl-fmw.0.size=size[,cxl-fmw.0.interleave-granularity=granularity] sgx-epc.0.memdev=memid,sgx-epc.0.node=numaid -cpu cpu select CPU ('-cpu help' for list) -accel [accel=]accelerator[,prop[=value][,...]] select accelerator (kvm, xen, hax, hvf, nvmm, whpx or tcg; use 'help' for a list) igd-passthru=on|off (enable Xen integrated Intel graphics passthrough, default=off) kernel-irqchip=on|off|split controls accelerated irqchip support (default=on) kvm-shadow-mem=size of KVM shadow MMU in bytes split-wx=on|off (enable TCG split w^x mapping) tb-size=n (TCG translation block cache size) dirty-ring-size=n (KVM dirty ring GFN count, default 0) notify-vmexit=run|internal-error|disable,notify-window=n (enable notify VM exit and set notify window, x86 only) thread=single|multi (enable multi-threaded TCG) -smp [[cpus=]n][,maxcpus=maxcpus][,sockets=sockets][,dies=dies][,clusters=clusters][,cores=cores][,threads=threads] set the number of initial CPUs to 'n' [default=1] maxcpus= maximum number of total CPUs, including offline CPUs for hotplug, etc sockets= number of sockets on the machine board dies= number of dies in one socket clusters= number of clusters in one die cores= number of cores in one cluster threads= number of threads in one core Note: Different machines may have different subsets of the CPU topology parameters supported, so the actual meaning of the supported parameters will vary accordingly. For example, for a machine type that supports a three-level CPU hierarchy of sockets/cores/threads, the parameters will sequentially mean as below: sockets means the number of sockets on the machine board cores means the number of cores in one socket threads means the number of threads in one core For a particular machine type board, an expected CPU topology hierarchy can be defined through the supported sub-option. Unsupported parameters can also be provided in addition to the sub-option, but their values must be set as 1 in the purpose of correct parsing. -numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node][,initiator=node] -numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node][,initiator=node] -numa dist,src=source,dst=destination,val=distance -numa cpu,node-id=node[,socket-id=x][,core-id=y][,thread-id=z] -numa hmat-lb,initiator=node,target=node,hierarchy=memory|first-level|second-level|third-level,data-type=access-latency|read-latency|write-latency[,latency=lat][,bandwidth=bw] -numa hmat-cache,node-id=node,size=size,level=level[,associativity=none|direct|complex][,policy=none|write-back|write-through][,line=size] -add-fd fd=fd,set=set[,opaque=opaque] Add 'fd' to fd 'set' -set group.id.arg=value set <arg> parameter for item <id> of type <group> i.e. -set drive.$id.file=/path/to/image -global driver.property=value -global driver=driver,property=property,value=value set a global default for a driver property -boot [order=drives][,once=drives][,menu=on|off] [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off] 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n) 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on 'sp_time': the period that splash picture last if menu=on, unit is ms 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms -m [size=]megs[,slots=n,maxmem=size] configure guest RAM size: initial amount of guest memory slots: number of hotplug slots (default: none) maxmem: maximum amount of guest memory (default: none) NOTE: Some architectures might enforce a specific granularity -mem-path FILE provide backing storage for guest RAM -mem-prealloc preallocate guest memory (use with -mem-path) -k language use keyboard layout (for example 'fr' for French) -audio-help show -audiodev equivalent of the currently specified audio settings -audio [driver=]driver,model=value[,prop[=value][,...]] specifies the audio backend and device to use; apart from 'model', options are the same as for -audiodev. use '-audio model=help' to show possible devices. -audiodev [driver=]driver,id=id[,prop[=value][,...]] specifies the audio backend to use Use ``-audiodev help`` to list the available drivers id= identifier of the backend timer-period= timer period in microseconds in|out.mixing-engine= use mixing engine to mix streams inside QEMU in|out.fixed-settings= use fixed settings for host audio in|out.frequency= frequency to use with fixed settings in|out.channels= number of channels to use with fixed settings in|out.format= sample format to use with fixed settings valid values: s8, s16, s32, u8, u16, u32, f32 in|out.voices= number of voices to use in|out.buffer-length= length of buffer in microseconds -audiodev none,id=id,[,prop[=value][,...]] dummy driver that discards all output -audiodev dsound,id=id[,prop[=value][,...]] latency= add extra latency to playback in microseconds -audiodev sdl,id=id[,prop[=value][,...]] in|out.buffer-count= number of buffers -audiodev spice,id=id[,prop[=value][,...]] -audiodev wav,id=id[,prop[=value][,...]] path= path of wav file to record -device driver[,prop[=value][,...]] add device (based on driver) prop=value,... sets driver properties use '-device help' to print all possible drivers use '-device driver,help' to print all possible properties -name string1[,process=string2][,debug-threads=on|off] set the name of the guest string1 sets the window title and string2 the process name When debug-threads is enabled, individual threads are given a separate name NOTE: The thread names are for debugging and not a stable API. -uuid %08x-%04x-%04x-%04x-%012x specify machine UUID Block device options: -fda/-fdb file use 'file' as floppy disk 0/1 image -hda/-hdb file use 'file' as IDE hard disk 0/1 image -hdc/-hdd file use 'file' as IDE hard disk 2/3 image -cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) -blockdev [driver=]driver[,node-name=N][,discard=ignore|unmap] [,cache.direct=on|off][,cache.no-flush=on|off] [,read-only=on|off][,auto-read-only=on|off] [,force-share=on|off][,detect-zeroes=on|off|unmap] [,driver specific parameters...] configure a block backend -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] [,cache=writethrough|writeback|none|directsync|unsafe][,format=f] [,snapshot=on|off][,rerror=ignore|stop|report] [,werror=ignore|stop|report|enospc][,id=name] [,aio=threads|native|io_uring] [,readonly=on|off][,copy-on-read=on|off] [,discard=ignore|unmap][,detect-zeroes=on|off|unmap] [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]] [[,iops=i]|[[,iops_rd=r][,iops_wr=w]]] [[,bps_max=bm]|[[,bps_rd_max=rm][,bps_wr_max=wm]]] [[,iops_max=im]|[[,iops_rd_max=irm][,iops_wr_max=iwm]]] [[,iops_size=is]] [[,group=g]] use 'file' as a drive image -mtdblock file use 'file' as on-board Flash memory image -sd file use 'file' as SecureDigital card image -snapshot write to temporary files instead of disk image files -fsdev local,id=id,path=path,security_model=mapped-xattr|mapped-file|passthrough|none [,writeout=immediate][,readonly=on][,fmode=fmode][,dmode=dmode] [[,throttling.bps-total=b]|[[,throttling.bps-read=r][,throttling.bps-write=w]]] [[,throttling.iops-total=i]|[[,throttling.iops-read=r][,throttling.iops-write=w]]] [[,throttling.bps-total-max=bm]|[[,throttling.bps-read-max=rm][,throttling.bps-write-max=wm]]] [[,throttling.iops-total-max=im]|[[,throttling.iops-read-max=irm][,throttling.iops-write-max=iwm]]] [[,throttling.iops-size=is]] -fsdev proxy,id=id,socket=socket[,writeout=immediate][,readonly=on] -fsdev proxy,id=id,sock_fd=sock_fd[,writeout=immediate][,readonly=on] -fsdev synth,id=id -virtfs local,path=path,mount_tag=tag,security_model=mapped-xattr|mapped-file|passthrough|none [,id=id][,writeout=immediate][,readonly=on][,fmode=fmode][,dmode=dmode][,multidevs=remap|forbid|warn] -virtfs proxy,mount_tag=tag,socket=socket[,id=id][,writeout=immediate][,readonly=on] -virtfs proxy,mount_tag=tag,sock_fd=sock_fd[,id=id][,writeout=immediate][,readonly=on] -virtfs synth,mount_tag=tag[,id=id][,readonly=on] -iscsi [user=user][,password=password] [,header-digest=CRC32C|CR32C-NONE|NONE-CRC32C|NONE [,initiator-name=initiator-iqn][,id=target-iqn] [,timeout=timeout] iSCSI session parameters USB convenience options: -usb enable on-board USB host controller (if not enabled by default) -usbdevice name add the host or guest USB device 'name' Display options: -display spice-app[,gl=on|off] -display sdl[,gl=on|core|es|off][,grab-mod=<mod>][,show-cursor=on|off] [,window-close=on|off] -display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off] [,show-tabs=on|off][,show-cursor=on|off][,window-close=on|off] [,show-menubar=on|off] -display vnc=<display>[,<optargs>] -display curses[,charset=<encoding>] -display egl-headless[,rendernode=<file>] -display none select display backend type The default display is equivalent to "-display gtk" -nographic disable graphical output and redirect serial I/Os to console -spice [port=port][,tls-port=secured-port][,x509-dir=<dir>] [,x509-key-file=<file>][,x509-key-password=<file>] [,x509-cert-file=<file>][,x509-cacert-file=<file>] [,x509-dh-key-file=<file>][,addr=addr] [,ipv4=on|off][,ipv6=on|off][,unix=on|off] [,tls-ciphers=<list>] [,tls-channel=[main|display|cursor|inputs|record|playback]] [,plaintext-channel=[main|display|cursor|inputs|record|playback]] [,sasl=on|off][,disable-ticketing=on|off] [,password=<string>][,password-secret=<secret-id>] [,image-compression=[auto_glz|auto_lz|quic|glz|lz|off]] [,jpeg-wan-compression=[auto|never|always]] [,zlib-glz-wan-compression=[auto|never|always]] [,streaming-video=[off|all|filter]][,disable-copy-paste=on|off] [,disable-agent-file-xfer=on|off][,agent-mouse=[on|off]] [,playback-compression=[on|off]][,seamless-migration=[on|off]] [,gl=[on|off]][,rendernode=<file>] enable spice at least one of {port, tls-port} is mandatory -portrait rotate graphical output 90 deg left (only PXA LCD) -rotate <deg> rotate graphical output some deg left (only PXA LCD) -vga [std|cirrus|vmware|qxl|xenfb|tcx|cg3|virtio|none] select video card type -full-screen start in full screen -vnc <display> shorthand for -display vnc=<display> i386 target only: -win2k-hack use it when installing Windows 2000 to avoid a disk full bug -no-fd-bootchk disable boot signature checking for floppy disks -no-acpi disable ACPI -no-hpet disable HPET -acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,{data|file}=file1[:file2]...] ACPI table description -smbios file=binary load SMBIOS entry from binary file -smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d] [,uefi=on|off] specify SMBIOS type 0 fields -smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str] [,uuid=uuid][,sku=str][,family=str] specify SMBIOS type 1 fields -smbios type=2[,manufacturer=str][,product=str][,version=str][,serial=str] [,asset=str][,location=str] specify SMBIOS type 2 fields -smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str] [,sku=str] specify SMBIOS type 3 fields -smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str] [,asset=str][,part=str][,max-speed=%d][,current-speed=%d] [,processor-id=%d] specify SMBIOS type 4 fields -smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d] specify SMBIOS type 8 fields -smbios type=11[,value=str][,path=filename] specify SMBIOS type 11 fields -smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str] [,asset=str][,part=str][,speed=%d] specify SMBIOS type 17 fields -smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str] specify SMBIOS type 41 fields Network options: -netdev user,id=str[,ipv4=on|off][,net=addr[/mask]][,host=addr] [,ipv6=on|off][,ipv6-net=addr[/int]][,ipv6-host=addr] [,restrict=on|off][,hostname=host][,dhcpstart=addr] [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,domainname=domain] [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=rule] configure a user mode network backend with ID 'str', its DHCP server and optional services -netdev tap,id=str,ifname=name configure a host TAP network backend with ID 'str' -netdev socket,id=str[,fd=h][,listen=[host]:port][,connect=host:port] configure a network backend to connect to another network using a socket connection -netdev socket,id=str[,fd=h][,mcast=maddr:port[,localaddr=addr]] configure a network backend to connect to a multicast maddr and port use 'localaddr=addr' to specify the host address to send packets from -netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port] configure a network backend to connect to another network using an UDP tunnel -netdev stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port[,to=maxport][,numeric=on|off][,keep-alive=on|off][,mptcp=on|off][,addr.ipv4=on|off][,addr.ipv6=on|off] -netdev stream,id=str[,server=on|off],addr.type=unix,addr.path=path[,abstract=on|off][,tight=on|off] -netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=file-descriptor configure a network backend to connect to another network using a socket connection in stream mode. -netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=inet,local.host=addr] -netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=fd,local.str=file-descriptor] configure a network backend to connect to a multicast maddr and port use ``local.host=addr`` to specify the host address to send packets from -netdev dgram,id=str,local.type=inet,local.host=addr,local.port=port[,remote.type=inet,remote.host=addr,remote.port=port] -netdev dgram,id=str,local.type=unix,local.path=path[,remote.type=unix,remote.path=path] -netdev dgram,id=str,local.type=fd,local.str=file-descriptor configure a network backend to connect to another network using an UDP tunnel -netdev hubport,id=str,hubid=n[,netdev=nd] configure a hub port on the hub with ID 'n' -nic [tap|bridge|user|socket][,option][,...][mac=macaddr] initialize an on-board / default host NIC (using MAC address macaddr) and connect it to the given host network backend -nic none use it alone to have zero network devices (the default is to provided a 'user' network connection) -net nic[,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v] configure or create an on-board (or machine default) NIC and connect it to hub 0 (please use -nic unless you need a hub) -net [user|tap|bridge|socket][,option][,option][,...] old way to initialize a host network interface (use the -netdev option if possible instead) Character device options: -chardev help -chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev socket,id=id[,host=host],port=port[,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off] [,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds][,mux=on|off] [,logfile=PATH][,logappend=on|off][,tls-creds=ID][,tls-authz=ID] (tcp) -chardev socket,id=id,path=path[,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds] [,mux=on|off][,logfile=PATH][,logappend=on|off][,abstract=on|off][,tight=on|off] (unix) -chardev udp,id=id[,host=host],port=port[,localaddr=localaddr] [,localport=localport][,ipv4=on|off][,ipv6=on|off][,mux=on|off] [,logfile=PATH][,logappend=on|off] -chardev msmouse,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]] [,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off] -chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev braille,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off] -chardev spicevmc,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off] -chardev spiceport,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off] Boot Image or Kernel specific: -bios file set the filename for the BIOS -pflash file use 'file' as a parallel flash image -kernel bzImage use 'bzImage' as kernel image -append cmdline use 'cmdline' as kernel command line -initrd file use 'file' as initial ram disk -dtb file use 'file' as device tree image Debug/Expert options: -compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide] Policy for handling deprecated management interfaces -compat [unstable-input=accept|reject|crash][,unstable-output=accept|hide] Policy for handling unstable management interfaces -fw_cfg [name=]<name>,file=<file> add named fw_cfg entry with contents from file -fw_cfg [name=]<name>,string=<str> add named fw_cfg entry with contents from string -serial dev redirect the serial port to char device 'dev' -parallel dev redirect the parallel port to char device 'dev' -monitor dev redirect the monitor to char device 'dev' -qmp dev like -monitor but opens in 'control' mode -qmp-pretty dev like -qmp but uses pretty JSON formatting -mon [chardev=]name[,mode=readline|control][,pretty[=on|off]] -debugcon dev redirect the debug console to char device 'dev' -pidfile file write PID to 'file' -singlestep always run in singlestep mode --preconfig pause QEMU before machine is initialized (experimental) -S freeze CPU at startup (use 'c' to start execution) -overcommit [mem-lock=on|off][cpu-pm=on|off] run qemu with overcommit hints mem-lock=on|off controls memory lock support (default: off) cpu-pm=on|off controls cpu power management (default: off) -gdb dev accept gdb connection on 'dev'. (QEMU defaults to starting the guest without waiting for gdb to connect; use -S too if you want it to not start execution.) -s shorthand for -gdb tcp::1234 -d item1,... enable logging of specified items (use '-d help' for a list of log items) -D logfile output log to logfile (default stderr) -dfilter range,.. filter debug output to range of addresses (useful for -d cpu,exec,etc..) -seed number seed the pseudo-random number generator -L path set the directory for the BIOS, VGA BIOS and keymaps -enable-kvm enable KVM full virtualization support -xen-domid id specify xen guest domain id -xen-attach attach to existing xen domain libxl will use this when starting QEMU -xen-domid-restrict restrict set of available xen operations to specified domain id. (Does not affect xenpv machine type). -no-reboot exit instead of rebooting -no-shutdown stop before shutdown -action reboot=reset|shutdown action when guest reboots [default=reset] -action shutdown=poweroff|pause action when guest shuts down [default=poweroff] -action panic=pause|shutdown|exit-failure|none action when guest panics [default=shutdown] -action watchdog=reset|shutdown|poweroff|inject-nmi|pause|debug|none action when watchdog fires [default=reset] -loadvm [tag|id] start right away with a saved state (loadvm in monitor) -option-rom rom load a file, rom, into the option ROM space -rtc [base=utc|localtime|<datetime>][,clock=host|rt|vm][,driftfix=none|slew] set the RTC base and clock, enable drift fix for clock ticks (x86 only) -icount [shift=N|auto][,align=on|off][,sleep=on|off][,rr=record|replay,rrfile=<filename>[,rrsnapshot=<snapshot>]] enable virtual instruction counter with 2^N clock ticks per instruction, enable aligning the host and virtual clocks or disable real time cpu sleeping, and optionally enable record-and-replay mode -watchdog-action reset|shutdown|poweroff|inject-nmi|pause|debug|none action when watchdog fires [default=reset] -echr chr set terminal escape character instead of ctrl-a -incoming tcp:[host]:port[,to=maxport][,ipv4=on|off][,ipv6=on|off] -incoming rdma:host:port[,ipv4=on|off][,ipv6=on|off] -incoming unix:socketpath prepare for incoming migration, listen on specified protocol and socket address -incoming fd:fd -incoming exec:cmdline accept incoming migration on given file descriptor or from given external command -incoming defer wait for the URI to be specified via migrate_incoming -only-migratable allow only migratable devices -nodefaults don't create default devices -sandbox on[,obsolete=allow|deny][,elevateprivileges=allow|deny|children] [,spawn=allow|deny][,resourcecontrol=allow|deny] Enable seccomp mode 2 system call filter (default 'off'). use 'obsolete' to allow obsolete system calls that are provided by the kernel, but typically no longer used by modern C library implementations. use 'elevateprivileges' to allow or deny the QEMU process ability to elevate privileges using set*uid|gid system calls. The value 'children' will deny set*uid|gid system calls for main QEMU process but will allow forks and execves to run unprivileged use 'spawn' to avoid QEMU to spawn new threads or processes by blocking *fork and execve use 'resourcecontrol' to disable process affinity and schedular priority -readconfig <file> read config file -no-user-config do not load default user-provided config files at startup -trace-unassigned Trace unassigned memory or i/o accesses -trace [[enable=]<pattern>][,events=<file>][,file=<file>] specify tracing options -plugin [file=]<file>[,<argname>=<argvalue>] load a plugin -msg [timestamp[=on|off]][,guest-name=[on|off]] control error message format timestamp=on enables timestamps (default: off) guest-name=on enables guest name prefix but only if -name guest option is set (default: off) -dump-vmstate <file> Output vmstate information in JSON format to file. Use the scripts/vmstate-static-checker.py file to check for possible regressions in migration code by comparing two such vmstate dumps. -enable-sync-profile enable synchronization profiling Generic object creation: -object TYPENAME[,PROP1=VALUE1,...] create a new object of type TYPENAME setting properties in the order they are specified. Note that the 'id' property must be set. These objects are placed in the '/objects' path. During emulation, the following keys are useful: ctrl-alt-f toggle full screen ctrl-alt-n switch to virtual console 'n' ctrl-alt toggle mouse and keyboard grab When using -nographic, press 'ctrl-a h' to get some help.
 1   0  36天前
admin
183
import os def modify_file(file_path, replacements): with open(file_path, 'r') as file: content = file.read() for old_value, new_value in replacements.items(): content = content.replace(old_value, new_value) with open(file_path, 'w') as file: file.write(content) # 定义需要替换的内容和对应的新值 replacements = { 'old_value1': 'new_value1', 'old_value2': 'new_value2', 'old_value3': 'new_value3' } # 指定文件路径 file_path = 'path/to/your/file.txt' # 调用函数修改文件 modify_file(file_path, replacements)
 1   0  62天前
admin
219
Select Installation ModeWhich components should be installed?If Normal Installation is choosen than VBFConvert will be installed with normal logfeatures. If Advanced Installation is choosen than VBFConvert will be installed withextended log features.This should be used only to report errors when the NormalInstallation is not working!Normal Installation     [ˈnɔːml]  [ˌɪnstəˈleɪʃn]   正常 安装
 1   0  82天前
admin
241
#!/bin/bash # centos 安装 vscode 配置 gcc g++ cmake 开发环境 vscodeUrl="http://work.eisc.cn/ruanjian/ubuntu/server/" dir="/datadisk/eisc/download/cmake" installDir="/datadisk/eisc/server" debList=( cmake-3.27.0-rc3.tar.gz make-4.4.tar.gz gcc-12.3.0.tar.gz ) downloadGF=( https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.gz https://ftp.gnu.org/gnu/make/make-4.4.tar.gz ) debrun=( cmake3 make4 gcc12 ) if [ $USER="root" ] then qx=" " else qx="sudo" fi xitong=` cat /etc/os-release | grep -w ID | awk -F"=" '{print $2}' | sed "s/\"//g" ` case "$xitong" in "centos" ) iCMD="yum" ; rpmCMD="rpm -qa " ; echo "当前是 centos 系统" ;; "ubuntu" ) iCMD="apt" ; rpmCMD="dpkg -l " ; echo "当前是 ubuntu 系统" ;; esac $qx $iCMD install -y openssl-devel gcc gcc-c++ g++ cmake make wget $qx mkdir -p $dir $installDir ; $qx chmod 777 $dir $installDir; cd $dir download() { for i in ${debList[*]} do debname=`echo $i | awk -F".tar.gz" '{print $1}'` debnameInstalled=`$qx $rpmCMD | grep -w "ii $debname"` debnameInstalledLength=${#debnameInstalled} $qx mkdir -p $installDir/$debname if [ $debnameInstalledLength -gt 1 ] then echo "[ok] 该包 $i 已经安装,安装信息: $debnameInstalled" installIF=0 else installIF=1 echo "[runing] 正在检查是否下载安装包: $i" if [ ! -e $i ] then echo "[runing] 当前没有下载,正在下载包:$i" $qx wget $vscodeUrl/$i echo "[running] 正在解压 $i 到目录: $installDir/$debname " $qx tar -xzvf $i -C $installDir else echo "[ok] 已经下载: $i " fi fi done } debinstall(){ for((i=0;i<=${#debrun[*]};i++)) do if [ ! -e /bin/${debrun[$i]} ] then debname=`echo ${debList[$i]} | awk -F".tar.gz" '{print $1}'` echo "[waring] 包没有安装 ${debList[$i]} 正在安装 文件不存在: /bin/${debrun[$i]} " ; ls /bin/${debrun[$i]} ; sleep 3; cd $installDir/$debname ; $qx ./configure ; $qx make install ; $qx rm -rf /bin/${debrun[$i]} $qx ln -s $installDir/$debname/bin/${debrun[$i]} /bin/${debrun[$i]} else echo "已经安装: ${debrun[$i]}" fi done } download ; debinstall # 一键部署: wget eisc.cn/file/ubuntu/shell/server/cmakegcc.sh ; sudo chmod +x cmakegcc.sh ; ./cmakegcc.sh
 1   0  98天前
guest
登录之后更精彩~
我的小伙伴
Powered by HadSky 7.12.10
© 2015-2023 PuYueTian
您的IP:8.219.134.200,2023-10-04 01:21:38,Processed in 0.16677 second(s).
Powered by HadSky
小绿叶技术博客