[新增]添加start.sh脚本中的两个参数(-x屏蔽安装言灵 -s屏蔽安装配置ohmyzsh), 添加下载并执行言灵模块

This commit is contained in:
寻觅(樊旭东) 2024-02-04 17:56:33 +08:00
parent be3bb50a75
commit d52fb0d88d
3 changed files with 77 additions and 3 deletions

54
bin/untar.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/zsh
# 这个脚本可以根据文件 16 进制判断压缩格式,然后通过对应命令解压
# 解压函数:file 接收文件名,cmd 接收命令,opt 参数选项
decompress() {
file=$1
cmd=$2
opt=$3
$cmd $opt $file
}
# 数组:存储支持的压缩格式和对应的文件头和解压命令
# 每个元素的格式为:文件 16 进制头:解压命令:选项
formats=(
377abcaf:7z:x
213c6172:ar:x
425a6839:bunzip2:
504b0304:unzip:
7f454c46:7z:x
1f8b0808:gunzip:
5d000080:unlzma:
1f8b0800:tar:-zxvf
fd377a58:unxz:
)
#判断是否为 tar
filesion=$(file $1 | cut -d':' -f2-)
if [[ "$filesion" == *tar* ]]; then
tar -xvf "$1"
#判断是否为文件
elif [[ -f $1 ]]; then
header=$(xxd -p -l 4 $1)
# 定义一个变量,表示是否找到匹配的格式
found=0
# 遍历数组,匹配文件头和解压命令
for format in $formats; do
# 使用 IFS 分隔数组元素的各个字段
IFS=: read head cmd opt <<< $format
# 如果文件头匹配,调用解压函数,并设置 found 为 1
if [[ $header == $head* ]]; then
decompress $1 $cmd $opt
found=1
break
fi
done
# 如果没有找到匹配的格式,打印提示信息
if [[ $found == 0 ]]; then
echo "无法识别的压缩格式"
fi
else
echo "不是一个文件"
fi

View File

@ -119,6 +119,16 @@ Download_Config() {
Show 2 "寻觅基础环境安装完成"
}
Download_X(){
Show 0 "正在下载配置言灵"
GreyStart
x_dir=$ROOT_INSTALL/x
sudo rm -vrf $x_dir
sudo git clone $ROOT_URL $x_dir || Show 1 "言灵拉去失败"
ColorReset
X_START=1
}
# 选配
Select_Config(){
if Select_Continue "将Zsh设置为默认命令行"; then
@ -132,15 +142,24 @@ Select_Config(){
Show 0 "将在程序结束后启动zsh"
ZSH_START=1
else
Show 2 "zsh未启动, 如需启动请执行: 'zsh' "
Show 2 "zsh未启动, 如需启动请执行: 'zsh' 或 'exec zsh'"
fi
}
Install_Zsh
Download_Config
# 如果携带 -c 则不下载安装ohmyzsh
[[ "$@" == *-c* ]] || Download_Config
# 如果携带 -x 则不下载安装言灵
[[ "$@" == *-x* ]] || Download_X
Select_Config
if [ "$ZSH_START" ]; then
exec zsh
fi
if [ "$X_START" ]; then
zsh $x_dir/安装.zsh
fi

View File

@ -103,7 +103,7 @@ readonly 色彩=(
检查_发行版() {
未知=0
case ${系统_发行版} in
# *arch*) ;;
*arch*) ;;
*Loongnix*);;
*openwrt*)
输出 1 "暂不支持openwrt"
@ -140,3 +140,4 @@ readonly 色彩=(
###############################################################################
输出_主机配置