-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_basics.sh
More file actions
executable file
·214 lines (177 loc) · 4.03 KB
/
02_basics.sh
File metadata and controls
executable file
·214 lines (177 loc) · 4.03 KB
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
#!/bin/bash
set -e
CPU_TYPE=$(uname -m)
if [[ "$EUID" == 0 ]]; then
echo "Please run as normal user (w/o sudo)"
exit
fi
term_color_red () {
echo -e "\e[91m"
}
term_color_white () {
echo -e "\e[39m"
}
confirmation(){
term_color_red
echo "Install some basic packages"
echo "Do you want to install? (y/n)"
term_color_white
echo
read -n 1 ans
echo
if [[ ! $ans == "y" ]]; then
exit 1
fi
}
install_basic_packages(){
term_color_red
echo "Install basic packages"
term_color_white
sudo apt update
sudo apt install -y \
zsh \
vim \
git \
ncal \
ncdu \
htop \
bpytop \
curl \
tree \
udev \
iotop \
unzip \
psmisc \
keychain \
fastfetch \
bash-completion \
command-not-found \
jq \
fzf \
rsync \
ranger \
ripgrep \
progress \
xmlstarlet \
aptitude \
pipewire-audio \
console-setup
# autofs \
# powerline \
# https://manpages.debian.org/stretch/lm-sensors/sensors-detect.8.en.html
# https://wiki.archlinux.org/title/lm_sensors
# Please run `sudo sensors-detect --auto` to create the config file automatically
sudo apt install -y \
lm-sensors
}
install_daemon_packages(){
term_color_red
echo "Install some daemon packages"
term_color_white
sudo apt install -y \
openssh-server \
avahi-daemon \
avahi-utils
}
install_network_packages(){
term_color_red
echo "Install network packages"
term_color_white
sudo apt install -y \
ufw \
bmon \
nmap \
sshfs \
fail2ban \
net-tools \
wireless-tools
}
install_nvim_base(){
term_color_red
echo "Install Python for nvim"
term_color_white
sudo apt install -y \
python3-pip \
python3-dev \
python-is-python3
}
install_bluetooth_packages(){
term_color_red
echo "Install Bluetooth packages"
term_color_white
sudo apt install -y \
bluez \
bluetooth \
bluez-tools
sudo systemctl enable bluetooth.service
sudo systemctl start bluetooth.service
sudo usermod -aG bluetooth $USER
}
install_platform_specific_packages(){
term_color_red
echo "Install platform specific packages"
term_color_white
# if [[ $OS_TYPE =~ "Debian" ]]; then
# sudo apt install -y \
# software-properties-common
# fi
if [[ $CPU_TYPE == "x86_64" ]]; then
echo
elif [[ $CPU_TYPE == "aarch64" ]]; then
echo "Install for Raspbian OS"
sudo apt install -y \
file \
pi-bluetooth
fi
}
cleanup(){
term_color_red
echo "Cleanup"
term_color_white
sudo apt autoremove -y
}
update_capslock(){
term_color_red
echo "Update Capslock to nocaps"
term_color_white
sudo bash -c "echo 'XKBOPTIONS=ctrl:nocaps' >> /etc/default/keyboard"
setupcon -k
}
update_ssh_port(){
term_color_red
echo "Update sshd port"
term_color_white
# Port update
sudo bash -c "sed -i '/#Port 22/c\Port 2222' /etc/ssh/sshd_config"
# No DNS for better performance
sudo bash -c "sed -i '/#UseDNS no/c\UseDNS no' /etc/ssh/sshd_config"
}
update_timeout(){
term_color_red
echo "Update default timeout to stop from 90s to 7s"
term_color_white
sudo bash -c "sed -i '/#DefaultTimeoutStopSec=90s/c\DefaultTimeoutStopSec=7s' /etc/systemd/system.conf"
}
post(){
term_color_red
echo "1. SSH port number is changed"
echo "2. Source your .bashrc (source ~/.bashrc)"
echo "3. Capslock is disabled"
echo "4. Try neofetch"
echo
echo "Done"
term_color_white
}
trap term_color_white EXIT
confirmation
install_basic_packages
install_daemon_packages
install_network_packages
install_nvim_base
install_bluetooth_packages
install_platform_specific_packages
cleanup
update_capslock
update_ssh_port
update_timeout
post