-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
110 lines (97 loc) · 3.04 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
#!/bin/bash
source vars.sh
storage_check() {
if [[ -d "$HOME/storage/" ]]; then
echo -e "$info Internal storage already set"
else
echo -e "$warn You must grant internal storage permission : ${R}termux-setup-storage${reset}"
termux-setup-storage
fi
}
package() {
echo -e "$info Checking required package : (${W}proot-distro pulseaudio tigervnc xorg-xhost${reset})"
if [[ `command -v pulseaudio` && `command -v proot-distro` && `command -v xhost` && `command -v vncserver` ]]; then
echo -e "$info Packages already installed."
else
apt update -y > out.log 2> err.log
apt upgrade -y > out.log 2> err.log
packs=(which pulseaudio proot-distro tigervnc x11-repo xorg-xhost)
for pkgname in "${packs[@]}"; do
type -p "$pkgname" &>/dev/null || {
echo -e "$info Installing package : ${C}${pkgname}${reset}"
execcom "apt install $pkgname -y" > out.log 2> err.log
}
done
fi
}
remove_distro() {
execcom "proot-distro remove archlinux"
execcom "pkg uninstall pulseaudio proot-distro tigervnc x11-repo xorg-xhost -y"
execcom "apt autoremove -y"
execcom "rm $(which vncstart)"
execcom "rm $(which archlogin)"
return 1
}
env_install() {
echo -e "$info Setting up environment.."
echo -e "$info Generating sound server.."
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
cp -r distro-config $archdir/root/
chmod +x $archdir/root/distro-config/*
echo "proot-distro login archlinux --bind /dev/null:/proc/sys/kernel/cap_last_last --shared-tmp --fix-low-ports" > $PREFIX/bin/archlogin
chmod +x $PREFIX/bin/archlogin
echo -e "$info Command to login to your distro : ${G}archlogin${reset}"
echo -e "$info Command to setting up a user after logging in: ${G}bash set_user.sh${reset}"
echo -e "$warn Restart your termux first to prevent some issue"
}
distro() {
echo -e "$info Checking for distro : ${C}archlinux${reset} (120MB)"
termux-reload-settings
mkdir -p $archdir
if [[ `ls $archdir` != "" ]]; then
echo -e "$info Distro already installed."
echo -e "$info Command to login to your distro : ${G}archlogin${reset}"
printf "$quest What you wanna do?
1${G})${reset} Reinstall environment
2${G})${reset} Uninstall distro
B${G})${reset} I don't know..
: "
read reins
case "$reins" in
1)
echo -e "$warn Reinstalling.."
env_install
;;
2)
echo -e "$info Uninstalling.."
remove_distro
;;
*) echo -e "$info Cancelling.."; return 1 ;;
esac
return 1
else
rm -r $archdir
printf "$quest Do you sure to install it? (y/n) "
read sure
if [[ `echo "$sure" | tr '[:upper:]' '[:lower:]'` == "y" ]]; then
echo -e "$info Installing.."
execcom "proot-distro install archlinux"
execcom "termux-reload-settings"
else
echo -e "$err Cancelled."
return 1
fi
fi
if [[ `ls $archdir` != "" ]]; then
echo -e "$info Successfully installed : ${C}archlinux${reset}"
env_install
else
echo -e "$err Error Installing Distro"
return 1
fi
}
banner
storage_check
package
distro