Skip to content

Commit

Permalink
🐛 fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
marchocode committed Jan 6, 2023
1 parent 8b92927 commit 3e4e6fd
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tiny-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ else
echo -e "${red}未检测到系统版本,请联系脚本作者!${plain}\n" && exit 1
fi

# clean log
cat /dev/null > .tiny-shell.log

log() {
echo "$1" > .tiny-shell.log
echo "$1" >> .tiny-shell.log
}

root_check() {

log "root_check user=${USER}"

if [[ $USER != "root" ]]
then
echo -e "${red}错误:${plain} 必须使用root用户运行此脚本!\n" && exit 1
Expand All @@ -54,6 +59,8 @@ root_check() {
# 选择镜像源
mirrors_check(){

log "mirrors_check param=${1}"

q=$1
# centos-stream-8 作为centos去搜索
if [[ ${q} = "centos-stream" && ${version} = "8" ]];then
Expand All @@ -69,12 +76,15 @@ mirrors_check(){
name=$(echo ${mirrors_list[$i]}| cut -d "|" -f 2)

echo -e "${i}. ${green}${host}${plain}(${name})"
log "${i}. ${green}${host}${plain}(${name})"
done

echo -e ""
echo -e ${line}

read -p "请输入选择 [0-${mirrors_length}](默认0): " CHOISE

log "user choice=${CHOISE}"

if [[ -z $CHOISE ]]; then
CHOISE="0"
Expand All @@ -85,6 +95,7 @@ mirrors_check(){
fi

check_host=${mirrors_list[${CHOISE}]}
log "check_host=${check_host}"

id=$(echo ${check_host} | cut -d "|" -f 1)
host=$(echo ${check_host} | cut -d "|" -f 2)
Expand Down Expand Up @@ -117,9 +128,11 @@ system(){
mirrors_check ${release}

destinations=($(cat system.destination | grep "${release}-${version}"))
log "system-destinations=${destinations}"

if [[ ${#destinations[@]} -eq 0 ]]; then
destinations=($(cat system.destination | grep "${release}-default"))
log "system-destinations=${destinations}"
fi

backup=".sources.list.backup"
Expand All @@ -129,7 +142,10 @@ system(){
do

destination=$(echo ${destinations[$i]} | cut -d "|" -f 3)
config="${release}/"$(echo ${destinations[$i]} | cut -d "|" -f 3)
config="${release}/"$(echo ${destinations[$i]} | cut -d "|" -f 2)

log "system-destination=${destination}"
log "system-config=${config}"

backup="${backup_dir}/"$(basename ${destination})

Expand Down Expand Up @@ -256,6 +272,9 @@ menu(){
echo -e ""
}

log "os: ${release}"
log "version: ${version}"

if [[ $# > 0 ]]; then
case $1 in
"system")
Expand Down

0 comments on commit 3e4e6fd

Please sign in to comment.