Initial import: Alpine cloud-init configs
This commit is contained in:
2
alpine/meta-data
Normal file
2
alpine/meta-data
Normal file
@@ -0,0 +1,2 @@
|
||||
instance-id: 7f99e7b4-5aae-cc1c-61fa-a66f9ebe6844
|
||||
|
||||
34
alpine/scripts/bojemoiVM.sh
Executable file
34
alpine/scripts/bojemoiVM.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/ash
|
||||
# wget http://bojemoi.me/cloud-init/alpine/bojemoiVM.sh -O -| ash
|
||||
echo "-------------------------------------------------------"
|
||||
echo " etape 2 : vous venez d'installer votre VM sous alpine "
|
||||
echo " maintemamt vous installez cloud-init"
|
||||
echo "-------------------------------------------------------"
|
||||
|
||||
setup-apkrepos -cf
|
||||
apk update
|
||||
apk upgrade
|
||||
apk add xe-guest-utilities
|
||||
rc-update add xe-guest-utilities default
|
||||
/etc/init.d/xe-guest-utilities start
|
||||
|
||||
apk add cloud-init
|
||||
rc-update add cloud-init default
|
||||
|
||||
rm /etc/cloud/cloud.cfg.d/10-datasource.cfg
|
||||
|
||||
wget http://bojemoi.me/cloud-init/cloud.cfg.d/10_datasource.cfg -O /etc/cloud/cloud.cfg.d/10-datasource.cfg
|
||||
#
|
||||
# # Vérifiez si la commande scp a réussi
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Les fichiers ont été copiés avec succès."
|
||||
else
|
||||
echo "Une erreur s'est produite lors de la copie des fichiers."
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
setup-cloud-init
|
||||
cloud-init clean
|
||||
#reboot
|
||||
|
||||
|
||||
86
alpine/scripts/installation-suricata.sh
Normal file
86
alpine/scripts/installation-suricata.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/bin/sh
|
||||
# Script d'installation de Suricata avec règles sous Alpine Linux
|
||||
# Auteur: Claude
|
||||
# Date: 14 Avril 2025
|
||||
|
||||
set -e
|
||||
echo "============================================"
|
||||
echo "Installation de Suricata sous Alpine Linux"
|
||||
echo "============================================"
|
||||
|
||||
# Vérification si l'utilisateur est root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Ce script doit être exécuté en tant que root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mise à jour des dépôts
|
||||
echo "[+] Mise à jour des dépôts..."
|
||||
apk update
|
||||
|
||||
# Installation des dépendances
|
||||
echo "[+] Installation des dépendances..."
|
||||
apk add --no-cache \
|
||||
suricata \
|
||||
python3 \
|
||||
py3-pip \
|
||||
curl \
|
||||
wget \
|
||||
ca-certificates \
|
||||
jq \
|
||||
tar \
|
||||
libnfnetlink \
|
||||
libnetfilter_queue \
|
||||
libpcap \
|
||||
libelf \
|
||||
yaml \
|
||||
pcre \
|
||||
file-dev \
|
||||
hiredis \
|
||||
jansson \
|
||||
git
|
||||
|
||||
# Installation de suricata-update via pip
|
||||
echo "[+] Installation de suricata-update..."
|
||||
pip3 install --no-cache-dir suricata-update
|
||||
|
||||
# Création des répertoires nécessaires
|
||||
echo "[+] Création des répertoires nécessaires..."
|
||||
mkdir -p /etc/suricata/rules
|
||||
mkdir -p /var/lib/suricata/rules
|
||||
mkdir -p /var/log/suricata
|
||||
|
||||
# Sauvegarde de la configuration originale si elle existe
|
||||
if [ -f /etc/suricata/suricata.yaml ]; then
|
||||
echo "[+] Sauvegarde de la configuration existante..."
|
||||
cp /etc/suricata/suricata.yaml /etc/suricata/suricata.yaml.bak
|
||||
fi
|
||||
|
||||
# Configuration de base de Suricata
|
||||
echo "[+] Configuration de Suricata..."
|
||||
cat > /etc/suricata/suricata.yaml << 'EOF'
|
||||
%YAML 1.1
|
||||
---
|
||||
# Voici la configuration de base pour Suricata
|
||||
|
||||
vars:
|
||||
# Plus de definición de variables específicas
|
||||
address-groups:
|
||||
HOME_NET: "[192.168.0.0/16,10.0.0.0/8,172.16.0.0/12]"
|
||||
EXTERNAL_NET: "!$HOME_NET"
|
||||
HTTP_SERVERS: "$HOME_NET"
|
||||
SMTP_SERVERS: "$HOME_NET"
|
||||
SQL_SERVERS: "$HOME_NET"
|
||||
DNS_SERVERS: "$HOME_NET"
|
||||
TELNET_SERVERS: "$HOME_NET"
|
||||
AIM_SERVERS: "$EXTERNAL_NET"
|
||||
port-groups:
|
||||
HTTP_PORTS: "80"
|
||||
SHELLCODE_PORTS: "!80"
|
||||
ORACLE_PORTS: 1521
|
||||
SSH_PORTS: 22
|
||||
|
||||
# Configuration des répertoires par défaut
|
||||
default-rule-path: /var/lib/suricata/rules
|
||||
rule-files:
|
||||
- suricata.rules
|
||||
132
alpine/user-data
Executable file
132
alpine/user-data
Executable file
@@ -0,0 +1,132 @@
|
||||
#cloud-config
|
||||
# vim: syntax=yaml
|
||||
|
||||
hostname: meta-76
|
||||
manage_etc_hosts: false
|
||||
|
||||
groups:
|
||||
- meta: yoh1
|
||||
|
||||
# Configuration des utilisateurs
|
||||
users:
|
||||
- default
|
||||
- name: yoh1
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
groups: meta
|
||||
passwd: $6$Cvg/O/hpkWgpCvLd$z6awusyCE39i.JzjNfDvJPbxyEHu4rXSVUjQZJL8OGKOWpQNfe3iS1S7/7zstZcHhIIy.VzoC/V5YLQ7SYFA.0
|
||||
lock_passwd: false
|
||||
- name: docker
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
groups: meta
|
||||
passwd: $6$dMo0oCFfhDf2velN$cq258FKXOjyFTZR64Uow5m/LWdaoU5peYaqIJPE0dpMiKRCo.2JRtVnuRu8.dWZaghkpnfnfaC.lclWNk1d6t.
|
||||
lock_passwd: false
|
||||
|
||||
# Mise à jour des paquets et installation des dépendances
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
|
||||
packages:
|
||||
- fail2ban
|
||||
- postgresql14-contrib
|
||||
- nmap
|
||||
- docker
|
||||
- docker-cli-compose
|
||||
- xe-guest-utilities
|
||||
# Commandes avant boot
|
||||
bootcmd:
|
||||
- modprobe bonding
|
||||
|
||||
runcmd:
|
||||
- rc-update add docker default
|
||||
- rc-update add xe-guest-utilities default
|
||||
- rc-service docker start
|
||||
- rc-service xe-guest-utilities start
|
||||
- rc-update add local boot
|
||||
# - /etc/local.d/bonding-setup.start
|
||||
|
||||
# Attendre que le réseau soit stable
|
||||
- sleep 5
|
||||
|
||||
# Configurer Docker
|
||||
- rc-update add docker boot
|
||||
- rc-service docker start
|
||||
|
||||
# Initialiser Swarm
|
||||
- docker swarm init --advertise-addr bond0 || logger "Swarm already initialized or failed"
|
||||
|
||||
# Logs de diagnostic
|
||||
- ip addr > /var/log/network-post-init.log
|
||||
- ip route > /var/log/routes-post-init.log
|
||||
- cat /proc/net/bonding/bond0 > /var/log/bond-post-init.log 2>&1 || echo "Bond not ready" > /var/log/bond-post-init.log
|
||||
- docker info > /var/log/docker-info.log 2>&1
|
||||
|
||||
|
||||
write_files:
|
||||
- path: /etc/motd
|
||||
content: |
|
||||
Bienvenue sur bojemoi
|
||||
# Fichiers de configuration
|
||||
write_files:
|
||||
- path: /etc/modules
|
||||
content: |
|
||||
bonding
|
||||
xen_netfront
|
||||
append: true
|
||||
|
||||
- path: /etc/modprobe.d/bonding.conf
|
||||
content: |
|
||||
alias bond0 bonding
|
||||
options bonding mode=1 miimon=100 use_carrier=1
|
||||
permissions: '0644'
|
||||
|
||||
- path: /etc/local.d/bonding-setup.start
|
||||
permissions: '0755'
|
||||
content: |
|
||||
#!/bin/sh
|
||||
# Setup bonding
|
||||
logger "Starting bonding setup"
|
||||
|
||||
# Charger le module si pas déjà fait
|
||||
modprobe bonding 2>/dev/null || true
|
||||
|
||||
# Créer bond0 si n'existe pas
|
||||
if ! ip link show bond0 >/dev/null 2>&1; then
|
||||
ip link add bond0 type bond mode active-backup miimon 100 primary eth0
|
||||
logger "Bond0 created"
|
||||
fi
|
||||
|
||||
# S'assurer que les interfaces sont down
|
||||
ip link set eth0 down 2>/dev/null
|
||||
ip link set eth1 down 2>/dev/null
|
||||
|
||||
# Attacher les interfaces au bond
|
||||
ip link set eth0 master bond0 2>/dev/null || echo "+eth0" > /sys/class/net/bond0/bonding/slaves
|
||||
ip link set eth1 master bond0 2>/dev/null || echo "+eth1" > /sys/class/net/bond0/bonding/slaves
|
||||
|
||||
# Activer les interfaces
|
||||
ip link set eth0 up
|
||||
ip link set eth1 up
|
||||
ip link set bond0 up
|
||||
|
||||
logger "Bonding setup complete"
|
||||
|
||||
# Log status
|
||||
sleep 2
|
||||
cat /proc/net/bonding/bond0 > /var/log/bond0-init.log 2>&1
|
||||
|
||||
- path: /etc/docker/daemon.json
|
||||
content: |
|
||||
{
|
||||
"metrics-addr": "0.0.0.0:9323",
|
||||
"experimental": true,
|
||||
"log-driver": "json-file",
|
||||
"log-opts": {
|
||||
"max-size": "10m",
|
||||
"max-file": "3"
|
||||
}
|
||||
}
|
||||
permissions: '0644'
|
||||
|
||||
|
||||
# Afficher un message final à l'utilisateur après l'installation
|
||||
final_message: "L'installation est terminée avec succès ! Accédez à l'interface {ip}"
|
||||
Reference in New Issue
Block a user