代码拉取完成,页面将自动刷新
同步操作将从 WindowHZT/termux-ubuntu2004 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
#字体颜色
red="\e[31;1m" #红
green="\e[32;1m" #绿
yellow="\e[33;1m" #黄
blue="\e[34;1m" #蓝
purple="\e[35;1m" #紫红
cyanine="\e[36;1m" #青蓝
white="\e[0m" ##白色
echo `date +"%Y-%m-%d %H:%M:%S"` > `pwd`/Time
msg() { clear;echo -e "\n\t\t$blue[*]$white$1$2$white\n" ;:;} ##自定义通告颜色
enter() { echo -en "\n\n$green按回车继续$white";read op ;:;}
cmsg() { colour=$1;command=$2;echo -e "\n$blue[*]$white$colour$command$white";command $command ;:;} ##自定义通告颜色
msg $red "等待授权存储…®login"
echo -e "\n$yellow小提示:请允许应用使用存储,否则会导致无法正常使用!$white"
enter
cmsg $green "termux-setup-storage"
enter
msg $red "等待授权后台运行…®login"
echo -e "\n$yellow小提示:请允许应用后台无限制运行(即加入白名单),否则会导致应用卡顿!$white"
enter
cmsg $green "termux-wake-lock"
enter
cat<<-EOF> $PREFIX/etc/apt/sources.list
# The main termux repository, behind cloudflare cache:
# deb https://packages-cf.termux.dev/apt/termux-main/ stable main
# The main termux repository:
#deb https://packages.termux.dev/apt/termux-main/ stable main
deb https://mirrors.bfsu.edu.cn/termux/apt/termux-main stable main
EOF
msg $red "更新软件包"
echo -e "\n$yellow小提示:更新过程如果暂停,请输入y再回车!$white"
enter
cmsg $green "pkg update -y"
cmsg $green "pkg i wget proot x11-repo aria2 termux-api libusb clang -y"
while :
do
#wget -c "https://raw.githubusercontent.com/WindowHZT/termux-ubuntu2004/main/mix/termux-x11.deb"
wget -c "gitee.com/djyd/termux-ubuntu2004/raw/main/mix/termux-x11.deb"
if [ ! "$?" == "0" ];then
echo -e "$yellow下载资源失败!请检查网络再继续下载……"
enter
else
cmsg $green "apt install ./termux-x11.deb -y"
break
fi
done
msg $red "配置声音模块"
cmsg $green "pkg i pulseaudio -y"
pulseaudio --start >> /dev/null 2>&1
if [ -e ~/../usr/etc/pulse/default.pa ];then
echo "load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" >> ~/../usr/etc/pulse/default.pa
fi
if [ -e ~/../usr/etc/pulse/daemon.conf ];then
sed -i "s/; exit-idle/#; exit-idle/g" ~/../usr/etc/pulse/daemon.conf
echo "exit-idle-time = 180" >> ~/../usr/etc/pulse/daemon.conf
echo "将timeout修改为180秒"
else
echo "exit-idle-time = 180" >> ~/../usr/etc/pulse/daemon.conf
echo "将timeout修改为180秒"
fi
folder=ubuntu20-fs
tarball="ubuntu20-rootfs.tar.gz"
mkdir -p ubuntu20-binds
cur=`pwd`
if [ -d "$folder" ]; then
first=1
echo -e "\n$yellow检测到$folder目录存在!$white"
echo -e "\n$yellow它可能是一个完整的系统或者卸载残留!$white"
echo -e "\n脚本退出"
exit
fi
if [ "$first" != 1 ];then
if [ ! -f $tarball ]; then
msg $red "下载Rootfs,请保持你的网络良好"
case `dpkg --print-architecture` in
aarch64)
archurl="arm64" ;;
arm)
archurl="armhf" ;;
x86_64 | amd64)
archurl="amd64" ;;
*)
echo "未知构架"; exit 1 ;;
esac
while :
do
#wget -c "https://github.com/WindowHZT/termux-ubuntu2004/releases/download/ubuntu2004/focal-$archurl.tar.gz" -O ubuntu20-rootfs.tar.gz
wget -c "gitee.com/djyd/termux-ubuntu2004/releases/download/ubuntu2004/focal-$archurl.tar.gz" -O ubuntu20-rootfs.tar.gz
if [ ! "$?" == "0" ];then
echo -e "$yellow下载资源失败!请检查网络再继续下载……"
enter
else
break
fi
done
fi
mkdir -p "$folder"
cd "$folder"
msg $red "解压Rootfs,请耐心等待。"
proot --link2symlink tar -xf ${cur}/${tarball} --exclude=dev||:
cd $HOME/$folder/var/cache/apt/archives
if [ "$archurl" == "arm64" ];then
for x in 1 2 3 4
do
while :
do
clear
cmsg $green "Download the package$x (下载整合包,减少依赖网络质量***)"
wget -c "gitee.com/djyd/termux-ubuntu2004/releases/download/ubuntu2004/package$x.tar.gz"
if [ ! "$?" == "0" ];then
echo -e "$yellow下载资源失败!请检查网络再继续下载……"
enter
else
tar -zxvf package$x.tar.gz && rm -rf package$x.tar.gz
break
fi
done
done
fi
cd "$cur"
fi
##创建目录fakethings,输入数据
mkdir -p ${folder}/proc/fakethings
if [ ! -f "${cur}/${folder}/proc/fakethings/stat" ]; then
cat <<- EOF > "${cur}/${folder}/proc/fakethings/stat"
cpu 5502487 1417100 4379831 62829678 354709 539972 363929 0 0 0
cpu0 611411 171363 667442 7404799 61301 253898 205544 0 0 0
cpu1 660993 192673 571402 7853047 39647 49434 29179 0 0 0
cpu2 666965 186509 576296 7853110 39012 48973 26407 0 0 0
cpu3 657630 183343 573805 7863627 38895 48768 26636 0 0 0
cpu4 620516 161440 594973 7899146 39438 47605 26467 0 0 0
cpu5 610849 155665 594684 7912479 40258 46870 26044 0 0 0
cpu6 857685 92294 387182 8096756 46609 22110 12364 0 0 0
cpu7 816434 273809 414043 7946709 49546 22311 11284 0 0 0
intr 601715486 0 0 0 0 70612466 0 2949552 0 93228 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12862684 625329 10382717 16209 55315 8510 0 0 0 0 11 11 13 270 192 40694 95 7 0 0 0 36850 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 286 6378 0 0 0 54 0 3239423 2575191 82725 0 0 127 0 0 0 1791277 850609 20 9076504 0 301 0 0 0 0 0 3834621 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 806645 0 0 0 0 0 7243 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2445850 52 1783 0 0 5091520 0 0 0 3 0 0 0 0 0 5475 0 198001 0 2 42 1289224 0 2 202483 4 0 8390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3563336 4202122 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 17948 0 0 612 0 0 0 0 2103 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 11 11 12 0 12 0 52 752 0 0 0 0 0 0 0 743 0 14 0 0 12 0 0 1863 229 0 464 0 0 0 0 0 0 8588 97 7236426 92766 622 31 0 0 0 18 4 4 0 5 0 0 116013 7 0 0 752406
ctxt 826091808
btime 1611513513
processes 288493
procs_running 1
procs_blocked 0
softirq 175407567 14659158 51739474 28359 5901272 8879590 0 11988166 46104015 0 36107533
EOF
fi
if [ ! -f "${cur}/${folder}/proc/fakethings/version" ]; then
cat <<- EOF > "${cur}/${folder}/proc/fakethings/version"
Linux version 5.4.0-faked (andronix@fakeandroid) (gcc version 4.9.x (Andronix fake /proc/version) ) #1 SMP PREEMPT Sun Sep 13 00:00:00 IST 2020
EOF
fi
if [ ! -f "${cur}/${folder}/proc/fakethings/vmstat" ]; then
cat <<- EOF > "${cur}/${folder}/proc/fakethings/vmstat"
nr_free_pages 15717
nr_zone_inactive_anon 87325
nr_zone_active_anon 259521
nr_zone_inactive_file 95508
nr_zone_active_file 57839
nr_zone_unevictable 58867
nr_zone_write_pending 0
nr_mlock 58867
nr_page_table_pages 24569
nr_kernel_stack 49552
nr_bounce 0
nr_zspages 80896
nr_free_cma 0
nr_inactive_anon 87325
nr_active_anon 259521
nr_inactive_file 95508
nr_active_file 57839
nr_unevictable 58867
nr_slab_reclaimable 17709
nr_slab_unreclaimable 47418
nr_isolated_anon 0
nr_isolated_file 0
workingset_refault 33002180
workingset_activate 5498395
workingset_restore 2354202
workingset_nodereclaim 140006
nr_anon_pages 344014
nr_mapped 193745
nr_file_pages 218441
nr_dirty 0
nr_writeback 0
nr_writeback_temp 0
nr_shmem 1880
nr_shmem_hugepages 0
nr_shmem_pmdmapped 0
nr_anon_transparent_hugepages 0
nr_unstable 0
nr_vmscan_write 8904094
nr_vmscan_immediate_reclaim 139732
nr_dirtied 8470080
nr_written 16835370
nr_indirectly_reclaimable 8273152
nr_unreclaimable_pages 130861
nr_dirty_threshold 31217
nr_dirty_background_threshold 15589
pgpgin 198399484
pgpgout 31742368
pgpgoutclean 45542744
pswpin 3843200
pswpout 8903884
pgalloc_dma 192884869
pgalloc_normal 190990320
pgalloc_movable 0
allocstall_dma 0
allocstall_normal 3197
allocstall_movable 1493
pgskip_dma 0
pgskip_normal 0
pgskip_movable 0
pgfree 384653565
pgactivate 34249517
pgdeactivate 44271435
pglazyfree 192
pgfault 46133667
pgmajfault 5568301
pglazyfreed 0
pgrefill 55909145
pgsteal_kswapd 58467386
pgsteal_direct 255950
pgscan_kswapd 86628315
pgscan_direct 415889
pgscan_direct_throttle 0
pginodesteal 18
slabs_scanned 31242197
kswapd_inodesteal 1238474
kswapd_low_wmark_hit_quickly 11637
kswapd_high_wmark_hit_quickly 5411
pageoutrun 32167
pgrotated 213328
drop_pagecache 0
drop_slab 0
oom_kill 0
pgmigrate_success 729722
pgmigrate_fail 450
compact_migrate_scanned 43510584
compact_free_scanned 248175096
compact_isolated 1494774
compact_stall 6
compact_fail 3
compact_success 3
compact_daemon_wake 9438
compact_daemon_migrate_scanned 43502436
compact_daemon_free_scanned 248107303
unevictable_pgs_culled 66418
unevictable_pgs_scanned 0
unevictable_pgs_rescued 8484
unevictable_pgs_mlocked 78830
unevictable_pgs_munlocked 8508
unevictable_pgs_cleared 11455
unevictable_pgs_stranded 11455
swap_ra 0
swap_ra_hit 7
speculative_pgfault 221449963
EOF
fi
bin=start-ubuntu20.sh
cat <<- EOM > $bin
#!/data/data/com.termux/files/usr/bin/bash
cd \$(dirname \$0)
## unset LD_PRELOAD in case termux-exec is installed
pulseaudio -k >> /dev/null 2>&1
pulseaudio --start >> /dev/null 2>&1
config="/data/data/com.termux/files/home/ubuntu20-fs/usr/local/bin/.config"
##use termux-x11
if [ -e "\$config" ];then
source \$config
case "\$mode" in
"1")
[ -z "\$(ps -ef | grep 'pulseaudio --start' | grep -v grep)" ]&& pulseaudio --start >> /dev/null 2>&1
;;
"2")
export XDG_RUNTIME_DIR=\${TMPDIR}
termux-x11 :0 -dpi \$dpi &
;;
"3")
am start -n x.org.server/x.org.server.MainActivity
sleep 10
#pulseaudio -k >> /dev/null 2>&1
;;
esac
fi
[ -z "\$(ps -ef | grep 'pulseaudio --start' | grep -v grep)" ]&& pulseaudio --start >> /dev/null 2>&1
unset LD_PRELOAD
#export PROOT_NO_SECCOMP=1
command="proot"
command+=" --kill-on-exit"
command+=" --link2symlink"
command+=" -0"
command+=" -r ubuntu20-fs"
if [ -n "\$(ls -A ubuntu20-binds)" ]; then
for f in ubuntu20-binds/* ;do
. \$f
done
fi
command+=" -b /dev"
command+=" -b /proc"
command+=" -b /sys"
command+=" -b /data"
command+=" -b ubuntu20-fs/root:/dev/shm"
command+=" -b /proc/self/fd/2:/dev/stderr"
command+=" -b /proc/self/fd/1:/dev/stdout"
command+=" -b /proc/self/fd/0:/dev/stdin"
command+=" -b /dev/urandom:/dev/random"
command+=" -b /proc/self/fd:/dev/fd"
command+=" -b /data/data/com.termux/files/home/ubuntu20-fs/tmp:/dev/shm"
command+=" -b /data/data/com.termux/files/home/ubuntu20-fs/proc/fakethings/stat:/proc/stat"
command+=" -b /data/data/com.termux/files/home/ubuntu20-fs/proc/fakethings/vmstat:/proc/vmstat"
command+=" -b /data/data/com.termux/files/home/ubuntu20-fs/proc/fakethings/version:/proc/version"
command+=" -b /data/data/com.termux/files/home/ubuntu20-fs/proc/.uptime:/proc/uptime"
command+=" -b /data/data/com.termux/files/home/ubuntu20-fs/proc/.loadavg:/proc/loadavg"
command+=" -b /data/data/com.termux/files/usr/tmp:/tmp"
## uncomment the following line to have access to the home directory of termux
#command+=" -b /data/data/com.termux/files/home:/root"
command+=" -b /sdcard"
command+=" -b /storage"
command+=" -w /root"
command+=" /usr/bin/env -i"
command+=" MOZ_FAKE_NO_SANDBOX=1"
command+=" HOME=/root"
command+=" PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games"
command+=" TERM=$TERM"
#command+=" LANG=C.UTF-8"
command+=" LANG=zh_CN.UTF-8"
#command+=" PULSE_SERVER=tcp:127.0.0.1:4713"
command+=" /bin/bash --login"
com="\$@"
if [ -z "\$1" ];then
exec \$command
else
\$command -c "\$com"
fi
EOM
rm -rf ubuntu20-fs/usr/local/bin/*
touch ubuntu20-fs/proc/.uptime
touch ubuntu20-fs/proc/.loadavg
echo "127.0.0.1 localhost" > $folder/etc/hosts
echo "修复$bin的shebang"
termux-fix-shebang $bin
echo "使$bin可执行"
chmod +x $bin
echo "删除一些镜像"
cmsg $green "rm $HOME/$tarball"
touch $folder/root/.hushlogin
##向.bash_profile写入数据🍎
cat <<- EOF > "$HOME/$folder/root/.bash_profile"
#!/bin/bash
cmsg() { colour="\e[32;1m";command=\$1;echo -e "\n\e[34;1m[*]\e[0m\$colour\$command\e[0m";command \$command ;:;} ##自定义通告颜色
##添加用户组
for x in \$(echo \`groups\`)
do
if [ "\`cat /etc/group | grep \$x\`" == "" ];then
groupadd --gid \$x permagrp\$x
fi
done
rm -rf /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
##解决换源后更新失败
#cmsg "apt install apt-transport-https ca-certificates -y"
cmsg "apt install /var/cache/apt/archives/libssl1.1_1.1.1f-1ubuntu2.16_arm64.deb -y"
cmsg "apt install /var/cache/apt/archives/openssl_1.1.1f-1ubuntu2.16_arm64.deb -y"
cmsg "apt install /var/cache/apt/archives/apt-transport-https_2.0.9_all.deb -y"
cmsg "apt install /var/cache/apt/archives/ca-certificates_20211016ubuntu0.20.04.1_all.deb -y"
cat<<-END>/etc/apt/sources.list ##北京外国语大学
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
END
cmsg "apt update -y"
cmsg "apt-get update -y"
cmsg "apt install wget -y"
cmsg "apt install sudo -y"
cmsg "apt install locales language-pack-zh-hans-base language-pack-zh-hans language-pack-zh-hant-base language-pack-zh-hant -y"
cmsg "apt install dialog -y"
rm -rf /etc/skel/.profile.1 /root/.profile.1
user
EOF
##向profile写入数据🍎
cat <<-EOF >>$HOME/$folder/root/.profile
exit() {
if pgrep -f tiger >/dev/null;then
unset -f exit
exit
else
pkill dbus
pkill ssh-agent
pkill gpg-agent
pkill pulseaudio
unset -f exit
exit
fi
}
EOF
#chmod +x $tarball
for x in user vnc ubuntu software test.mp3
do
while :
do
#wget -c "https://raw.githubusercontent.com/WindowHZT/termux-ubuntu2004/main/usr/$x" -O "$cur/$folder/usr/local/bin/$x"
wget -c "gitee.com/djyd/termux-ubuntu2004/raw/main/usr/$x" -O "$cur/$folder/usr/local/bin/$x"
if [ ! "$?" == "0" ];then
echo -e "$yellow下载资源失败!请检查网络再继续下载……"
enter
else
break
fi
done
done
chmod +x $folder/root/.profile
chmod 770 $folder/usr/local/bin/*
echo "APT::Acquire::Retries \"3\";" > $folder/etc/apt/apt.conf.d/80-retries
cd ~ && echo "./$bin" > .bash_profile
sed -i "s/# allow-external-apps = true/allow-external-apps = true/g" ~/.termux/termux.properties
cat <<-EOF > .bash_profile
[ "\$(pwd)" != "\$HOME" ]&&echo -e "当前目录非\$HOME默认不启动ubuntu"&&exit
cmsg() { colour=$1;command=$2;echo -e "\n$blue[*]$white$colour$command$white";command $command ;:;} ##自定义通告颜色
echo -e "\t\t**************"
echo -e "\t\t\e[32;1m👉直接按回车 (启动ubuntu系统)\e[0m"
echo -e "\t\t\e[32;1m👉输入d回车 (删除ubuntu系统,说拜拜👋)\e[0m"
echo -e "\t\t**************"
echo -ne "\e[31;1m请在10s内决定(或输入):\e[0m"
read -t 5 op
if [ "\$?" == "0" ];then
if [ "\$op" == "" ];then
termux-wake-lock && ./$bin
elif [ "\$op" == "d" ];then
echo -en "\n$blue[*]$white$red是否需要删除ubuntu系统? [y/n]:$white"
read z
if [ "\$z" == "y" ];then
echo -en "\n$blue[*]$white$red最后确认一遍,是否删除? [y/n]:$white"
read z
if [ "\$z" == "y" ];then
cd \$HOME
kill -9 \$(ps -ef | grep "proot" | grep -v grep | awk -F " " '{print \$2}') >> /dev/null 2>&1
kill -9 \$(ps -ef | grep "su" | grep -v grep | awk -F " " '{print \$2}') >> /dev/null 2>&1
kill -9 \$(ps -ef | grep "dbus-daemon" | grep -v grep | awk -F " " '{print \$2}') >> /dev/null 2>&1
rm -rf ubuntu20-fs ubuntu20-binds .bash_profile >> /dev/null 2>&1
echo -e "\n$green已删除ubuntu系统,期待下次与你相见~$white"
fi
fi
fi
else
echo -e "\n选择超时,若想启动ubuntu系统也可以手动输入\e[31;1m ./start-ubuntu20.sh\e[0m 命令哦"
fi
EOF
msg $red "首次启动系统~"
bash $bin
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。