Skip to content

Commit

Permalink
add automatic turnip driver install option and some improvement
Browse files Browse the repository at this point in the history
if you select turnip as the hardware acceleration driver for proot distro, now it will automatically install the required driver package for you.
currently only debian and ubuntu are supported.
Also it only work on arm64/aarch64 device
  • Loading branch information
sabamdarif committed Nov 9, 2024
1 parent 59c9efe commit 261ef3b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 13 deletions.
68 changes: 59 additions & 9 deletions distro-container-setup
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ function distro_basic_task() {
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 dnf upgrade -y
chmod -R +w $distro_path/
fi
# Set proot timezone
timezone=$(getprop persist.sys.timezone)
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 rm /etc/localtime
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 cp /usr/share/zoneinfo/$timezone /etc/localtime
if [[ "$pd_audio_config_answer" == "y" ]]; then
distro_packs="sudo pulseaudio"
distro_fix_sound_issue
Expand Down Expand Up @@ -289,8 +293,9 @@ proot-distro login $selected_distro -- /bin/bash -c 'bash pd_basic_setup.sh'
else
final_pass="root"
fi

if [[ "$pd_useradd_answer" == "y" ]]; then
if [[ "$selected_distro" == "alpine" ]]; then

cat <<EOF > $distro_path/root/useradd.sh
#!/bin/bash
Expand All @@ -302,7 +307,9 @@ chown ${final_user_name}:users /home/$final_user_name
echo "${final_user_name}:${final_pass}" | chpasswd
rm useradd.sh
EOF

else

cat <<EOF > $distro_path/root/useradd.sh
#!/bin/bash
Expand All @@ -313,32 +320,74 @@ usermod -aG wheel,polkitd,audio,video,storage ${final_user_name}
echo "${final_user_name}:${final_pass}" | chpasswd
rm useradd.sh
EOF

fi

proot-distro login $selected_distro -- /bin/sh -c 'bash useradd.sh'

if [[ "$pd_pass_type" == "1" ]];then
cat <<EOF > $distro_path/root/useradd.sh

cat <<EOF > $distro_path/root/user_permission.sh
#!/bin/bash
chmod u+rw /etc/sudoers
echo "$final_user_name ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers > /dev/null 2>&1
chmod u-w /etc/sudoers
rm useradd.sh
EOF
rm user_permission.sh
EOF

elif [[ "$pd_pass_type" == "2" ]];then
cat <<EOF > $distro_path/root/useradd.sh

cat <<EOF > $distro_path/root/user_permission.sh
#!/bin/bash
chmod u+rw /etc/sudoers
echo "$final_user_name ALL=(ALL:ALL) ALL" | tee -a /etc/sudoers > /dev/null 2>&1
chmod u-w /etc/sudoers
rm useradd.sh
rm user_permission.sh
EOF

fi

proot-distro login $selected_distro -- /bin/sh -c 'bash useradd.sh'
proot-distro login $selected_distro -- /bin/sh -c 'bash user_permission.sh'
proot-distro login $selected_distro -- /bin/sh -c 'sudo -k'
fi
}

#########################################################################
#
# Hardware Acceleration Setup
#
#########################################################################

# setup hardware acceleration, check if the enable-hw-acceleration already exist then then first check if it different from github , then ask user if they want to replace it or not, if not then continue with the lacal enable-hw-acceleration file
function hw_config() {
banner
echo "${R}[${W}-${R}]${G}${BOLD} Configuring Hardware Acceleration"${W}
echo
if [[ -f "${current_path}/enable-hw-acceleration" ]]; then
local current_script_hash=$(curl -sL https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/enable-hw-acceleration | sha256sum | cut -d ' ' -f 1)
local local_script_hash=$(basename $(sha256sum ${current_path}/enable-hw-acceleration | cut -d ' ' -f 1))
if [[ "$local_script_hash" != "$current_script_hash" ]]; then
echo "${R}[${W}-${R}]${G} It look like you already have a different hw-acceleration installer in your current directory"${W}
echo
confirmation_y_or_n "Do you want to change it with the latest installer" change_old_hw_installer
if [[ "$change_old_hw_installer" == "y" ]]; then
check_and_backup "${current_path}/enable-hw-acceleration"
wget -O ${current_path}/enable-hw-acceleration https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/enable-hw-acceleration && chmod +x ${current_path}/enable-hw-acceleration && . ${current_path}/enable-hw-acceleration
else
echo "${R}[${W}-${R}]${G} Using the local hardware acceleraion setup file"${W}
chmod +x ${current_path}/enable-hw-acceleration ; . ${current_path}/enable-hw-acceleration
fi
echo "change_old_hw_installer=\"$change_old_hw_installer\"" >> $config_file
else
echo "${R}[${W}-${R}]${G} Using the local hardware acceleraion setup file"${W}
chmod +x ${current_path}/enable-hw-acceleration ; . ${current_path}/enable-hw-acceleration
fi
else
wget -O ${current_path}/enable-hw-acceleration https://raw.githubusercontent.com/sabamdarif/termux-desktop/main/enable-hw-acceleration && chmod +x ${current_path}/enable-hw-acceleration && . ${current_path}/enable-hw-acceleration
rm ${current_path}/enable-hw-acceleration
fi
}

