forked from tuanpham-dev/termux-ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7d15bbb
Showing
10 changed files
with
487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apt update -y && apt upgrade -y && apt install wget gnupg ffmpeg dialog xfce4-goodies libexo-1-0 -y | ||
rm -rf /etc/resolv.conf | ||
echo "nameserver 8.8.8.8" >> /etc/resolv.conf | ||
chmod +x /usr/share/andronix/firstrun | ||
mkdir -p ~/.vnc | ||
# Fixes for udisks2 | ||
echo "" > /var/lib/dpkg/info/udisks2.postinst | ||
dpkg --configure -a | ||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0CC3FD642696BFC8 | ||
groupadd --gid 3003 permagrp | ||
groupadd --gid 9997 permagrp2 | ||
groupadd --gid 50110 permagrp3 | ||
groupadd --gid 99909997 permagrp4 | ||
groupadd --gid 20195 permagrp5 | ||
groupadd --gid 50195 permagrp6 | ||
chmod 4755 /usr/bin/sudo | ||
rm -rf /etc/skel/.profile.1 /root/.profile.1 | ||
/usr/share/andronix/firstrun; exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Install Ubuntu20 on Termux Android | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
#!/bin/bash | ||
|
||
# suppress dmesg output while the script is running | ||
# echo 1 > /proc/sys/kernel/printk | ||
apt update | ||
apt install sudo dialog -y | ||
#variables | ||
TMPDIR=/var/tmp | ||
SWITCH=/usr/share/andronix/switchuser | ||
|
||
# Functions | ||
msg() { | ||
ALL_OFF="\e[1;0m" | ||
BOLD="\e[1;1m" | ||
GREEN="${BOLD}\e[1;32m" | ||
local mesg=$1; shift | ||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 | ||
} | ||
|
||
show_spinner() { | ||
local -r pid="${1}" | ||
local -r delay='0.75' | ||
local spinstr='\|/-' | ||
local temp | ||
printf "${GREEN} This might take a while.. " | ||
while ! grep -q "done" $TMPDIR/status ; do | ||
temp="${spinstr#?}" | ||
printf " [%c] " "${spinstr}" | ||
spinstr=${temp}${spinstr%"${temp}"} | ||
sleep "${delay}" | ||
printf "\b\b\b\b\b\b" | ||
done | ||
printf "Done! \b\b\b\b" | ||
echo "" | ||
} | ||
|
||
create_oem_install() { | ||
echo "$USER" > $TMPDIR/user | ||
echo "$PASSWORD" >> $TMPDIR/password | ||
echo "$PASSWORD" >> $TMPDIR/password | ||
echo "$ROOTPASSWORD" >> $TMPDIR/rootpassword | ||
echo "$ROOTPASSWORD" >> $TMPDIR/rootpassword | ||
msg "Setting root password..." | ||
passwd root < $TMPDIR/rootpassword 1> /dev/null 2>&1 | ||
/usr/bin/vncpasswd -f <<<"$ROOTPASSWORD"$'\n'"$ROOTPASSWORD" > /root/.vnc/passwd | ||
msg "Adding user $USER..." | ||
echo "" > $TMPDIR/status | ||
useradd -m -G sudo -s /bin/bash -U $(cat $TMPDIR/user) 1> /dev/null 2>&1 && echo "done" > $TMPDIR/status & | ||
show_spinner | ||
msg "Setting full name to $FULLNAME..." | ||
chfn -f "$FULLNAME" $(cat $TMPDIR/user) 1> /dev/null 2>&1 | ||
msg "Setting password for $USER..." | ||
passwd $(cat $TMPDIR/user) < $TMPDIR/password 1> /dev/null 2>&1 | ||
/usr/bin/vncpasswd -f <<<"$PASSWORD"$'\n'"$PASSWORD" > /home/$USER/.vnc/passwd | ||
sed -i "/^root/a $USER ALL=(ALL) ALL" /etc/sudoers | ||
msg "Applying system settings..." | ||
systemctl disable systemd-resolved.service 1> /dev/null 2>&1 | ||
|
||
msg "Cleaning install for unwanted files..." | ||
rm -rf /var/log/* | ||
|
||
# Remove temp files on host | ||
rm -rf $TMPDIR/user $TMPDIR/password $TMPDIR/rootpassword | ||
} | ||
|
||
|
||
# Using Dialog to ask for user input for variables | ||
USER=$(dialog --clear --title "Finish Andronix Install" \ | ||
--inputbox "Enter username: | ||
(Usernames can only be lower case)" 8 50 \ | ||
3>&1 1>&2 2>&3 3>&-) | ||
|
||
if [ ! -z "$USER" ] | ||
then | ||
FULLNAME=$(dialog --clear --title "Finish Andronix Install" \ | ||
--inputbox "Enter Full Name for $USER:" 8 50 \ | ||
3>&1 1>&2 2>&3 3>&- \ | ||
) | ||
fi | ||
|
||
if [ ! -z "$FULLNAME" ] | ||
then | ||
PASSWORD=$(dialog --clear --title "Finish Andronix Install" \ | ||
--insecure \ | ||
--passwordbox "Enter Password for $USER (at least 6 characters):" 8 50 \ | ||
3>&1 1>&2 2>&3 3>&- ) | ||
else | ||
clear | ||
msg "Configuration aborted. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
if [ ! -z "$PASSWORD" ] | ||
then | ||
LEN=${#PASSWORD} | ||
stat=1 | ||
if [[ "$LEN" -ge 6 ]]; then | ||
stat=$? | ||
else | ||
clear | ||
msg "Password does not match minimum lenght of 6 characters. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
fi | ||
fi | ||
|
||
if [ ! -z "$PASSWORD" ] | ||
then | ||
CONFIRMPASSWORD=$(dialog --clear --title "Andronix Installer" \ | ||
--insecure --passwordbox "Confirm Password for $USER:" 8 50 \ | ||
3>&1 1>&2 2>&3 3>&- \ | ||
) | ||
else | ||
clear | ||
msg "Configuration aborted. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
if [[ "$PASSWORD" != "$CONFIRMPASSWORD" ]]; then | ||
clear | ||
msg "User passwords do not match! Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
if [ ! -z "$CONFIRMPASSWORD" ] | ||
then | ||
ROOTPASSWORD=$(dialog --clear --title "Finish Andronix Install" \ | ||
--insecure \ | ||
--passwordbox "Enter Root Password (at least 6 characters):" 8 50 \ | ||
3>&1 1>&2 2>&3 3>&- \ | ||
) | ||
else | ||
clear | ||
msg "Configuration aborted. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
if [ ! -z "$ROOTPASSWORD" ] | ||
then | ||
LEN=${#ROOTPASSWORD} | ||
stat=1 | ||
if [[ "$LEN" -ge 6 ]]; then | ||
stat=$? | ||
else | ||
clear | ||
msg "Password does not match minimum lenght of 6 characters. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
fi | ||
fi | ||
|
||
if [ ! -z "$ROOTPASSWORD" ] | ||
then | ||
CONFIRMROOTPASSWORD=$(dialog --clear --title "Andronix Installer" \ | ||
--insecure --passwordbox "Confirm Root Password:" 8 50 \ | ||
3>&1 1>&2 2>&3 3>&- \ | ||
) | ||
else | ||
clear | ||
msg "Configuration aborted. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
if [[ "$ROOTPASSWORD" != "$CONFIRMROOTPASSWORD" ]]; then | ||
clear | ||
msg "Root passwords do not match! Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
if [ ! -z "$CONFIRMROOTPASSWORD" ] | ||
then | ||
dialog --clear --title "Finish Andronix Install" \ | ||
--yesno "Is the below information correct: | ||
Username = $USER | ||
Full Name for $USER = $FULLNAME | ||
Password for $USER = $PASSWORD | ||
Password for root = $ROOTPASSWORD" 20 50 \ | ||
3>&1 1>&2 2>&3 3>&- | ||
else | ||
clear | ||
msg "Configuration aborted. Restarting OEM script..." | ||
sleep 5 && exec bash /usr/share/andronix/firstrun | ||
#exit 1 | ||
fi | ||
|
||
response=$? | ||
case $response in | ||
0) clear; msg "Proceeding....";; | ||
1) clear; msg "Configuration aborted. Restarting OEM script..."; sleep 5 && exec bash /usr/share/andronix/firstrun;; | ||
255) clear; msg "Configuration aborted. Restarting OEM script..."; sleep 5 && exec bash /usr/share/andronix/firstrun;; | ||
esac | ||
|
||
create_oem_install | ||
|
||
msg "Configuration complete. Cleaning up..." | ||
# Here we export the DISPLAY variable for all know users | ||
echo "export DISPLAY=:1" >> /root/.bashrc && echo "export DISPLAY=:1" >> /home/$USER/.profile | ||
touch /home/$USER/.hushlogin | ||
# Here we overwrite .bash_login to drop the oem first run and the hack to redirect the user after the oem intaller has finished. | ||
echo "exec su - $USER" > $SWITCH | ||
echo "$SWITCH; exit" > /root/.bash_profile | ||
chmod +x $SWITCH | ||
if [ -e /etc/ssh/sshd_config ] | ||
then | ||
sed -i s/"PermitRootLogin yes"/"#PermitRootLogin prohibit-password"/g /etc/ssh/sshd_config | ||
fi | ||
msg "You can start using your newly installed Andronix Modded OS..." | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/.profile -O ~/.profile.1 > /dev/null | ||
cat ~/.profile.1 >> ~/.profile && rm -rf ~/.profile.1 | ||
echo "#!/bin/bash | ||
wget https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/xfce.sh -O ~/xfce.sh | ||
chmod +x ~/xfce.sh | ||
bash ~/xfce.sh | ||
rm -rf ~/.bash_profile" > /home/$USER/.bash_profile | ||
chmod +x /home/$USER/.bash_profile | ||
# Replace the current activity with a new shell for the user | ||
exec su - $USER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/data/data/com.termux/files/usr/bin/bash | ||
folder=ubuntu20-fs | ||
dlink="https://raw.githubusercontent.com/AndronixApp/AndronixOrigin/master/APT" | ||
if [ -d "$folder" ]; then | ||
first=1 | ||
echo "skipping downloading" | ||
fi | ||
tarball="ubuntu20-rootfs.tar.gz" | ||
|
||
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 | ||
aarch64) | ||
archurl="arm64" ;; | ||
arm) | ||
archurl="armhf" ;; | ||
amd64) | ||
archurl="amd64" ;; | ||
x86_64) | ||
archurl="amd64" ;; | ||
*) | ||
echo "unknown architecture"; exit 1 ;; | ||
esac | ||
wget "https://github.com/AndronixApp/AndronixOrigin/raw/master/Rootfs/Ubuntu20/focal-${archurl}.tar.gz" -O $tarball | ||
|
||
fi | ||
cur=`pwd` | ||
mkdir -p "$folder" | ||
cd "$folder" | ||
echo "Decompressing Rootfs, please be patient." | ||
proot --link2symlink tar -xf ${cur}/${tarball} --exclude=dev||: | ||
cd "$cur" | ||
fi | ||
mkdir -p ubuntu20-binds | ||
bin=start-ubuntu20.sh | ||
echo "writing launch script" | ||
cat > $bin <<- EOM | ||
#!/bin/bash | ||
cd \$(dirname \$0) | ||
pulseaudio -k >> /dev/null 2>&1 | ||
pulseaudio --start >> /dev/null 2>&1 | ||
## 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 ubuntu20-binds)" ]; then | ||
for f in ubuntu20-binds/* ;do | ||
. \$f | ||
done | ||
fi | ||
command+=" -b /dev" | ||
command+=" -b /proc" | ||
command+=" -b ubuntu20-fs/root:/dev/shm" | ||
## 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=en_US.UTF-8" | ||
command+=" LC_ALL=C" | ||
command+=" LANGUAGE=en_US" | ||
command+=" /bin/bash --login" | ||
com="\$@" | ||
if [ -z "\$1" ];then | ||
exec \$command | ||
else | ||
\$command -c "\$com" | ||
fi | ||
EOM | ||
|
||
mkdir -p ubuntu20-fs/usr/share/andronix | ||
mkdir -p ubuntu20-fs/var/tmp | ||
rm -rf ubuntu20-fs/usr/local/bin/* | ||
echo "127.0.0.1 localhost localhost" > $folder/etc/hosts | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/.profile -O ubuntu20-fs/root/.profile.1 > /dev/null | ||
cat $folder/root/.profile.1 >> $folder/root/.profile && rm -rf $folder/root/.profile.1 | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/.bash_profile -O ubuntu20-fs/root/.bash_profile > /dev/null | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/vnc -P ubuntu20-fs/usr/local/bin > /dev/null | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/vncpasswd -P ubuntu20-fs/usr/local/bin > /dev/null | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/vncserver-stop -P ubuntu20-fs/usr/local/bin > /dev/null | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/vncserver-start -P ubuntu20-fs/usr/local/bin > /dev/null | ||
wget -q https://raw.githubusercontent.com/tuanpham-dev/termux-ubuntu/master/firstrun -P ubuntu20-fs/usr/share/andronix > /dev/null | ||
|
||
chmod +x ubuntu20-fs/root/.bash_profile | ||
chmod +x ubuntu20-fs/root/.profile | ||
chmod +x ubuntu20-fs/usr/local/bin/vnc | ||
chmod +x ubuntu20-fs/usr/local/bin/vncpasswd | ||
chmod +x ubuntu20-fs/usr/local/bin/vncserver-start | ||
chmod +x ubuntu20-fs/usr/local/bin/vncserver-stop | ||
|
||
echo "fixing shebang of $bin" | ||
termux-fix-shebang $bin | ||
echo "making $bin executable" | ||
chmod +x $bin | ||
echo "removing image for some space" | ||
rm $tarball | ||
|
||
bash $bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
LD_PRELOAD=/lib/aarch64-linux-gnu/libgcc_s.so.1 vncserver -localhost no -depth 24 -name remote-desktop $GEO :$PORT | ||
echo "VNC server started. The default password is the account password for $USER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
read -sp 'Provide a new VNC password: ' PASSWORD | ||
/usr/bin/vncpasswd -f <<<"$PASSWORD"$'\n'"$PASSWORD" > $HOME/.vnc/passwd | ||
echo "" | ||
echo "Password for VNC changed" |
Oops, something went wrong.