Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ubuntu.sh #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 39 additions & 43 deletions Scripts/Installer/Ubuntu/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
#!/data/data/com.termux/files/usr/bin/bash
folder=ubuntu-fs
if [ -d "$folder" ]; then
first=1
echo "skipping downloading"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dddf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi

fi
tarball="ubuntu-rootfs.tar.xz"
if [ "$first" != 1 ];then
if [ ! -f $tarball ]; then
echo "Download Rootfs, this may take a while base on your internet speed."
case `dpkg --print-architecture` in

# Arrays with values for test and download config

declare -a folderFile=(ubuntu-fs ubuntu-rootfs.tar.xz)
declare -a archUrl=(arm64 armhf amd64 i386)


# If the folder ubuntu-fs do not exist and if rootfs file do not exist start the download

if ! [[ -d ${folderFile[0]} ]]; then
if [[ ! -f ${folderFile[1]} ]]; then
echo "Looks like you have not the Root file system, starting the download of Rootfs, this may take a while base on your internet speed."
case $(dpkg --print-architecture) in
aarch64)
archurl="arm64" ;;
archUrl=${archUrl[0]} ;;
arm)
archurl="armhf" ;;
archUrl=${archUrl[1]} ;;
amd64)
archurl="amd64" ;;
archUrl=${archUrl[2]} ;;
x86_64)
archurl="amd64" ;;
archUrl=${archUrl[2]} ;;
i*86)
archurl="i386" ;;
archUrl=${archUrl[3]} ;;
x86)
archurl="i386" ;;
archUrl=${archUrl[3]} ;;
*)
echo "unknown architecture"; exit 1 ;;
esac
wget "https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Rootfs/Ubuntu/${archurl}/ubuntu-rootfs-${archurl}.tar.xz" -O $tarball

wget "https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Rootfs/Ubuntu/${archUrl}/ubuntu-rootfs-${archUrl}.tar.xz" -O ${folderFile[1]}
fi
cur=`pwd`
mkdir -p "$folder"
cd "$folder"
cur=$(pwd)
mkdir -p ${folderFile[0]}
cd ${folderFile[0]}
echo "Decompressing Rootfs, please be patient."
proot --link2symlink tar -xJf ${cur}/${tarball}||:
cd "$cur"
proot --link2symlink tar -xJf ${cur}/${folderFile[1]}||:
cd $cur
fi


mkdir -p ubuntu-binds
bin=start-ubuntu.sh
echo "writing launch script"
Expand All @@ -41,31 +47,21 @@ cat > $bin <<- EOM
cd \$(dirname \$0)
## unset LD_PRELOAD in case termux-exec is installed
unset LD_PRELOAD
command="proot"
command+=" --link2symlink"
command+=" -0"
command+=" -r $folder"
if [ -n "\$(ls -A ubuntu-binds)" ]; then
for f in ubuntu-binds/* ;do
. \$f
done
fi
command+=" -b /dev"
command+=" -b /proc"
command+=" -b ubuntu-fs/root:/dev/shm"
command="proot --link2symlink -0 -r ${folderFile[0]} -b /dev -b /proc -b ubuntu-fs/root:/dev/shm -w /root /usr/bin/env -i HOME=/root PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games TERM=\$TERM LANG=C.UTF-8 /bin/bash --login"

## uncomment the following line to have access to the home directory of termux
#command+=" -b /data/data/com.termux/files/home:/root"
## uncomment the following line to mount /sdcard directly to /
#command+=" -b /sdcard"
command+=" -w /root"
command+=" /usr/bin/env -i"
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+=" /bin/bash --login"

if [[ -n "\$(ls -A ubuntu-binds)" ]]; then
for f in ubuntu-binds/* ;do
. \$f
done
fi

com="\$@"
if [ -z "\$1" ];then
if [[ -z "\$1" ]]; then
exec \$command
else
\$command -c "\$com"
Expand All @@ -77,5 +73,5 @@ termux-fix-shebang $bin
echo "making $bin executable"
chmod +x $bin
echo "removing image for some space"
rm $tarball
rm ${folderFile[1]}
echo "You can now launch Ubuntu with the ./${bin} script"