-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00-pre-installation.sh
executable file
·218 lines (175 loc) · 5.31 KB
/
00-pre-installation.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
#!/bin/bash
# Check if the current user is root
if [ "$(id -u)" != "0" ]; then
echo -e "\033[31mThis script must be run as root. \nPlease run again with 'sudo $0'\033[0m"
exit 1
fi
# Function to draw a progress bar
progress_bar() {
# Parameters: current step, total steps
local current_step=$1
local total_steps=$2
local progress=$((current_step * 100 / total_steps))
local filled=$((progress * 50 / 100)) # Assuming 50 characters wide bar
local empty=$((50 - filled))
echo -ne "\r\033[32m["
printf "%-${filled}s" '' | tr ' ' '#'
printf "%-${empty}s" '' | tr ' ' '-'
printf "] \033[33m%d%% (%d/%d)\033[0m \n" $progress $current_step $total_steps
if [ $current_step -eq $total_steps ]; then
echo "" # Print a new line at the end of the progress
fi
}
# Initialize step and total steps variables
step=1
total_steps=10 # Adjust based on the actual number of steps you have
upgrade_system() {
echo -e "\033[32mUpdating and upgrading system...\033[0m"
apt update && sudo apt dist-upgrade -y
sleep 1
progress_bar $step $total_steps
((step++))
}
install_dependencies() {
echo -e "\033[32mInstalling dependencies...\033[0m"
apt install -y \
vim \
curl \
net-tools \
iw \
lm-sensors \
conky \
tmux \
screen \
htop \
tree \
iperf3 \
timeshift \
cheese \
ffmpeg \
jq
# net-tools --- for network configuration
# iw --- for wireless network configuration
# lm-sensors --- for device temperature monitoring
# conky --- for system monitoring panel
# iperf3 --- for network performance testing
# timeshift --- for system snapshot and restore
# cheese --- for camera testing
# ffmpeg --- for audio and video processing (ex. boot-on sound)
# jq --- for JSON parsing
sleep 1
progress_bar $step $total_steps
((step++))
}
# Fix for USB device detection issue
# | Reference:
# | https://askubuntu.com/questions/1403705/dev-ttyusb0-not-present-in-ubuntu-22-04
remove_brltty() {
echo -e "\033[32mRemoving brltty...\033[0m"
apt remove -y brltty
sleep 1
progress_bar $step $total_steps
((step++))
}
# Install Docker Engine
install_docker() {
echo -e "\033[32mInstalling Docker...\033[0m"
curl -fsSL https://get.docker.com -o get-docker.sh
sh ./get-docker.sh
rm get-docker.sh
groupadd docker
usermod -aG docker ditrobotics
newgrp docker # optional
sleep 1
progress_bar $step $total_steps
((step++))
}
# Setup Conky system monitoring panel
setup_conky() {
echo -e "\033[32mSetting up conky...\033[0m"
./10-conky_setup.sh
sleep 1
progress_bar $step $total_steps
((step++))
}
# Setup Message of the MOTD banner
setup_motd_banner() {
echo -e "\033[32mSetting up motd banner...\033[0m"
./10-motd_setup.sh
sleep 1
progress_bar $step $total_steps
((step++))
}
# Setup DIT user group
create_user() {
echo -e "\033[32mCreate each group user and set their permission...\033[0m"
./10-user_setup.sh
sleep 1
progress_bar $step $total_steps
((step++))
}
# Setup DIT logger (System change information for each group)
setup_dit_logger() {
echo -e "\033[32mSetting up DIT logger...\033[0m"
./env_setup.sh
sleep 1
progress_bar $step $total_steps
((step++))
}
# Setup touch screen orientation
flip_screen() {
echo -e "\033[32mSetting up touch screen HID layout...\033[0m"
read -p "Would you like to rotate touch screen? (y/N): " answer
case $answer in
[Yy]* )
echo 'ATTRS{name}=="wch.cn USB2IIC_CTP_CONTROL", ENV{LIBINPUT_CALIBRATION_MATRIX}="-1.000 0.000 1.000 0.000 -1.000 1.000"' >> /etc/udev/rules.d/80-calibration.rules
udevadm control --reload-rules
udevadm trigger
service udev restart
;;
* )
echo "The screen layout will remain default."
;;
esac
sleep 1
progress_bar $step $total_steps
((step++))
}
# Restore firefox user preference
restore_firefox() {
echo -e "\033[32mRestoring firefox user preference...\033[0m"
find /home/ditrobotics/snap/firefox/common/.mozilla/firefox/ -type d -name "*.default" -exec cp -r /home/ditrobotics/DIT-Scripts/.mozilla/firefox/dit_config.default/* {} \;
sleep 1
progress_bar $step $total_steps
((step++))
}
# Add more steps as necessary...
cd /home/ditrobotics/DIT-Scripts
echo -e "\033[32mStarting pre-installation setup process...\033[0m"
for ((i=step; i<=total_steps; i++)); do
case $i in
1) upgrade_system;;
2) install_dependencies;;
3) remove_brltty;;
4) install_docker;;
5) setup_conky;;
6) setup_motd_banner;;
7) create_user;;
8) setup_dit_logger;;
9) flip_screen;;
10) restore_firefox;;
*) echo -e "\033[31mInvalid step\033[0m";;
esac
done
echo -e "\033[32mSetup complete. Please review any manual actions required.\033[0m"
MOTD="
1) Please check /etc/update-motd.d/99-dit-news Wi-Fi card model
2) Please check /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf wifi.powersave = 2
3) Please check your touch screen rotated or not
REBOOT YOUR SYSTEM!!!
IF ALL LOOKS GOOD, THEN CHECK THE FOLLOWING ITEM
A) Do your first timeshift
B) Use Clonezilla backup to external SSD
C) ...
"
echo "$MOTD"