-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·221 lines (174 loc) · 6.47 KB
/
install.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/data/data/com.termux/files/usr/bin/bash
## Author : Michael Haslam
## Mail : hreikin@gmail.com
## License : MIT
# Fail on error and report it, debug all lines.
set -eu -o pipefail
config_base () {
# Setup storage permissions.
echo "Setting up required storage permissions."
echo "Please grant termux storage permissions."
termux-setup-storage
sleep 2
# Setup mirrors.
echo "Please select/configure your default mirrors."
sleep 2
termux-change-repo
# Update and upgrade termux, install termux-api package.
echo "Updating and installing base packages."
pkg update -y && pkg upgrade -y
pkg install -y binutils build-essential curl git htop nano ncurses-utils openssh termux-api
# Create and link user directories.
mkdir "$HOME"/Desktop
mkdir "$HOME"/Downloads
mkdir "$HOME"/Templates
mkdir "$HOME"/Public
mkdir "$HOME"/Documents
mkdir "$HOME"/Pictures
mkdir "$HOME"/Videos
mkdir "$HOME"/Music
ln -s "$HOME"/storage/music/ "$HOME"/Music
ln -s "$HOME"/storage/downloads/ "$HOME"/Downloads
ln -s "$HOME"/storage/dcim/ "$HOME"/Pictures
# Add custom PS1 to bashrc.
echo "# Custom PS1 prompt." >> "$HOME"/.bashrc
echo "export PS1=\"\[\033[38;5;11m\]\u\[$(tput sgr0)\]@\h:\[$(tput sgr0)\]\[\033[38;5;6m\][\w]\[$(tput sgr0)\]: \[$(tput sgr0)\]\"" >> "$HOME"/.bashrc
}
config_minimal () {
# Enable the tur-repository.
pkg install -y tur-repo
pkg update -y && pkg upgrade -y
# Install minimal set of packages.
pkg install -y micro code-server
# Configuring Micro code editor and installing plugins.
echo "Configuring Micro code editor and installing plugins."
micro -plugin install autofmt detectindent filemanager manipulator quoter snippets
# Set filemanager plugin to show by default.
sed -i '/config.RegisterCommonOption("filemanager", "openonstart", false)/c\config.RegisterCommonOption("filemanager", "openonstart", true)' "$HOME"/.config/micro/plug/filemanager/filemanager.lua
}
config_desktop () {
# Enable X11 repository.
echo "Enabling X11 repository."
pkg install -y x11-repo
pkg update -y && pkg upgrade -y
# Install required dependencies
echo "Installing XFCE desktop and basic packages."
pkg install -y code-oss firefox leafpad python python-tkinter xclip xfce4 xfce4-terminal
}
config_vnc () {
# Update and install tigervnc.
pkg update -y && pkg upgrade -y
pkg install -y tigervnc
# Configuring VNC server.
echo "Configuring VNC server."
echo "When prompted please provide a VNC password. Note that passwords are not visible when you are typing them and maximum password length is 8 characters."
vncserver -localhost
echo "#!/data/data/com.termux/files/usr/bin/sh" > "$HOME"/.vnc/xstartup
echo "xfce4-session &" >> "$HOME"/.vnc/xstartup
echo "geometry=1920x1080" >> "$HOME"/.vnc/config
echo "# VNC display variable." >> "$HOME"/.bashrc
echo "export DISPLAY=\":1\"" >> "$HOME"/.bashrc
vncserver -kill :1
}
config_xserver () {
echo "Configuring Xserver."
echo "# Xserver display variable." >> "$HOME"/.bashrc
echo "export DISPLAY=localhost:0" >> "$HOME"/.bashrc
}
# Minimal and desktop installation completed messages.
MINIMAL_MSG="
Minimal installation is now complete.
Code Server Instructions
To start code-server use the following command:
code-server &
This will run code-server in the background and generate a default config.yaml file on first run.
The password used to access code-server in the browser can be found using the config.yaml file
available at:
~/.config/code-server/config.yaml
Next open a browser and go to the following address:
https//127.0.0.1:8080
Detailed usage instructions can be found at the following github repository:
https://githb.com/hreikin/termux-dev-setups
Please quit Termux using the 'exit' command and then restart the app.
"
DESKTOP_VNC_MSG="
Desktop installation is now complete. To view the installed desktop you will need to use a VNC
viewer installed on Android.
VNC Instructions
To start the VNC server use the following command:
vncserver
To view running VNC servers use the following command:
vncserver -list
To stop a VNC server running on display 1 use the following command:
vncserver -kill :1
Detailed usage instructions can be found at the following github repository:
https://githb.com/hreikin/termux-dev-setups
Please quit Termux using the 'exit' command and then restart the app.
"
DESKTOP_XSERVER_MSG="
Desktop installation is now complete. To view the installed desktop you will need to use an Xserver
client installed on Android.
Xserver Instructions
To start the XFCE desktop run one of the following commands:
startxfce4 &
xfce4-session &
Then open your Xserver app on Android to view the desktop.
You can also launch single applications such as code-oss or firefox like so:
xfwm4 & code-oss
xfwm4 & firefox
Detailed usage instructions can be found at the following github repository:
https://githb.com/hreikin/termux-dev-setups
Please quit Termux using the 'exit' command and then restart the app.
"
# Create dialog menu for option selection.
TERMINAL=$(tty)
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="termux-dev-setups"
TITLE="Installation"
MENU="Please choose one of the following options, use the ARROW keys to navigate and press ENTER to select your option:"
OPTIONS=(1 "Minimal"
2 "Desktop (VNC)"
3 "Desktop (Xserver)")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >"$TERMINAL")
clear
case $CHOICE in
1)
clear
echo "Starting \"Minimal\" installation."
config_base
config_minimal
source "$HOME"/.bashrc
clear
echo "$MINIMAL_MSG"
;;
2)
clear
echo "Starting \"Desktop (VNC)\" installation."
config_base
config_minimal
config_desktop
config_vnc
source "$HOME"/.bashrc
clear
echo "$DESKTOP_VNC_MSG"
;;
3)
clear
echo "Starting \"Desktop (Xserver)\" installation."
config_base
config_minimal
config_desktop
config_xserver
source "$HOME"/.bashrc
clear
echo "$DESKTOP_XSERVER_MSG"
;;
esac