1 #!/data/data/com.termux/files/usr/bin/bash
4 test ! -d $INDIR && mkdir $INDIR
5 INED_LIST=(`ls ${INDIR}`)
6 ARCH_LIST=('aarch64' 'armhf')
7 LOCAL_ARCH=$(dpkg --print-architecture)
8 LINUX_LIST=('alpine' 'aosc' 'arch' 'centos' 'debian' 'fedora' 'kali' 'opensuse' 'ubuntu' 'termux' 'parrot' 'backbox' 'void')
10 tips() { printf " $@ \n";}
11 warn() { printf "\033[1;33m $@ \033[0m\n";}
12 error() { printf "[\033[1;31m $@ \033[0m]\n";}
13 cutline(){ tips "******************************************";}
23 tips "atilo 0.19.5 (Bash Script) by http://funs.ml"
24 tips "用法: atilo [选项] [参数]"
26 tips "apertis\t\t| 安装apertis"
27 tips "fedora \t\t| 安装fedora"
28 tips "debian \t\t| 安装debian"
29 tips "alpine \t\t| 安装alpine"
30 tips "aosc \t\t| 安装aosc"
31 tips "arch \t\t| 安装archlinux"
32 tips "kali \t\t| 安装kali"
33 tips "void \t\t| 安装voidlinux"
34 tips "parrot \t\t| 安装parrot"
35 tips "backbox\t\t| 安装backbox"
36 tips "ubuntu \t\t| 安装ubuntu"
37 tips "centos \t\t| 安装centos"
38 tips "opensuse \t\t| 安装opensuse"
39 #tips "termux \t\t| 安装termux"
40 tips "run \t\t| 运行一个linux"
41 tips "rm \t\t| 删除安装的linux"
49 #export PROOT_NO_SECCOMP=1
54 "\\Linux\\${NAME}\\5.4-fake\#1\\${LOCAL_ARCH}\\localhost\\-1\\" \
60 -b /data/data/com.termux/files/home \
62 -b ${NAME}/tmp:/dev/shm \
63 -b ${NAME}/proc/.stat:/proc/stat \
64 -b ${NAME}/proc/.uptime:/proc/uptime \
67 PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games \
72 ###########################################
74 ############## 删除linux ###############j
77 if echo "${LINUX_LIST[@]}" | grep -w "${1}" &>/dev/null;
79 chmod -R 0755 ${INDIR}/${1} > /dev/null 2>&1;
80 rm -rf ${INDIR}/${1} ${PREFIX}/bin/start${1} > /dev/null 2>&1;
81 tips "删除${1}成功"; exit 0;
83 warn "! 输入错误"; exit 1;
87 ####################################
90 if echo "${INED_LIST[@]}" | grep -wq "$1";then true
98 if [ $# = 0 ]; then show_help; fi
103 if [ $LOCAL_ARCH == "${ARCH_LIST[0]}" ];
105 elif [ ${LOCAL_ARCH} == "${ARCH_LIST[1]}" ];
107 else warn "! 未知架构 ${LOCAL_ARCH}\n只支持(aarch64,armhf)"
112 url="https://api.funs.ml/rootfs/?url=${NAME}_${LOCAL_ARCH}.tgz"
115 #######################################
121 NAME=apertis; zip=pxJf;
126 NAME=alpine; zip=pzxf; sh=ash;
127 mirrors="mirrors.bfsu.edu.cn"
128 mirrorshost="dl-cdn.alpinelinux.org"
129 mirrorspath="etc/apk/repositories";;
132 mirrors="mirrors.bfsu.edu.cn\/archlinuxarm"
133 mirrorshost="mirror.archlinuxarm.org"
134 mirrorspath="etc/pacman.d/mirrorlist"
135 #attach="pacman-key --init;pacman-key --populate archlinuxarm;locale-gen"
136 attach="echo hello";;
139 NAME=centos; zip=pxf;
140 mirrors=0 #"mirrors.tuna.tsinghua.edu.cn\/centos"
141 mirrorshost=0 #"mirrorlist.centos.org"
142 mirrorspath=0 #"etc/yum.repos.d/CentOS-Base.repo"
146 NAME=ubuntu; zip=pxJf;
147 mirrors="mirrors.bfsu.edu.cn"
148 mirrorshost="ports.ubuntu.com"
149 mirrorspath="etc/apt/sources.list"
150 #attach="apt update;apt install -y perl apt-utils dialog locales";;
151 attach="locale-gen zh_CN.UTF-8 && sed -i '/^LANG/c'LANG=zh_CN.UTF-8'' /etc/default/locale";;
155 if [ ${LOCAL_ARCH} != "arm" ];then
160 attach="dnf update";;
163 NAME=debian; zip=pxf;
164 mirrors="mirrors.bfsu.edu.cn"
165 mirrorshost="deb.debian.org"
166 mirrorspath="etc/apt/sources.list"
167 attach="apt update;apt install -y perl apt-utils dialog locales";;
170 mirrors="mirrors.bfsu.edu.cn\/anthon"
171 mirrorshost="repo.aosc.io"
172 mirrorspath="etc/apt/sources.list"
173 attach="apt-gen-list m tuna;apt update;ln -s /usr/bin/perl5.24.3 /usr/bin/perl;dpkg --configure -a";;
175 NAME=backbox; zip=pxf
176 mirrors="mirrors.bfsu.edu.cn"
177 mirrorshost="ports.ubuntu.com"
178 mirrorspath="etc/apt/sources.list"
179 attach="apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 680E1A5A78A7ABE1;apt update;apt install -y apt-utils dialog";;
181 NAME=parrot; zip=pxf;
182 mirrors="mirrors.bfsu.edu.cn"
183 mirrorshost="ba.mirror.garr.it\/mirrors"
184 mirrorspath="etc/apt/sources.list"
185 attach="apt update";;
188 NAME=opensuse; zip=pxf;
189 mirrors=0 ##"mirrors.tuna.tsinghua.edu.cn\/opensuse"
190 mirrorshost=0 ##"download.opensuse.org"
191 mirrorspath=0 ##"etc/zypp/repos.d/repo-update.repo"
196 mirrors="mirrors.bfsu.edu.cn"
197 mirrorshost="http.kali.org"
198 mirrorspath="etc/apt/sources.list"
199 attach="locale-gen zh_CN.UTF-8 && apt update && apt install apt-utils -y";;
203 mirrors="mirrors.bfsu.edu.cn\/voidlinux"
204 mirrorshost="alpha.de.repo.voidlinux.org"
205 mirrorspath="usr/share/xbps.d/*-repository-*.conf"
208 # termux) NAME=termux; zip=pJx;
209 # mirrors="deb http://mirrors.tuna.tsinghua.edu.cn/termux/ stable main"
211 # mirrorspath="etc/apt/sources.list"
215 run) is_installed $2;NAME=$2;run_proot;;
216 *) warn "! 未知选项: '$1'";exit 1;
218 #######################################
220 ############ 下载 ##############
221 mkdir -p ${INDIR}/${NAME}
227 if [ ! -f "${NAME}.tgz" ];then
229 (curl -A funs -sfL ${url} -o ${NAME}.tgz) &
230 all_size=$(curl ${url} -sfLI |grep -i "Content-Length:" |awk -F "[Cc]ontent-[Ll]ength: " '{print $2}'|dos2unix)
231 if [ "$all_size" == '' ]; then
232 tips "+ 下载错误 (请检查链接是否能正常访问)\n ${url}"
237 while [[ $all_size != $dow_size ]]
239 dow_size=$(wc -c ${NAME}.tgz |awk -F ' ' '{print $1}')
240 echo -en "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"' + 下载根目录文件 ... '`echo "scale=2;${dow_size} / (${all_size} / 100)"|bc`'%'
248 #########################################
251 ############# 解压 ##############
254 if [ ${LOCAL_ARCH} == "arm" ];then
255 if [ ${NAME} == "fedora" ];then
256 tar xvf fedora.tgz --strip-components=1 --exclude json --exclude VERSION
263 if [ ${NAME} == "termux" ];then
267 proot -0 -l tar ${zip} ${NAME}.tgz --exclude=dev
268 if [ "$?" != "0" ]; then
273 ###########################################
276 ########### 设置 DNS ##########
277 tips "+ 设置DNS服务器 ..."
279 rm -r ${INDIR}/${NAME}/etc/resolv.conf 2>/dev/null
280 echo -e "nameserver 119.29.29.29\nnameserver 8.8.8.8" > ${INDIR}/${NAME}/etc/resolv.conf
281 #echo "export USER=root" >> ~/${cmd}/etc/profile
282 #echo "export LC_ALL=zh_CN.utf8" >> ~/${cmd}/etc/profile
283 #echo "zh_CN.UTF-8 UTF-8" >> ~/${cmd}/etc/locale.gen
284 #echo "export DISPLAY=127.0.0.1:0" >> ~/${cmd}/etc/profile
285 #echo "export PULSE_SERVER=tcp:127.0.0.1:4712" >> ~/${cmd}/etc/profile
286 #########################################
287 proot -0 sed -i 's#root:.*#root:$6$9XNS6Hzz0bzrPIwm$whRSUOZ6o5dkSeORcBKup2YZUt7/Z4hhqDvJ6lG0o5ApmwfrP/3eObde6OLHfekjoheKWkVZ0ZNZ3H1.WcX/Z1:18549:0:99999:7:::#g' ${INDIR}/${NAME}/etc/shadow
288 echo -e "pts/0\npts/1" >> ${INDIR}/${NAME}/etc/securetty 2>/dev/null
289 chmod 700 ${INDIR}/${NAME}/proc/
290 proot -0 echo '843422.42 3355754.32' > ${INDIR}/${NAME}/proc/.uptime
291 proot -0 cat <<- EOF > ${INDIR}/${NAME}/proc/.stat
292 cpu 1050008 127632 898432 43828767 37203 63 99244 0 0 0
293 cpu0 212383 20476 204704 8389202 7253 42 12597 0 0 0
294 cpu1 224452 24947 215570 8372502 8135 4 42768 0 0 0
295 cpu2 222993 17440 200925 8424262 8069 9 17732 0 0 0
296 cpu3 186835 8775 195974 8486330 5746 3 8360 0 0 0
297 cpu4 107075 32886 48854 8688521 3995 4 5758 0 0 0
298 cpu5 90733 20914 27798 1429573 2984 1 11419 0 0 0
299 intr 53261351 0 686 1 0 0 1 12 31 1 20 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 0 0 0 0 0 0 0 0 0 0 0 0 0 7818 0 0 0 0 0 0 0 0 255 33 1912 33 0 0 0 0 0 0 3449534 2315885 2150546 2399277 696281 339300 22642 19371 0 0 0 0 0 0 0 0 0 0 0 2199 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 2445 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 162240 14293 2858 0 151709 151592 0 0 0 284534 0 0 0 0 0 0 0 0 0 0 0 0 0 0 185353 0 0 938962 0 0 0 0 736100 0 0 1 1209 27960 0 0 0 0 0 0 0 0 303 115968 452839 2 0 0 0 0 0 0 0 0 0 0 0 0 0 160361 8835 86413 1292 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3592 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 6091 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 35667 0 0 156823 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 138 2667417 0 41 4008 952 16633 533480 0 0 0 0 0 0 262506 0 0 0 0 0 0 126 0 0 1558488 0 4 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 2 2 8 0 0 6 0 0 0 10 3 4 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 20 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 12 1 1 83806 0 1 1 0 1 0 1 1 319686 2 8 0 0 0 0 0 0 0 0 0 244534 0 1 10 9 0 10 112 107 40 221 0 0 0 144
305 softirq 25293348 2883 7658936 40779 539155 497187 2864 1908702 7229194 279723 7133925
307 chmod +rw ${INDIR}/${NAME}/etc/passwd
308 chmod +rw ${INDIR}/${NAME}/etc/shadow
309 chmod +rw ${INDIR}/${NAME}/etc/group
310 echo "aid_$(id -un):x:$(id -u):$(id -g):Android user:/:/usr/sbin/nologin" >> ${INDIR}/${NAME}/etc/passwd
311 echo "aid_$(id -un):*:18446:0:99999:7:::" >> ${INDIR}/${NAME}/etc/shadow
312 for g in $(id -G); do
313 echo "aid_$(id -gn "$g"):x:${g}:root,aid_$(id -un)" >> ${INDIR}/${NAME}/etc/group
314 if [ -f "${HOME}/${NAME}/etc/gshadow" ]; then
315 chmod +rw ${INDIR}/${NAME}/etc/gshadow
316 echo "aid_$(id -gn "$g"):*::root,aid_$(id -un)" >> ${INDIR}/${NAME}/etc/gshadow
320 ############# 修改源 ##########
323 # echo -e "$mirrors" > "$mirrorspath"
324 sed -i "s/${mirrorshost}/${mirrors}/" $mirrorspath
327 if [ "$mirrors" != "0" ]; then "ch_mirrors"; fi
328 ################################
332 #start${cmd} ${attach} #> /dev/null 2>&1
335 ############ 全部完成 ################
338 tips "+ 启动${NAME}的命令\033[1;33m atilo run ${NAME}\033[0m"
339 tips "+ 默认账号:root 密码:root"
342 #######################################