#########################################################################
Expand Down Expand Up @@ -441,7 +490,7 @@ esac
EOF
elif [[ "$distro_terminal_utility_setup_answer" == "y" ]];then
banner
echo "${R}[${W}-${R}]${C}${BOLD}Configuring Terminal Utility..."${W}
echo "${R}[${W}-${R}]${C}${BOLD}Configuring Terminal Utility For $selected_distro ..."${W}
echo
if [[ "$selected_distro" == "debian" ]] || [[ "$selected_distro" == "ubuntu" ]]; then
cat <<'EOF' > $distro_path/root/pd_setup.sh
Expand Down Expand Up @@ -486,7 +535,7 @@ wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sud
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
apt update
apt install -y eza
pd_package_install_and_check "eza"
rm pd_setup.sh
EOF
else
Expand Down Expand Up @@ -1199,6 +1248,7 @@ fi

setup_distro
distro_basic_task
hw_config
distro_zsh_answer
distro_terminal_utility_setup
distro_create_app_installer
Expand Down
21 changes: 20 additions & 1 deletion enable-hw-acceleration
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,24 @@ else
fi
}

function setup_turnip_proot() {
banner
echo "${R}[${W}-${R}]${G}${BOLD} Setting up Turnip for $selected_distro ..."${W}
echo
if [[ "$selected_distro" == "debian" ]] || [[ "$selected_distro" == "ubuntu" ]]; then
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 apt install xdg-desktop-portal xdg-desktop-portal-gtk libgl1 libgl1-mesa-dri libvulkan1 glmark2 -y
if [[ "$selected_distro" == "ubuntu" ]]; then
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 apt install mesa-vulkan-drivers libllvm15t64 -y
fi
wget https://github.com/bengkelgawai/Termux_XFCE/raw/main/mesa-vulkan-kgsl_23.3.0-ubuntu_arm64.deb
mv mesa-vulkan-kgsl_23.3.0-ubuntu_arm64.deb $distro_path/root/
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 dpkg -i mesa-vulkan-kgsl_23.3.0-ubuntu_arm64.deb
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 rm mesa-vulkan-kgsl_23.3.0-ubuntu_arm64.deb
fi
}

hw_install_required_packages
setup_hw_method
setup_hw_method
if [[ ("$termux_hw_answer" == "2" && "$pd_hw_answer" == "4") || ("$termux_hw_answer" != "2" && "$pd_hw_answer" == "3") ]]; then
setup_turnip_proot
fi
5 changes: 2 additions & 3 deletions setup-termux-desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ function terminal_utility_setup() {
echo
else
banner
echo "${R}[${W}-${R}]${C}${BOLD} Configuring Terminal Utility..."${W}
echo "${R}[${W}-${R}]${C}${BOLD} Configuring Terminal Utility For Termux..."${W}
echo
check_and_backup "$PREFIX/etc/motd"
check_and_backup "$PREFIX/etc/motd-playstore"
Expand Down Expand Up @@ -2589,7 +2589,6 @@ if [[ "$style_answer" == "0" ]]; then
else
setup_config
fi
hw_config
banner
distro_container_setup
gui_launcher
Expand Down Expand Up @@ -2712,4 +2711,4 @@ case $1 in
*)
install_termux_desktop
;;
esac
esac

0 comments on commit 261ef3b

Please sign in to comment.