Skip to content
Snippets Groups Projects
Commit 03152235 authored by David Beniamine's avatar David Beniamine
Browse files

Merge branch 'services-desk-81-redistributivite-securimag' into 'master'

Services desk 81 redistributivite securimag

See merge request !21
parents 29243588 a2eef749
No related branches found
No related tags found
1 merge request!21Services desk 81 redistributivite securimag
# NoCloud Auto Installer
NoCloud-Auto-Installer is designed to automatically install all applications for the [NoCloud solution](https://gitlab.tetras-libre.fr/nocloud).
NoCloud-Auto-Installer is modular, it allows you to have a dockerized or non-dockerized installation and to deploy the desired services.
## Environnement
All configuration is on .env.main.sample. By default, this environnement is configure to feat with Tétras-libre's needs
## Install
1. intall `apt-get install vim git tmux`
2. `tmux new -s installation`
3. `cd /opt; git clone https://gitlab.tetras-libre.fr/nocloud/NoCloud-Auto-Installer; ln -s /opt/NoCloud-Auto-Installer /root`
4. `cd NoCloud-Auto-Installer`
5. `cp main.env.sample main.env`
6. Edit the 'main.env' file to put the right modules and domains do not touch the 'MAINTENANCE_LEVEL' **if you dont do that, Tetras Libre get access to your server**
7. `bash run.sh`
8. Test the connection with the ssh key (in case of hosting by OVH, remove the waring in '.ssh/authorized_keys')
9. **Delete temporary user as needed** `deluser [user] && rm -r /home/[user]`
10. `. main.env; bash validate.sh`
11. Put your ssh key in `/root/.ssh/authorized_keys` if needed
If dockerweb doesn't have the right uid, you can chaange it **only if it's not already in use** thanks to:
```sh
groupmod -g 1000 dockerweb
usermod -u 1000 -g 1000 dockerweb
id dockerweb
```
At this point, you have a NoCloud server ready with the intended modules not configured and no DNS
11. Set up your DNS through your provider
12. `apt dist-upgrade`
13. Reboot
14. `/opt/NoCloud-Auto-Installer/validate.sh`
15. Reverse DNS configuration (in the OVH order or at the ISP depending on the order)
16. Sending a test email `echo -e "Subject: test\n\nThis is a test" | sendmail -t root` and check its receipt
Well done.
## Backup
Tu backup your services data you can use [duplicity-ftp-backup](https://gitlab.tetras-libre.fr/nocloud/duplicity-ftp-backup). All needed informaiton in readme of repository.
## Upgrade
1. `sudo tmux`
2. `cd /root/NoCloud-Auto-Installer; git pull; bash upgrade/All.sh`
3. Let it unfold and answer the question individually
4. À la fin vérifier sur chaque serveur en commencant
1. That Rkhunter only displays green messages (if necessary, look in `/var/log/rkhunter.log`)
2. Clamav detects nothing but fishing for people with their email on nextcloud
3. The host names displayed for each client are accessible (`liste-domain.txt | xargs firefox`)
4. Stop the maintenance service `cd /home/dockerweb/maintenance; docker-compose down`
5. Troubleshoot any issues
## Licence
This program is distributed under GPLV3 Licence, see `Licence.txt`
# NoCloud Auto Installer
NoCloud-Auto-Installer est conçu pour installer automatiquement l'ensemble des
applications pour la solution NoCloud.
Deux types d'installations sont possibles :
* Full installation : permet d'installer la totalité des packages pour la
Solution NoCloud.
* Installe les paquets pour Apache2, Certbot, Php
* Installe et configure MySql
* Installation automatisé de Nextcloud :
* Création de la database Nextcloud.
* Création de l'utilisateur Nextcloud.
* Création de l'utilisateur Admin pour Nextcloud
* Ajoute un fichier de préconfiguration pour l'accès à Nexcloud dans
apache.
* Installation automatisé de Dolibarr à partir du fichier d'installation de
debian.
* Installation automatisé de TetrasBack à partir du dépot TetrasBack de Tétras-Libre
* Installation sélective : permet d'installer l'outil voulu.
## Pré-requis
NoCloud-Auto-Installer a été testé sur Debian Jessie.
Pas de pré-requis nécessaires.
## Installation
### Full script
L'installation totale du système se fait en trois temps :
1. Configuration des variables d'environnement pour chaque logiciel à
installer.<br/>
A chaque fichier SH correspond un fichier ENV qui contient l'ensemble des
variables que l'installeur peut personnaliser.<br/>
Pour chaque variable existantes il existe une valeur par défaut. Donc si un
oubli est fait la valeur par défaut est utilisée.
2. Exécution automatisé des outils via ``sh run.sh``
3. Actions Post installation.
1. DNS + réseau
2. Finalisation Dolibarr
3. Ajout les certificats SSL
4. Extractions MDP vers keepass
### Selective script
L'installation d'un script spécifique se fait aussi en trois étapes.
1. Configuration du ENV du script à faire tourner
2. Exécution de la commande avec le script voulu :
* Mysql : ``sh initInstall.sh && sh installMySQL.sh``
* Nextcloud :
``sh initInstall.sh && sh installMySQL.sh && sh installNextcloud.sh``
* Dolibarr :
``sh initInstall.sh && sh installMySQL.sh && sh installDolibarr.sh``
* TetrasBack : ``sh initInstall.sh && sh installTetrasBack.sh``
3. Faire la post installationd du script
### Actions post installation
#### MySql
* Vérifier le fichier /root/.my.cnf
* Le sauvegarder dans un lieu sûr. (Attention TetraBack a besoin de ce fichier
pour fonctionner correctement)
#### Nextcloud
* Activer l'accès à Nextcloud sur via apache2
#### Dolibarr
* Ouvrir le navigateur pour aller sur Dolibarr et finaliser l'installation via
l'interface web.
#### TetrasBack
* Installation a partir du dépot de Tétras-Libre
## Mises à jour
Le script `upgradeAll.sh`, met à jour tous les logiciels installés via cet
installer.
### Nextcloud
Le script `upgradeNextcloud.sh` met nextcloud à jour depuis la dernière version
stable depuis les dépots nextcloud.
En cas de lenteur en accés webdav aux fichiers depuis windows, il est possible d'utiliser [la solution décrite ici](https://help.nextcloud.com/t/trouble-with-webdav-performance/36423/5), nous ne recommandons pas ce réglage par défaut car il rends la base de donnée moins résiliante aux crash
### Tetras-back
Le script `upgradeTetras-back.sh` met Tetras-Back à jour en clonant la version
dans le gitlab tetras-libre.
### Dolibarr
Le script `upgradeDolibarr.sh` met Dolibarr à jour depuis la version deb
contenue dans ce dépot.
## Project
### TODO
+ [x] Ajouter clé maintenance de tetrix
+ [x] Permettre root sans password
+ [x] ufw permettre http https et ssh seulement.
+ [x] ClamAv en daemon
+ [x] HealthReport
+ [x] installation MySQL automatisée
+ [x] Mot de passe root aléatoire ou prédéfinie
+ [x] sauvegarde des informations de log dans /root/.my.cnf
+ [ ] installation de Nextcloud
+ [x] Installation des fichiers de configuration pour apache2
+ [ ] Activation nextcloud sur apache
+ [x] Variables de spécialisation installation Nextcloud
+ [x] Installation Dolibarr
+ [x] Installation TetrasBack
## Licence
This program is distributed under GPLV3 Licence, see `Licence.txt`
...@@ -118,7 +118,11 @@ bash $DIR/checks/rkhunter.sh ...@@ -118,7 +118,11 @@ bash $DIR/checks/rkhunter.sh
# Allow maintenance operations: # Allow maintenance operations:
mkdir -p /root/.ssh mkdir -p /root/.ssh
if [ "$TETRAS_MAINTENANCE" = true ] ; then
cat id_rsa.pub >> /root/.ssh/authorized_keys cat id_rsa.pub >> /root/.ssh/authorized_keys
else
touch /root/.ssh/authorized_keys
fi
chmod 600 /root/.ssh/authorized_keys chmod 600 /root/.ssh/authorized_keys
#Ssh #Ssh
......
# Listes of modules : Base GlpiAgent WebServer MySQL Nextcloud Collabora Dolibarr TetrasBack # Listes of modules : Base GlpiAgent WebServer MySQL Nextcloud Collabora Dolibarr TetrasBack
# You always need : Base GlpiAgent # You always need : Base
# To use Docker you need : Traefik # To use Docker you need : Traefik
export MODS="Base GlpiAgent Traefik" export MODS="Base GlpiAgent Traefik"
...@@ -8,11 +8,22 @@ export MODS="Base GlpiAgent Traefik" ...@@ -8,11 +8,22 @@ export MODS="Base GlpiAgent Traefik"
# Valid levels are security and upgrade # Valid levels are security and upgrade
export MAINTENANCE_LEVEL="security" export MAINTENANCE_LEVEL="security"
# TODO change domain for you domaine of server # TODO change domain for you domain of server
export DOMAIN="dev.tetras-libre.fr" export DOMAIN="dev.tetras-libre.fr"
# TODO change admin mail
export SERVER_ADMIN="sysadmin@tetras-libre.fr" export SERVER_ADMIN="sysadmin@tetras-libre.fr"
# TODO put this variable to false if tetras does not provide maintenance
# This has the consequence of whether or not the Tetras-Libre ssh public key is added to the authorized keys
export TETRAS_MAINTENANCE=true
# TODO change ignore domains for fail2ban
export IGNORE_DOMAINS=(
"tetrix.tetras-libre.fr"
"piculus.tetras-libre.fr"
)
# can be set to nginx # can be set to nginx
export WEB_SERVER="apache2" export WEB_SERVER="apache2"
# You can define here some services that are badly detected by checkrestart # You can define here some services that are badly detected by checkrestart
......
#!/bin/bash #!/bin/bash
set -o nounset # Treat unset variables as an error
echo "RUN $(basename "$0") ===" echo "RUN $(basename "$0") ==="
DIR=$(realpath $(dirname $0)/..)
if [ ! -e $DIR/main.env ]
then
echo "Please copy in root of NoCloud Auto Installer main.env.sample to main.env and edit it"
exit 1
else
echo "Environment file loaded"
fi
. $DIR/main.env
if [ -z "$(grep '^alias ls=' /root/.bashrc)" ] if [ -z "$(grep '^alias ls=' /root/.bashrc)" ]
then then
...@@ -35,10 +47,21 @@ syntax on ...@@ -35,10 +47,21 @@ syntax on
filetype plugin indent on filetype plugin indent on
EOF EOF
ignoreips=()
for domain in "${IGNORE_DOMAINS[@]}"; do
# Use dig to get the IP address
ip=$(dig +short "$domain")
ignoreips=("${ignoreips[@]}" $ip)
# Displays the domain name and IP addresss
echo "$domain : $ip"
done
cat <<EOF > /etc/fail2ban/jail.local cat <<EOF > /etc/fail2ban/jail.local
[DEFAULT] [DEFAULT]
# Ignore Tetras Libre IPs ignoreip = 127.0.0.1/8 ::1 ${ignoreips[@]} $(docker network inspect traefik | awk '/Subnet/{print $2}' | sed -e 's/"//g' -e 's/,$//')
ignoreip = 127.0.0.1/8 ::1 $(dig +short servermon.tetras-libre.fr | tail -n 1) $(dig +short tetrix.tetras-libre.fr | tail -n 1) $(docker network inspect traefik | awk '/Subnet/{print $2}' | sed -e 's/"//g' -e 's/,$//')
EOF EOF
fail2ban-client reload fail2ban-client reload
#!/usr/bin/env bash
set -o nounset # Treat unset variables as an error
echo "RUN $(basename "$0") ==="
DIR=$(realpath $(dirname $0)/..)
if [ ! -e $DIR/main.env ]
then
echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it"
exit 1
else
echo "Environment file loaded"
fi
. $DIR/main.env
ignoreips=()
for domain in "${IGNORE_DOMAINS[@]}"; do
# Use dig to get the IP address
ip=$(dig +short "$domain")
ignoreips=("${ignoreips[@]}" $ip)
# Displays the domain name and IP address
echo "$domain : $ip"
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment