diff --git a/codes/linux/soft/README.md b/codes/linux/soft/README.md index 56deb72..4ba17d8 100644 --- a/codes/linux/soft/README.md +++ b/codes/linux/soft/README.md @@ -233,3 +233,14 @@ wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fa curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/docker-install.sh | bash wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/docker-install.sh | bash ``` + +## FastDFS 安装 + +说明: + +使用方法:执行以下任意命令即可执行脚本。 + +```sh +curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fastdfs-install.sh | bash +wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/fastdfs-install.sh | bash +``` diff --git a/codes/linux/soft/fastdfs-install.sh b/codes/linux/soft/fastdfs-install.sh index 4ac701b..0ad79b4 100644 --- a/codes/linux/soft/fastdfs-install.sh +++ b/codes/linux/soft/fastdfs-install.sh @@ -47,7 +47,7 @@ nginx_version=1.16.0 nginx_path=/opt/nginx printf "${GREEN}>>>>>>>> install required libs.${RESET}\n\n" -yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y +yum install -y git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim unzip # download and decompression mkdir -p ${path} @@ -95,6 +95,7 @@ make && make install printf "${GREEN}>>>>>>>>> fastdfs 配置文件准备${RESET}\n" # 配置修改参考:https://github.com/happyfish100/fastdfs/wiki +mkdir -p /etc/fdfs cp ${path}/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用 cp ${path}/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用 cp ${path}/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs diff --git a/codes/shell/demos/variable-demo.sh b/codes/shell/demos/variable-demo.sh index c7acaa1..3cb6fdf 100644 --- a/codes/shell/demos/variable-demo.sh +++ b/codes/shell/demos/variable-demo.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash ################### 声明变量 ################### -word="hello" -echo ${word} +name="world" +echo "hello ${name}" # Output: hello ################### 只读变量 ################### diff --git a/codes/shell/示例脚本/变量/变量基本使用.sh b/codes/shell/示例脚本/变量/变量基本使用.sh new file mode 100644 index 0000000..22c6877 --- /dev/null +++ b/codes/shell/示例脚本/变量/变量基本使用.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +################### 声明变量 ################### +name="world" +echo "hello ${name}" +# Output: hello world + +################### 只读变量 ################### +readonly_var="hello" +echo ${readonly_var} +# Output: hello +readonly readonly_var +# rword="bye" # 如果放开注释,执行时会报错 + +################### 删除变量 ################### +dword="hello" # 声明变量 +echo ${dword} # 输出变量值 +# Output: hello + +unset dword # 删除变量 +echo ${dword} +# Output: (空) diff --git a/codes/shell/示例脚本/变量/将输出结果赋值给变量.sh b/codes/shell/示例脚本/变量/将输出结果赋值给变量.sh new file mode 100644 index 0000000..b935859 --- /dev/null +++ b/codes/shell/示例脚本/变量/将输出结果赋值给变量.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +folder=$(pwd) +echo "current path: ${folder}" diff --git a/codes/shell/示例脚本/变量/系统变量.sh b/codes/shell/示例脚本/变量/系统变量.sh new file mode 100644 index 0000000..3c9bb1c --- /dev/null +++ b/codes/shell/示例脚本/变量/系统变量.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "User info fro userId:$USER" +echo UID:$UID +echo HOME:$HOME diff --git a/codes/shell/示例脚本/基本脚本/使用自定义变量.sh b/codes/shell/示例脚本/变量/自定义变量.sh similarity index 79% rename from codes/shell/示例脚本/基本脚本/使用自定义变量.sh rename to codes/shell/示例脚本/变量/自定义变量.sh index 5dd633d..854b16d 100644 --- a/codes/shell/示例脚本/基本脚本/使用自定义变量.sh +++ b/codes/shell/示例脚本/变量/自定义变量.sh @@ -1,5 +1,4 @@ -#!/bin/bash -#testing variables +#!/usr/bin/env bash days=10 guest="Katie" diff --git a/codes/shell/示例脚本/字符串/字符串分割成数组.sh b/codes/shell/示例脚本/字符串/字符串分割成数组.sh new file mode 100644 index 0000000..5f770fa --- /dev/null +++ b/codes/shell/示例脚本/字符串/字符串分割成数组.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# ---------------------------------------------------------------------------------- +# 根据特定字符将一个字符串分割成数组 +# ---------------------------------------------------------------------------------- + +str="0.0.0.1" +OLD_IFS="$IFS" +IFS="." +array=(${str}) +IFS="$OLD_IFS" +size=${#array[*]} +lastIndex=`expr ${size} - 1` +echo "数组长度:${size}" +echo "最后一个数组元素:${array[${lastIndex}]}" +for item in ${array[@]} +do + echo "$item" +done diff --git a/codes/shell/示例脚本/字符串/字符串基本使用.sh b/codes/shell/示例脚本/字符串/字符串基本使用.sh new file mode 100644 index 0000000..9401876 --- /dev/null +++ b/codes/shell/示例脚本/字符串/字符串基本使用.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +################### 单引号和双引号 ################### +################### 拼接字符串 ################### +# 使用单引号拼接 +name1='white' +str1='hello, '${name1}'' +str2='hello, ${name1}' +echo ${str1}_${str2} +# Output: +# hello, white_hello, ${name1} + +# 使用双引号拼接 +name2="black" +str3="hello, "${name2}"" +str4="hello, ${name2}" +echo ${str3}_${str4} +# Output: +# hello, black_hello, black + +################### 获取字符串长度 ################### +text="12345" +echo "${text} length is: ${#text}" +# Output: +# 12345 length is: 5 + +################### 获取字符串长度 ################### +text="12345" +echo ${text:2:2} +# Output: +# 34 + +################### 查找子字符串 ################### +text="hello" +echo `expr index "${text}" ll` +# Output: +# 3 + +################### 截取关键字左边内容 ################### +full_branch="feature/1.0.0" +branch=`echo ${full_branch#feature/}` +echo "branch is ${branch}" + +################### 截取关键字右边内容 ################### +full_version="0.0.1-SNAPSHOT" +version=`echo ${full_version%-SNAPSHOT}` +echo "version is ${version}" + +################### 判断字符串中是否包含子字符串 ################### +result=$(echo "${str}" | grep "feature/") +if [[ "$result" != "" ]] ; then + echo "feature/ 是 ${str} 的子字符串" +else + echo "feature/ 不是 ${str} 的子字符串" +fi diff --git a/codes/shell/示例脚本/数组/数组基本使用.sh b/codes/shell/示例脚本/数组/数组基本使用.sh new file mode 100644 index 0000000..65ff2ef --- /dev/null +++ b/codes/shell/示例脚本/数组/数组基本使用.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# 创建数组 +nums=([2]=2 [0]=0 [1]=1) +colors=(red yellow "dark blue") + +# 访问数组的单个元素 +echo ${nums[1]} +# Output: 1 + +# 访问数组的所有元素 +echo ${colors[*]} +# Output: red yellow dark blue + +echo ${colors[@]} +# Output: red yellow dark blue + +printf "+ %s\n" ${colors[*]} +# Output: +# + red +# + yellow +# + dark +# + blue + +printf "+ %s\n" "${colors[*]}" +# Output: +# + red yellow dark blue + +printf "+ %s\n" "${colors[@]}" +# Output: +# + red +# + yellow +# + dark blue + +# 访问数组的部分元素 +echo ${nums[@]:0:2} +# Output: +# 0 1 + +# 访问数组长度 +echo ${#nums[*]} +# Output: +# 3 + +# 向数组中添加元素 +colors=(white "${colors[@]}" green black) +echo ${colors[@]} +# Output: +# white red yellow dark blue green black + +# 从数组中删除元素 +unset nums[0] +echo ${nums[@]} +# Output: +# 1 2