centos 安装 Emscripten

centos 安装 Emscripten
Rust 是一种系统级编程语言,旨在提供高性能和内存安全,同时避免常见的编程错误。
由 Mozilla Research 推出,Rust 自推出以来因其独特的设计理念和强大的功能而在开发者社区中迅速获得了广泛的关注和采用。
安装命令:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
分解说明:
curl:这是一个用于在命令行下传输数据的工具,支持多种协议(如 HTTP、HTTPS、FTP 等)。
--proto '=https':指定只允许使用 HTTPS 协议进行传输,确保数据传输的安全性。
--tlsv1.2:强制 curl 使用 TLS 1.2 协议,这是一种安全的传输层协议。
-s:静默模式(silent),在执行过程中不会显示进度条或错误信息。
-Sf:
-S:当使用 -s(静默模式)时,-S 可以让 curl 在发生错误时仍然显示错误信息。
-f:如果服务器返回一个错误状态码(如 404),curl 会失败并返回一个错误,而不是输出错误页面的内容。
https://sh.rustup.rs:这是 Rust 官方提供的安装脚本的 URL。
| sh:管道符号(|)将前一个命令(curl)的输出传递给后一个命令(sh)。也就是说,下载的安装脚本将直接由 sh(shell)执行。
整体作用:
这个命令通过安全的 HTTPS 连接下载 Rust 的安装脚本,并立即在您的终端中执行该脚本,以便安装 Rust 编程语言及其工具链。
输出解释
- info: downloading installer
- Welcome to Rust!
- This will download and install the official compiler for the Rust
- programming language, and its package manager, Cargo.
- Rustup metadata and toolchains will be installed into the Rustup
- home directory, located at:
- /home/jjmczd/.rustup
- This can be modified with the RUSTUP_HOME environment variable.
- The Cargo home directory is located at:
- /home/jjmczd/.cargo
- This can be modified with the CARGO_HOME environment variable.
- The cargo, rustc, rustup and other commands will be added to
- Cargo's bin directory, located at:
- /home/jjmczd/.cargo/bin
- This path will then be added to your PATH environment variable by
- modifying the profile files located at:
- /home/jjmczd/.profile
- /home/jjmczd/.bashrc
- You can uninstall at any time with rustup self uninstall and
- these changes will be reverted.
- Current installation options:
- default host triple: x86_64-unknown-linux-gnu
- default toolchain: stable (default)
- profile: default
- modify PATH variable: yes
- 1) Proceed with standard installation (default - just press enter)
- 2) Customize installation
- 3) Cancel installation
逐行解释:
info: downloading installer
解释:安装程序正在下载过程中。
Welcome to Rust!
解释:欢迎使用 Rust!
接下来的几行
解释:这些行说明了安装过程将会下载和安装 Rust 官方编译器(rustc)以及其包管理器(Cargo)。
Rustup metadata and toolchains will be installed into the Rustup home directory, located at:
解释:Rustup 的元数据和工具链将被安装到指定的 Rustup 主目录中,默认路径为 /home/jjmczd/.rustup。您可以通过设置 RUSTUP_HOME 环境变量来修改此路径。
The Cargo home directory is located at:
解释:Cargo 的主目录位于 /home/jjmczd/.cargo。同样,您可以通过设置 CARGO_HOME 环境变量来修改此路径。
The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at:
解释:cargo、rustc、rustup 以及其他相关命令将被添加到 Cargo 的 bin 目录中,即 /home/jjmczd/.cargo/bin。
This path will then be added to your PATH environment variable by modifying the profile files located at:
解释:安装程序会将上述 bin 目录路径添加到您的 PATH 环境变量中,这通过修改您的 shell 配置文件(如 /home/jjmczd/.profile 和 /home/jjmczd/.bashrc)来实现。这样,您可以在任何终端会话中直接运行 Rust 的命令。
You can uninstall at any time with rustup self uninstall and these changes will be reverted.
解释:如果您在任何时候想要卸载 Rust,可以运行 rustup self uninstall 命令,这将撤销所有安装的更改。
Current installation options:
解释:当前的安装选项如下:
default host triple: x86_64-unknown-linux-gnu
解释:默认的主机三元组(host triple)是 x86_64-unknown-linux-gnu,表示安装的是适用于 64 位 Linux 系统的 Rust 工具链。
default toolchain: stable (default)
解释:默认的工具链是 stable 版本,这是 Rust 的稳定版本,适合大多数用户和生产环境使用。
profile: default
解释:使用的是默认的安装配置文件,包含基本的组件和设置。
modify PATH variable: yes
解释:安装程序将修改您的 PATH 环境变量,以便您可以在终端中直接使用 Rust 的命令。
安装选项菜单:
- 1) Proceed with standard installation (default - just press enter)
- 2) Customize installation
- 3) Cancel installation
- rustc --version
- cargo --version
- rustup update
- [root@localhost brotli-compress-vue-component]# wasm-pack build --target web --out-name compress --out-dir pkg
SHELL 脚本删除文件或目录

