forked from modded-ubuntu/modded-ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·138 lines (118 loc) · 4.15 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
R="$(printf '\033[1;31m')"
G="$(printf '\033[1;32m')"
Y="$(printf '\033[1;33m')"
B="$(printf '\033[1;34m')"
C="$(printf '\033[1;36m')"
W="$(printf '\033[1;37m')"
CURR_DIR=$(realpath "$(dirname "$BASH_SOURCE")")
UBUNTU_DIR="$PREFIX/var/lib/proot-distro/installed-rootfs/ubuntu"
banner() {
clear
cat <<- EOF
${Y} _ _ ___ _ _ _ _ ___ _ _ _ _ ____ ___
${C} | | |__] | | |\ | | | | |\/| | | | \
${G} |__| |__] |__| | \| | |__| | | |__| |__/
EOF
echo -e "${G} A modded gui version of ubuntu for Termux\n\n"${W}
}
package() {
banner
echo -e "${R} [${W}-${R}]${C} Checking required packages..."${W}
[ ! -d '/data/data/com.termux/files/home/storage' ] && echo -e "${R} [${W}-${R}]${C} Setting up Storage.."${W} && termux-setup-storage
if [[ $(command -v pulseaudio) && $(command -v proot-distro) ]]; then
echo -e "\n${R} [${W}-${R}]${G} Packages already installed."${W}
else
yes | pkg upgrade
packs=(pulseaudio proot-distro)
for x in "${packs[@]}"; do
type -p "$x" &>/dev/null || {
echo -e "\n${R} [${W}-${R}]${G} Installing package : ${Y}$x${C}"${W}
yes | pkg install "$x"
}
done
fi
}
distro() {
echo -e "\n${R} [${W}-${R}]${C} Checking for Distro..."${W}
termux-reload-settings
if [[ -d "$UBUNTU_DIR" ]]; then
echo -e "\n${R} [${W}-${R}]${G} Distro already installed."${W}
exit 0
else
proot-distro install ubuntu
termux-reload-settings
fi
if [[ -d "$UBUNTU_DIR" ]]; then
echo -e "\n${R} [${W}-${R}]${G} Installed Successfully !!"${W}
else
echo -e "\n${R} [${W}-${R}]${G} Error Installing Distro !\n"${W}
exit 0
fi
}
sound() {
echo -e "\n${R} [${W}-${R}]${C} Fixing Sound Problem..."${W}
[ ! -e "$HOME/.sound" ] && touch "$HOME/.sound"
echo "pacmd load-module module-aaudio-sink" >> "$HOME/.sound"
echo "pulseaudio --start --exit-idle-time=-1" >> "$HOME/.sound"
echo "pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" >> "$HOME/.sound"
}
downloader(){
path="$1"
[ -e "$path" ] && rm -rf "$path"
echo "Downloading $(basename $1)..."
curl --progress-bar --insecure --fail \
--retry-connrefused --retry 3 --retry-delay 2 \
--location --output ${path} "$2"
echo
}
setup_vnc() {
if [[ -d "$CURR_DIR/distro" ]] && [[ -e "$CURR_DIR/distro/vncstart" ]]; then
cp -f "$CURR_DIR/distro/vncstart" "$UBUNTU_DIR/usr/local/bin/vncstart"
else
downloader "$CURR_DIR/vncstart" "https://raw.githubusercontent.com/modded-ubuntu/modded-ubuntu/master/distro/vncstart"
mv -f "$CURR_DIR/vncstart" "$UBUNTU_DIR/usr/local/bin/vncstart"
fi
if [[ -d "$CURR_DIR/distro" ]] && [[ -e "$CURR_DIR/distro/vncstop" ]]; then
cp -f "$CURR_DIR/distro/vncstop" "$UBUNTU_DIR/usr/local/bin/vncstop"
else
downloader "$CURR_DIR/vncstop" "https://raw.githubusercontent.com/modded-ubuntu/modded-ubuntu/master/distro/vncstop"
mv -f "$CURR_DIR/vncstop" "$UBUNTU_DIR/usr/local/bin/vncstop"
fi
chmod +x "$UBUNTU_DIR/usr/local/bin/vncstart"
chmod +x "$UBUNTU_DIR/usr/local/bin/vncstop"
}
permission() {
banner
echo -e "${R} [${W}-${R}]${C} Setting up Environment..."${W}
if [[ -d "$CURR_DIR/distro" ]] && [[ -e "$CURR_DIR/distro/user.sh" ]]; then
cp -f "$CURR_DIR/distro/user.sh" "$UBUNTU_DIR/root/user.sh"
else
downloader "$CURR_DIR/user.sh" "https://raw.githubusercontent.com/modded-ubuntu/modded-ubuntu/master/distro/user.sh"
mv -f "$CURR_DIR/user.sh" "$UBUNTU_DIR/root/user.sh"
fi
chmod +x $UBUNTU_DIR/root/user.sh
setup_vnc
echo "$(getprop persist.sys.timezone)" > $UBUNTU_DIR/etc/timezone
echo "proot-distro login ubuntu" > $PREFIX/bin/ubuntu
chmod +x "$PREFIX/bin/ubuntu"
termux-reload-settings
if [[ -e "$PREFIX/bin/ubuntu" ]]; then
banner
cat <<- EOF
${R} [${W}-${R}]${G} Ubuntu-22.04 (CLI) is now Installed on your Termux
${R} [${W}-${R}]${G} Restart your Termux to Prevent Some Issues.
${R} [${W}-${R}]${G} Type ${C}ubuntu${G} to run Ubuntu CLI.
${R} [${W}-${R}]${G} If you Want to Use UBUNTU in GUI MODE then ,
${R} [${W}-${R}]${G} Run ${C}ubuntu${G} first & then type ${C}bash user.sh${W}
EOF
{ echo; sleep 2; exit 1; }
else
echo -e "\n${R} [${W}-${R}]${G} Error Installing Distro !"${W}
exit 0
fi
}
package
distro
sound
permission