更新 'bin/func.sh'
方法里面的exit改为return
This commit is contained in:
parent
1343a5b7b7
commit
212dd663d0
27
bin/func.sh
27
bin/func.sh
@ -10,14 +10,14 @@ function get_config() {
|
|||||||
# 判断是否传入空
|
# 判断是否传入空
|
||||||
if [ 'a'$1 == 'a' ] || [ 'a'$2 == 'a' ];then
|
if [ 'a'$1 == 'a' ] || [ 'a'$2 == 'a' ];then
|
||||||
echo '没有传入配置项'
|
echo '没有传入配置项'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# 获取类型
|
# 获取类型
|
||||||
cfg_type=`cat $CONFIG_PATH|grep '\['$1'\]'`
|
cfg_type=`cat $CONFIG_PATH|grep '\['$1'\]'`
|
||||||
cfg_start=`grep '\['$1'\]' $CONFIG_PATH -n|awk -F ':' '{print $1}'`
|
cfg_start=`grep '\['$1'\]' $CONFIG_PATH -n|awk -F ':' '{print $1}'`
|
||||||
if [ 'a'$cfg_type == 'a' ];then
|
if [ 'a'$cfg_type == 'a' ];then
|
||||||
echo '配置['$1']不存在'
|
echo '配置['$1']不存在'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
cfg_data=''
|
cfg_data=''
|
||||||
while read line;do
|
while read line;do
|
||||||
@ -38,9 +38,10 @@ function get_config() {
|
|||||||
|
|
||||||
if [ 'a'$cfg_data == 'a' ];then
|
if [ 'a'$cfg_data == 'a' ];then
|
||||||
echo '配置['$1']里面项'$2'不存在'
|
echo '配置['$1']里面项'$2'不存在'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo $cfg_data
|
echo $cfg_data
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 获取路径文件名
|
# 获取路径文件名
|
||||||
@ -49,6 +50,7 @@ function get_config() {
|
|||||||
function get_path_name() {
|
function get_path_name() {
|
||||||
fun_file_path=$1
|
fun_file_path=$1
|
||||||
echo ${fun_file_path##*/}
|
echo ${fun_file_path##*/}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 获取路径文件夹
|
# 获取路径文件夹
|
||||||
@ -57,6 +59,7 @@ function get_path_name() {
|
|||||||
function get_path_dir() {
|
function get_path_dir() {
|
||||||
fun_file_path=$1
|
fun_file_path=$1
|
||||||
echo ${fun_file_path%/*}
|
echo ${fun_file_path%/*}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 获取路径文件后缀
|
# 获取路径文件后缀
|
||||||
@ -69,6 +72,7 @@ function get_file_suffix() {
|
|||||||
fun_suffix=`echo $1|awk -F '.' '{print $(NF-1)}'`'.'`echo $1|awk -F '.' '{print $NF}'`
|
fun_suffix=`echo $1|awk -F '.' '{print $(NF-1)}'`'.'`echo $1|awk -F '.' '{print $NF}'`
|
||||||
fi
|
fi
|
||||||
echo $fun_suffix
|
echo $fun_suffix
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 获取路径文件的文件夹
|
# 获取路径文件的文件夹
|
||||||
@ -79,6 +83,7 @@ function get_file_dir() {
|
|||||||
fun_suffix=`get_file_suffix $1`
|
fun_suffix=`get_file_suffix $1`
|
||||||
fun_file_dir=`echo $1|awk -F $fun_suffix '{print $1}'`
|
fun_file_dir=`echo $1|awk -F $fun_suffix '{print $1}'`
|
||||||
echo ${fun_file_dir%*.}
|
echo ${fun_file_dir%*.}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 解压文件
|
# 解压文件
|
||||||
@ -87,12 +92,12 @@ function decompression() {
|
|||||||
# 判断是否传入空
|
# 判断是否传入空
|
||||||
if [ 'a'$1 == 'a' ];then
|
if [ 'a'$1 == 'a' ];then
|
||||||
echo '没有传入压缩包地址'
|
echo '没有传入压缩包地址'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# 判断文件是否存在
|
# 判断文件是否存在
|
||||||
if [ ! -f $1 ];then
|
if [ ! -f $1 ];then
|
||||||
echo $1'文件不存在'
|
echo $1'文件不存在'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# 删除原解压
|
# 删除原解压
|
||||||
zip_file_dir=`get_file_dir $1`
|
zip_file_dir=`get_file_dir $1`
|
||||||
@ -108,8 +113,9 @@ function decompression() {
|
|||||||
unzip $zip_path_name
|
unzip $zip_path_name
|
||||||
else
|
else
|
||||||
echo $zip_suffix'格式的压缩文件无法解压'
|
echo $zip_suffix'格式的压缩文件无法解压'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 存在http且下载
|
# 存在http且下载
|
||||||
@ -124,10 +130,11 @@ function exists_download() {
|
|||||||
wget -P $PWD'/package' $1
|
wget -P $PWD'/package' $1
|
||||||
if [ $? != 0 ];then
|
if [ $? != 0 ];then
|
||||||
echo $1'下载失败'
|
echo $1'下载失败'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo $PWD'/package/'$down_path_name
|
echo $PWD'/package/'$down_path_name
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 修改文件
|
# 修改文件
|
||||||
@ -138,7 +145,7 @@ function update_file() {
|
|||||||
update_name=$3
|
update_name=$3
|
||||||
if [ ! -f $update_file_url ];then
|
if [ ! -f $update_file_url ];then
|
||||||
echo $update_file_url'文件不存在'
|
echo $update_file_url'文件不存在'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# 文件备份
|
# 文件备份
|
||||||
if [ ! -f $update_file_url'.bak' ];then
|
if [ ! -f $update_file_url'.bak' ];then
|
||||||
@ -158,6 +165,7 @@ function update_file() {
|
|||||||
done < $update_file_url'.tmp'
|
done < $update_file_url'.tmp'
|
||||||
IFS=$SAVEIFS
|
IFS=$SAVEIFS
|
||||||
rm -rf $update_file_url'.tmp'
|
rm -rf $update_file_url'.tmp'
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 追加文件
|
# 追加文件
|
||||||
@ -167,9 +175,10 @@ function append_file() {
|
|||||||
append_name=$2
|
append_name=$2
|
||||||
if [ ! -f $append_file_url ];then
|
if [ ! -f $append_file_url ];then
|
||||||
echo $append_file_url'文件不存在'
|
echo $append_file_url'文件不存在'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ `cat $append_file_url|grep "$append_name"|wc -l` == 0 ];then
|
if [ `cat $append_file_url|grep "$append_name"|wc -l` == 0 ];then
|
||||||
echo "$append_name" >> $append_file_url
|
echo "$append_name" >> $append_file_url
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user