使用SHELL脚本,删除指定文件或目录,
使用方法:bash /sh/delfiles.sh 11.txt 22.txt
- #!/bin/bash
- # 检查是否有参数传入
- if [ "$#" -eq 0 ]; then
- echo "[ERROR] No files to delete! At least one parameter is required! "
- exit 1
- fi
- # 打印脚本名称
- echo "Script Name: $0"
- # 打印脚本所在的目录
- echo "Script Directory: $(dirname $0)"
- # 打印当前工作目录
- echo "Working Directory: $PWD"
- # 进入当前工作目录
- cd $PWD
- echo "=================================================="
- # 循环遍历所有参数并删除文件
- for file in "$@"; do
- if [ -f "$file" ]; then
- rm "$file"
- echo "Deleted file ==> ./$file"
- elif [ -d "$file" ]; then
- rm -rf "$file"
- echo "Deleted directory ==> ./$file"
- else
- echo "File or directory does not exist: $file"
- fi
- done
- echo "=================================================="
发布专属环境SHELL脚本

- #ifconfig
- echo $projectPath
- echo $developer
- echo $rebuildBranch
- ### 获取最后一层的项目名称
- las_dir=$(basename "$projectPath")
- ### 提取上一层目录的全路径
- cur_dir=$(dirname $projectPath)
- ### 获取业务线的名称第二层
- pat_dir=$(basename "$cur_dir")
- echo $las_dir
- echo $cur_dir
- echo $pat_dir
- ### 通用前端发布脚本( 从本地同步来取 dist.tar.gz 文件包 ) ###
- wwwroot=/data/apps/nginx/htdocs/public/frontend$projectPath &&
- cd $wwwroot && pwd && git fetch && git checkout dev-$developer &&
- git pull origin dev-$developer &&
- bash /sh/downdist.sh /data/apps/nginx/htdocs/public/frontend$projectPath/upload/dynamicAssets.json /data/apps/nginx/htdocs/public/tarfile/XXX/$developer$projectPath http://dl.ktm1234.com/XXX/$developer$projectPath
- ### 通用前端发布脚本( 从本地同步来取 dist.tar.gz 文件包 ) ###
- wwwroot=/data/apps/nginx/htdocs/public/frontend$projectPath &&
- cd $wwwroot && pwd
- if [[ $rebuildBranch == true ]] ;then
- echo '---- 全新构建分支 ------'
- git checkout . && git checkout master &&
- git branch -D dev-$developer && git fetch &&
- git checkout -b dev-$developer origin/dev-$developer &&
- bash /sh/downdist.sh /data/apps/nginx/htdocs/public/frontend$projectPath/upload/dynamicAssets.json /data/apps/nginx/htdocs/public/tarfile/XXX/$developer$projectPath http://dl.ktm1234.com/XXX/$developer$projectPath
- else
- echo '---- 更新新版本 ------'
- git fetch && git checkout dev-$developer &&
- git checkout . && git pull origin dev-$developer &&
- bash /sh/downdist.sh /data/apps/nginx/htdocs/public/frontend$projectPath/upload/dynamicAssets.json /data/apps/nginx/htdocs/public/tarfile/XXX/$developer$projectPath http://dl.ktm1234.com/XXX/$developer$projectPath
- fi
shell(bash)替换字符串大全

1. 替换(只替换一个)
- $ var="AAAszip_BBB.zip";var2=${var/zip/ZIP};echo $var2};
- AAAsZIP_BBB.zip
- $ var="AAAszip_BBB.zip";var2=${var/.zip/.ZIP};echo $var2;
- AAAszip_BBB.ZIP
2. 替换(替换所有)
- $ var="AAAszip_BBB.zip";var2=${var//zip/ZIP};echo $var2;
- AAAsZIP_BBB.ZIP
3. 替换(替换开头一个)
- $ var=".zipAAAszip_BBB.zip_CCC";var2=${var/#.zip/.ZIP};echo $var2;
- .ZIPAAAszip_BBB.zip_CCC
4. 替换(替换结尾一个)
- $ var="AAAszip_BBB.zip_CCC.zip";var2=${var/%.zip/.ZIP};echo $var2;
- AAAszip_BBB.zip_CCC.ZIP
5. 截取,删除右边,保留左边,从右起最短匹配
- $ a="aaa=bbb";b=${a%=*};echo $b
- aaa
- $ a="http://localhost:3000/china/shanghai.html";b=${a%/*};echo $b
- http://localhost:3000/china
6. 截取,删除右边,保留左边,从右起最长匹配
- $ a="http://localhost:3000/china/shanghai.html";b=${a%%/*};echo $b
- http:
7. 截取,删除左边,保留右边,从左起最短匹配
- $ a="aaa=bbb";b=${a#*=};echo $b
- bbb
- $ a="http://localhost:3000/china/shanghai.html";b=${a#*/};echo $b
- /localhost:3000/china/shanghai.html
8. 截取,删除左边,保留右边,从左起最长匹配
- $ a="http://localhost:3000/china/shanghai.html";b=${a##*/};echo $b
- shanghai.html
SHELL替换字符串内容

- //http://dl.ktm1234.com/injured/work-litigation/
- //http://dl.ktm1234.com/XXX/jiaye/injured/work-litigation/
- var="http://dl.ktm1234.com/injured/work-litigation/";var2=${var//com/com\/XXX\/jiaye};echo $var2;
结果:http://dl.ktm1234.com/XXX/jiaye/injured/work-litigation/
Linux shell命令 批量删除子目录下的文件,保留指定数量的最新文件

- #!/bin/bash
- #保留文件数
- ReservedNum=2
- #要删除文件的,父级目录
- FileDir=/usr/docker/springCloud/project/
- #循环子目录列表
- for element in `ls $FileDir`
- do
- # 拼接成完成目录 (父目录路径/子目录名)
- dir_or_file=$FileDir$element
- # 获取子目录下的指定文件格式的总数量
- FileNum=$(ls -l $dir_or_file | grep 'keda-' |wc -l)
- # 输出 删除前的 指定格式的文件数量
- echo $element "jar num:" $FileNum
- # 如果 数量大于保留数量,那就循环删除 文件
- while(( $FileNum > $ReservedNum))
- do
- OldFile=$(ls -rt $dir_or_file | grep 'keda-'| head -1)
- echo $element "Delete jar:"$OldFile
- rm -rf $dir_or_file/$OldFile
- let "FileNum--"
- done
- done
- # 删除完后,再循环输出一下 每个子目录下的文件数量
- for element in `ls $FileDir`
- do
- dir_or_file=$FileDir$element
- FileNum=$(ls -l $dir_or_file | grep 'keda-' |wc -l)
- echo $element "jar num:" $FileNum
- done
SHELL 获取目录
- ### 提取目录中的名称
- las_dir=$(basename "$PWD")
- cur_dir=$(dirname $(pwd))
- lat_dir=$(basename "$cur_dir")
docker容器备份成镜像结合定时器自动执行

- ### 把docker容器提交成新的镜像
- cd /data/backup
- ### 备份Jenkins容器
- docker commit -a "Jesse Liu" -m "v20230602" jenkins-rsync-v2 jenkins-rsync:v2b
- docker save -o jenkins-rsync-v2b.tar jenkins-rsync:v2b
- ### 备份Nginx容器
- docker commit -a "Jesse Liu" -m "v20230602" nginx-nodejs-redis-v2 nginx-nodejs-redis:v2b
- docker save -o nginx-nodejs-redis-v2b.tar nginx-nodejs-redis:v2b
- docker commit -a "Jesse Liu" -m "v20230602" jenkins-rsync-v2 jenkins-rsync:v2b
- docker save -o jenkins-rsync-v2b.tar jenkins-rsync:v2b
- docker commit -a "Jesse Liu" -m "v20230602" nginx-nodejs-redis-v2 nginx-nodejs-redis:v2b
- docker save -o nginx-nodejs-redis-v2b.tar nginx-nodejs-redis:v2b
- ### SHELL脚本依次压缩导出tgz文件
- cd /data/backup &&
- rm -rf jenkins-rsync-v2b.tgz &&
- rm -rf nginx-nodejs-redis-v2b.tgz &&
- docker rmi jenkins-rsync:v2b &&
- docker rmi nginx-nodejs-redis:v2b &&
- docker commit -a "Jesse Liu" -m "v20230602" jenkins-rsync-v2 jenkins-rsync:v2b &&
- docker image save jenkins-rsync:v2b > jenkins-rsync-v2b.tgz &&
- docker commit -a "Jesse Liu" -m "v20230602" nginx-nodejs-redis-v2 nginx-nodejs-redis:v2b &&
- docker image save nginx-nodejs-redis:v2b > nginx-nodejs-redis-v2b.tgz
- ### SHELL脚本依次解压导入docker镜像
- docker image load -i jenkins-rsync-v2b.tgz
- docker image load -i nginx-nodejs-redis-v2b.tgz
- ### 编辑和查看定时器配置
- crontab -e
- crontab -l
- 每星期六的晚上11 : 00 pm重启smb
- 0 23 * * 6 /etc/init.d/smb restart
- 每天的0:30重启smb
- 30 0 * * * /etc/init.d/smb restart
- 30 0 * * * root /sh/docker-backup.sh
- 一分钟执行一次
- */1 * * * * root /sh/test.sh
- */1 * * * * root /sh/test.sh
- ### 重启定时器服务
- chmod 755 /sh/test.sh
- chmod 755 /sh/docker-backup.sh
- chmod 755 /sh/scp-docker.sh
- systemctl restart crond
### 本地机器生成密钥