From 6b8fe4cc46547de537ba61f9bbc361e6fc74847f Mon Sep 17 00:00:00 2001 From: xunmi-pc <寻觅> Date: Tue, 20 Feb 2024 17:52:10 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=20=E6=B7=BB=E5=8A=A0aosc?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=9A=84=E6=94=AF=E6=8C=81,=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0oma=E5=8C=85=E7=AE=A1=E7=90=86=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81,=E4=BC=98=E5=8C=96=E5=9F=BA=E7=A1=80=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.sh | 57 ++++++++++++++------------------------------------- 公共/包管.zsh | 15 +++++++++----- 安装.zsh | 28 +++++++++++++++++-------- 3 files changed, 44 insertions(+), 56 deletions(-) diff --git a/start.sh b/start.sh index 1b54500..1c8892a 100755 --- a/start.sh +++ b/start.sh @@ -49,22 +49,13 @@ ColorReset() { # 函数 # ############################################################################### -# 选择判断器 -Select_Continue() { - Show 3 "$1((是/否 Yes/No))" - read r - if echo "$r" | grep -Eq "^[是Yy][Ee]?[Ss]?$";then - return 0 - else - return 1 - fi -} - # 更新包管理器 Update_Package_Resource() { Show 2 "更新包管理器..." GreyStart - if [ -x "$(command -v apt)" ]; then + if [ -x "$(command -v oma)" ]; then + sudo oma refresh + elif [ -x "$(command -v apt)" ]; then sudo apt-get update -qq elif [ -x "$(command -v yum)" ]; then sudo yum update @@ -80,14 +71,14 @@ Install_Zsh() { pack=${PACK_LIST[i]} Show 2 "安装必要的依赖项: ${aCOLOUR[4]} $pack $COLOUR_RESET" GreyStart - if [ -x "$(command -v apt)" ]; then + if [ -x "$(command -v oma)" ]; then + sudo oma -y install $pack + elif [ -x "$(command -v apt)" ]; then sudo apt -y install $pack elif [ -x "$(command -v yum)" ]; then sudo yum install -y $pack - elif [ -x "$(command -v pacman)" ]; then - sudo pacman -Sy --needed $pack - #elif [ -x "$(command -v paru)" ]; then - # paru -S zsh + elif [ -x "$(command -v pacman)" ]; then + sudo pacman -Sy --needed $pack else Show 1 "未找到包管理器, 您需要手动安装: ${aCOLOUR[5]} $pack $COLOUR_RESET" fi @@ -112,7 +103,8 @@ Download_Config() { config_url=${ROOT_URL}raw/配置/zshrc sudo wget -t 3 -q --show-progress -c "${config_url}" || Show 1 "无法下载预设配置( ${config_url} )" sudo sed -i "s:export ZSH=/etc/oh-my-zsh:export ZSH=$ohmyzsh_dir:" zshrc - sudo mv zshrc /etc/skel/.zshrc + sudo echo "export 寻觅=${ROOT_INSTALL}" | cat - zshrc > .zshrc + sudo mv .zshrc /etc/skel/.zshrc cp -v /etc/skel/.zshrc $HOME cd $HOME ColorReset @@ -120,7 +112,7 @@ Download_Config() { } Download_X(){ - Show 0 "正在下载配置言灵" + Show 0 "开始下载配置言灵" GreyStart x_dir=$ROOT_INSTALL/x sudo rm -vrf $x_dir @@ -129,33 +121,14 @@ Download_X(){ X_START=1 } -# 选配 -Select_Config(){ - if Select_Continue "将Zsh设置为默认命令行"; then - chsh -s /usr/bin/zsh - Show 0 "已将zsh设置为默认命令行" - else - Show 2 "如需将zsh设置为默认命令行请执行: 'chsh -s /usr/bin/zsh' " - fi - - if Select_Continue "启动zsh"; then - Show 0 "将在程序结束后启动zsh" - ZSH_START=1 - else - Show 2 "zsh未启动, 如需启动请执行: 'zsh' 或 'exec zsh'" - fi - -} - - +################################################################# +# 主函数(main) # +################################################################# Install_Zsh # 如果携带 -c 则不下载安装ohmyzsh [[ "$@" == *-c* ]] || Download_Config # 如果携带 -x 则不下载安装言灵 [[ "$@" == *-x* ]] || Download_X -Select_Config - -(( $ZSH_START == 1 )) && exec zsh (( $X_START == 1 )) && zsh $x_dir/安装.zsh - +exec zsh diff --git a/公共/包管.zsh b/公共/包管.zsh index 73736ac..bed6f63 100644 --- a/公共/包管.zsh +++ b/公共/包管.zsh @@ -16,10 +16,13 @@ # 参数 [ -y -确认 ] 跳过包管理器更新时的二次确认 # 实例 `包管_更新 -n`; `包管_更新 -确认` 包管_更新() { - if [ -x "$(command -v apt)" ]; then - sudo apt-get update -qq - elif [ -x "$(command -v yum)" ]; then - sudo yum update + if [ -x "$(command -v oma)" ]; then +# sudo oma refresh + sudo oma update -y + elif [ -x "$(command -v apt)" ]; then + sudo apt-get update -qq + elif [ -x "$(command -v yum)" ]; then + sudo yum update elif [ -x "$(command -v pacman)"]; then sudo pacman -Syu fi @@ -27,7 +30,9 @@ # 调用当前包管理器的安装模块 包管_安装(){ - if [ -x "$(command -v apt)" ]; then + if [ -x "$(command -v oma)" ]; then + sudo oma -y install $1 + elif [ -x "$(command -v apt)" ]; then sudo apt -y install $1 elif [ -x "$(command -v yum)" ]; then sudo yum install -y $1 diff --git a/安装.zsh b/安装.zsh index 6344da4..82d6afc 100755 --- a/安装.zsh +++ b/安装.zsh @@ -5,9 +5,6 @@ export PATH=/usr/sbin:$PATH export DEBIAN_FRONTEND=noninteractive # 加载系统配置 source /etc/os-release -# 加载公共函数 -. 公共/函数.zsh -. 公共/包管.zsh # 脚本在执行过程中遇到任何非零返回码的命令时立即退出 set -e @@ -65,8 +62,9 @@ readonly 系统_发行版_名称=$(echo "${NAME}") 未知=0 case ${系统_发行版} in *arch*) ;; - *Loongnix*);; - *openwrt*) + *Loongnix*) ;; + *aosc*) ;; + *openwrt*) 输出 1 "暂不支持openwrt" exit 1 ;; @@ -125,8 +123,18 @@ readonly 系统_发行版_名称=$(echo "${NAME}") done } +选配(){ + if 是否 "将Zsh设置为默认命令行"; then + chsh -s /usr/bin/zsh + 输出 0 "已将zsh设置为默认命令行,此设置主要适用于ssh和tty,如终端不生效则需要在可视化设置中手动配置启动时加载 '/usr/bin/zsh' " + else + 输出 2 "如需将zsh设置为默认命令行请执行: 'chsh -s /usr/bin/zsh' " + fi +} + + ############################################################################### -# 入口(main) # +# 主函数(main) # ############################################################################### echo " @@ -134,8 +142,10 @@ echo " * 欢迎使用 言灵 配置脚本 * *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* " -(( ${言灵_函数} == 1 )) && 输出 0 "公共函数模块初始化完成" || exit 1 -(( ${言灵_包管} == 1 )) && 输出 0 "包管理器模块初始化完成" || exit 2 + +# 先检查相关 +[[ ${言灵_函数} == 1 ]] || . 公共/函数.zsh || exit 1 && 输出 0 "公共函数模块初始化完成" +[[ ${言灵_包管} == 1 ]] || . 公共/包管.zsh || exit 2 && 输出 0 "包管理器模块初始化完成" 配置检测 @@ -146,4 +156,4 @@ echo " 优化_常用命令 # 配置_开发环境 - +选配