-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-initial-install.sh
More file actions
executable file
·263 lines (217 loc) · 8.16 KB
/
01-initial-install.sh
File metadata and controls
executable file
·263 lines (217 loc) · 8.16 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/bash
RED="\033[1;31m"
GREEN="\033[1;32m"
NOCOLOR="\033[0m"
set -e
#
# #################################################################
#
# Written to be used on 64 bits Linux computers (Ubuntu & Debian)
# Author : Petitsurfeur
# Website : https://www.petitsurfeur.net
#
# Modified by :
# Version : v2.5
# Start date : 16/06/2017
# Last modified date: 02/09/2023
#
# #################################################################
###################################################################
#
# DO NOT JUST RUN THIS. EXAMINE AND JUDGE. RUN AT YOUR OWN RISK.
#
###################################################################
# Library Path
LIBRARYPATH=libraries
# Load Libraries
for file in $LIBRARYPATH/*.sh; do
# Source Libraries
source $file
done
# Check if root
if [[ "$EUID" -ne 0 ]];
then
error "Desole, vous devez etre ROOT !"
exit
fi
#echo ""
#header "### System Configuration ###"
#header "### ###"
#header "### Variables Definitions ###"
export script_PWD=$PWD
#clear
# Ajouter infos actuels dans banner
ActualIP=$(ip a | grep brd | grep inet)
echo -e ""
echo -e "**********************************************"
echo -e "--> Actuellement le nom de machine est "${RED}$(hostname -f)${NOCOLOR}""
echo -e "--> Son IP est "${RED}$ActualIP}${NOCOLOR}""
echo -e "**********************************************"
echo -e ""
echo ""
header "### Configure Time ###"
if [ ! -f /etc/localtime.SAVE ]; then
mv /etc/localtime /etc/localtime.SAVE
ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
fi
echo -e "${GREEN}L'heure systeme est ${NOCOLOR} $(date)"
echo ""
read -p "Voulez-vous ajouter/parametrer un utilisateur [O/n] ? " user_choice
if [[ "$user_choice" = 'O' ]]; then
read -p "Quel est le nom d'utilisateur (ex: admin) : " user_add
export user_add=$user_add
if [ ! -d /home/$user_add/ ]; then
adduser $user_add
usermod -a -G adm,sudo,www-data $user_add
echo -e "${GREEN}L'utilisateur $user_add a ete cree et ajoute aux groupes adm, sudo et www-data${NOCOLOR}"
else echo -e "${GREEN}L'utilisateur $user_add existe deja et il a ete ajoute aux groupes adm, sudo et www-data${NOCOLOR}"
usermod -a -G adm,sudo,www-data $user_add
fi
fi
echo ""
header "### System Update ###"
read -p "Voulez-vous mettre a jour le systeme [O/n] ? " upgrade_choice
if [[ "$upgrade_choice" = 'O' ]]; then
apt update -y && apt upgrade -y
sleep 2
fi
echo ""
header "### Usefull packets installation ###"
packages='unrar-free unzip hardinfo hwinfo htop tree locate git curl net-tools dirmngr ca-certificates gnupg iptables openssl wget curl sudo lshw'
#echo ""
read -p "Voulez-vous installer les paquets suivants (utiles) : $packages [O/n] ? " packages_choice
if [[ "$packages_choice" = 'O' ]]; then
apt-get install -y $packages
sleep 2
fi
echo ""
echo -e "--> Actuellement le nom de machine est "${RED}$(hostname -s)${NOCOLOR}" et le Full Name est "${RED}$(hostname -f)${NOCOLOR}""
read -p "Voulez-vous changer le hostname ou fullname ? [O/n] ? " hostname_conf_choice
if [[ "$hostname_conf_choice" = O ]];
then
if [[ ! -f /etc/hostname.SAVE ]]; then
cp /etc/hostname /etc/hostname.SAVE && echo $fqdn > /etc/hostname
fi
if [[ ! -f /etc/mailname.SAVE ]] & [[ -f /etc/mailname ]]; then
cp /etc/mailname /etc/mailname.SAVE && echo $dns > /etc/mailname
fi
if [[ ! -f /etc/hosts.SAVE ]]; then
cp /etc/hosts /etc/hosts.SAVE
fi
read -p "Nom du serveur (ex: tatooine) : " server_name
read -p "Nom de domaine utilise (ex: dns.net) : " dns
read -p "DNS complet (ex: tatooine.dns.net) : " fqdn
read -p "Email du serveur (server@xx.net) : " server_email
read -p "Email du destinataire (admin@xxx.xx) : " admin_email
export server_name=$server_name
export dns=$dns
export fqdn=$fqdn
export server_email=$server_email
export admin_email=$admin_email
export ActualFullHostname=$(hostname -f)
hostnamectl set-hostname $fqdn
hostname -F /etc/hostname
else
ActualFullHostname=$(hostname -f)
ActualServerName=$(hostname -s)
fi
echo ""
read -p "S'agit-il d'un serveur Proxmox (modifier l'apt source pve-enterprise.list) [O/n) ? " proxmox_choice
if [[ "$proxmox_choice" = 'O' ]] && [ -f /etc/apt/sources.list.d/pve-enterprise.list ]; then
cp /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.SAVE
sed -i -e 's/pve-enterprise/pve-no-subscription/' '/etc/apt/sources.list.d/pve-enterprise.list'
fi
echo ""
read -p "Voulez-vous planifier la mise a jour quotidienne du Systeme ? (Copie du script System_Update dans /root) [O/n] ?" update_install_script
if [[ "$update_install_script" = 'O' ]]; then
cd $script_PWD/update/ && ./install_update.sh
fi
echo ""
read -p "Voulez-vous installer rsyslog [O/n] ? " install_rsyslog
if [[ "$install_rsyslog" = 'O' ]]; then
apt install -y rsyslog
fi
echo ""
echo -e "${GREEN}################################################################"
echo "### Pre-requis installes ###"
echo -e "################################################################${NOCOLOR}"
echo ""
echo ""
header "### Configuration de GIT avec des couleurs ###"
read -p "Voulez-vous installer/configurer Git [O/n] : " git_install
if [[ "$git_install" = 'O' ]]; then
read -p "Utilisateur Git : " git_user
read -p "Email pour Git : " git_email
# read -p "--> Dossier d'installation du Repo GIT (ex: /opt/Git_Repos): " git_folder
# if [[ ! -d /$git_folder ]]; then
# mkdir $git_folder && cd /$git_folder
# fi
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global user.name $git_user
git config --global user.mail $git_email
# git clone https://github.com/petitsurfeur/cybit-script.git
fi
echo ""
#read -p "Dossier d'installation du Repo GIT (ex: /opt/Git_Repos): " git_folder
# if [[ ! -d /$git_folder ]]; then
# mkdir $git_folder && cd /$git_folder
# fi
echo ""
header "### Installation et configuration des outils tiers ###"
echo ""
read -p "Voulez-vous installer Vim [O/n] ? " vim_choice
if [[ "$vim_choice" = 'O' ]]; then
cd $script_PWD/vim/ && ./install_vim.sh
fi
echo ""
read -p "Voulez-vous installer SSH Server [O/n] ? " ssh_choice
if [[ "$ssh_choice" = 'O' ]]; then
cd $script_PWD/ssh/ && ./install_ssh.sh
fi
### Deprecated with Ubuntu and ZSH
#echo ""
#read -p "Voulez-vous configurer .bashrc [O/n] ? " bashrc_choice
# if [[ "$bashrc_choice" = 'O' ]]; then
# cd $script_PWD/bashrc && ./install_bashrc.sh
# fi
#echo ""
#read -p "Voulez-vous installer Exim4 [O/n] ? " exim4_choice
# if [[ "$exim4_choice" = 'O' ]]; then
# cd $script_PWD/exim4 && ./install_exim4.sh
# fi
echo ""
read -p "Voulez-vous installer Apticron [O/n] ? " apticron_choice
if [[ "$apticron_choice" = 'O' ]]; then
cd $script_PWD/apticron && ./install_apticron.sh
fi
echo ""
read -p "Voulez-vous installer Fail2ban [O/n] ? " fail2ban_choice
if [[ "$fail2ban_choice" = 'O' ]]; then
cd $script_PWD/fail2ban && ./install_fail2ban.sh
fi
echo ""
read -p "Voulez-vous installer UFW [O/n] ? " ufw_choice
if [[ "$ufw_choice" = 'O' ]]; then
cd $script_PWD/firewall && ./install_firewall.sh
fi
#echo ""
#read -p "Voulez-vous installer OpenVPN [O/n] ? " openvpn_choice
# if [[ "$openvpn_choice" = 'O' ]]; then
# cd $script_PWD/openvpn && ./install_openvpn_server.sh
# fi
echo ""
read -p "Voulez-vous installer Zsh [O/n] ? " zsh_choice
if [[ "$zsh_choice" = 'O' ]]; then
cd $script_PWD/zsh && ./install_zsh.sh
fi
echo ""
echo -e "${GREEN}################################################################"
echo "### Installation terminee ###"
echo -e "################################################################${NOCOLOR}"
echo ""
read -p "Voulez-vous redemarrer [O/n] ? " reboot
if [[ "$reboot" = 'O' ]]; then
shutdown -r now
fi