Compare commits
20 Commits
1b7173b824
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 48c26f9f84 | |||
| 70facd85f3 | |||
| 5eda1c002e | |||
| 24a45fecf3 | |||
| 1b758b6161 | |||
| b75afa7df8 | |||
| 58b6a44819 | |||
| 8e882c7756 | |||
| b8808e4219 | |||
| 5375a48bfd | |||
| 4936d3c8e7 | |||
| 3d64c538af | |||
| d9c2e20402 | |||
| 12cbbd0a6a | |||
| bd74da92ff | |||
| 5e663d8925 | |||
| 2f0831aa09 | |||
| cad29cdc71 | |||
| eabf6c042e | |||
| ca73246a47 |
@@ -1,5 +1,7 @@
|
|||||||
|
all_inclusive
|
||||||
common
|
common
|
||||||
server-dhcp
|
server-dhcp
|
||||||
server-httpd
|
server-httpd
|
||||||
server-mail
|
server-mail
|
||||||
server-mariadb
|
server-mariadb
|
||||||
|
server-postgres
|
||||||
|
|||||||
1
scripts/all_inclusive/.list_files.txt
Normal file
1
scripts/all_inclusive/.list_files.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
lychee_install.sh
|
||||||
159
scripts/all_inclusive/lychee_install.sh
Normal file
159
scripts/all_inclusive/lychee_install.sh
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Vérifier que le script est lancé en root
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "Ce script doit être exécuté en tant que root." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Définir les variables
|
||||||
|
DB_NAME="lychee"
|
||||||
|
DB_USER="lycheeuser"
|
||||||
|
LYCHEE_DIR="/var/www/lychee"
|
||||||
|
APACHE_CONF="/etc/apache2/sites-available/lychee.conf"
|
||||||
|
PHP_VERSION="8.3"
|
||||||
|
|
||||||
|
PHP_INI_CLI="/etc/php/${PHP_VERSION}/cli/php.ini"
|
||||||
|
PHP_INI_APACHE="/etc/php/${PHP_VERSION}/apache2/php.ini"
|
||||||
|
|
||||||
|
TIMEZONE=$(timedatectl show --value --property=Timezone)
|
||||||
|
|
||||||
|
# Générer un mot de passe alphanumérique sécurisé
|
||||||
|
DB_PASSWORD=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 16)
|
||||||
|
echo "Mot de passe généré pour la base de données : ${DB_PASSWORD}"
|
||||||
|
|
||||||
|
# Sauvegarde temporaire root-only
|
||||||
|
echo "${DB_PASSWORD}" > /root/.lychee_db_password
|
||||||
|
chmod 600 /root/.lychee_db_password
|
||||||
|
|
||||||
|
# Mise à jour du système
|
||||||
|
apt update && apt upgrade -y
|
||||||
|
|
||||||
|
# Ajout du dépôt Sury pour PHP 8.3
|
||||||
|
apt install -y apt-transport-https lsb-release ca-certificates wget gnupg2
|
||||||
|
wget -qO - https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/php.gpg
|
||||||
|
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
|
||||||
|
apt update
|
||||||
|
|
||||||
|
# Installation des paquets nécessaires
|
||||||
|
apt install -y apache2 mariadb-server php${PHP_VERSION} php${PHP_VERSION}-cli php${PHP_VERSION}-intl php${PHP_VERSION}-xmlrpc \
|
||||||
|
php${PHP_VERSION}-soap php${PHP_VERSION}-mysql php${PHP_VERSION}-zip php${PHP_VERSION}-gd php${PHP_VERSION}-tidy \
|
||||||
|
php${PHP_VERSION}-mbstring php${PHP_VERSION}-curl php${PHP_VERSION}-xml php${PHP_VERSION}-bcmath php${PHP_VERSION}-imagick \
|
||||||
|
php${PHP_VERSION}-tokenizer libapache2-mod-php${PHP_VERSION} unzip
|
||||||
|
|
||||||
|
# Définir la timezone PHP pour CLI et Apache
|
||||||
|
sed -i "s|^;*date.timezone =.*|date.timezone = ${TIMEZONE}|" "${PHP_INI_CLI}"
|
||||||
|
sed -i "s|^;*date.timezone =.*|date.timezone = ${TIMEZONE}|" "${PHP_INI_APACHE}"
|
||||||
|
|
||||||
|
# Sécuriser MariaDB
|
||||||
|
mysql_secure_installation <<EOF
|
||||||
|
|
||||||
|
y
|
||||||
|
n
|
||||||
|
y
|
||||||
|
y
|
||||||
|
y
|
||||||
|
y
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Créer la base et l'utilisateur avec droits restreints
|
||||||
|
mysql <<EOF
|
||||||
|
CREATE DATABASE ${DB_NAME} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASSWORD}';
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON ${DB_NAME}.* TO '${DB_USER}'@'localhost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Télécharger et installer Lychee proprement
|
||||||
|
cd /tmp
|
||||||
|
wget https://github.com/LycheeOrg/Lychee/releases/latest/download/Lychee.zip
|
||||||
|
unzip Lychee.zip
|
||||||
|
rm -rf ${LYCHEE_DIR}
|
||||||
|
mv Lychee ${LYCHEE_DIR}
|
||||||
|
rm Lychee.zip
|
||||||
|
|
||||||
|
# Demander le nom de domaine ou l'IP publique
|
||||||
|
read -p "Entrez le nom de domaine ou l'adresse IP d'accès à Lychee (ex: lychee.mondomaine.fr ou 192.168.1.100) : " LYCHEE_HOST
|
||||||
|
|
||||||
|
# Forcer le protocole HTTP pour APP_URL
|
||||||
|
APP_URL="http://${LYCHEE_HOST}"
|
||||||
|
|
||||||
|
# Modification du .env
|
||||||
|
cp ${LYCHEE_DIR}/.env.example ${LYCHEE_DIR}/.env
|
||||||
|
|
||||||
|
sed -i "s|^APP_URL=.*|APP_URL=${APP_URL}|" ${LYCHEE_DIR}/.env
|
||||||
|
sed -i "s|^DB_CONNECTION=.*|DB_CONNECTION=mysql|" ${LYCHEE_DIR}/.env
|
||||||
|
sed -i "s|^DB_HOST=.*|DB_HOST=127.0.0.1|" ${LYCHEE_DIR}/.env
|
||||||
|
sed -i "s|^DB_PORT=.*|DB_PORT=3306|" ${LYCHEE_DIR}/.env
|
||||||
|
sed -i "s|^#*DB_DATABASE=.*|DB_DATABASE=${DB_NAME}|" ${LYCHEE_DIR}/.env
|
||||||
|
sed -i "s|^#*DB_USERNAME=.*|DB_USERNAME=${DB_USER}|" ${LYCHEE_DIR}/.env
|
||||||
|
sed -i "s|^#*DB_PASSWORD=.*|DB_PASSWORD=\"${DB_PASSWORD}\"|" ${LYCHEE_DIR}/.env
|
||||||
|
|
||||||
|
# Définir le fuseau horaire
|
||||||
|
echo "APP_TIMEZONE=Europe/Paris" >> ${LYCHEE_DIR}/.env
|
||||||
|
|
||||||
|
# Propriétés et permissions
|
||||||
|
chown -R www-data:www-data ${LYCHEE_DIR}
|
||||||
|
chmod 640 ${LYCHEE_DIR}/.env
|
||||||
|
find ${LYCHEE_DIR} -type f -exec chmod 640 {} \;
|
||||||
|
find ${LYCHEE_DIR} -type d -exec chmod 750 {} \;
|
||||||
|
|
||||||
|
# Permissions spécifiques pour data/upload
|
||||||
|
chmod -R 750 ${LYCHEE_DIR}/uploads/ ${LYCHEE_DIR}/data/
|
||||||
|
|
||||||
|
# Permissions spécifiques attendues par Lychee
|
||||||
|
chmod -R g+s ${LYCHEE_DIR}/public/uploads
|
||||||
|
chmod -R g+s ${LYCHEE_DIR}/public/sym
|
||||||
|
chmod 2775 ${LYCHEE_DIR}/public/uploads
|
||||||
|
chmod 2775 ${LYCHEE_DIR}/public/uploads/import
|
||||||
|
chmod 2775 ${LYCHEE_DIR}/public/sym
|
||||||
|
chmod 0664 ${LYCHEE_DIR}/public/uploads/import/index.html
|
||||||
|
chmod 0664 ${LYCHEE_DIR}/public/sym/index.html
|
||||||
|
chmod 2775 ${LYCHEE_DIR}/storage/tmp/jobs
|
||||||
|
chmod 2775 ${LYCHEE_DIR}/storage/tmp/uploads
|
||||||
|
chmod -R g+s ${LYCHEE_DIR}/storage/tmp/jobs
|
||||||
|
chmod -R g+s ${LYCHEE_DIR}/storage/tmp/uploads
|
||||||
|
|
||||||
|
# Protéger les fichiers sensibles via .htaccess
|
||||||
|
cat > ${LYCHEE_DIR}/.htaccess <<EOF
|
||||||
|
<FilesMatch "\.(env|env\.example|sql|log|conf)$">
|
||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
||||||
|
</FilesMatch>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Configuration Apache
|
||||||
|
cat > ${APACHE_CONF} <<EOF
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot ${LYCHEE_DIR}/public
|
||||||
|
|
||||||
|
<Directory ${LYCHEE_DIR}/public>
|
||||||
|
Options -Indexes +FollowSymLinks
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog \${APACHE_LOG_DIR}/lychee_error.log
|
||||||
|
CustomLog \${APACHE_LOG_DIR}/lychee_access.log combined
|
||||||
|
|
||||||
|
LimitRequestBody 10485760
|
||||||
|
</VirtualHost>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Désactiver modules inutiles
|
||||||
|
a2dismod -f autoindex status cgi userdir
|
||||||
|
|
||||||
|
# Activer Lychee et désactiver le site par défaut
|
||||||
|
a2enmod rewrite
|
||||||
|
a2ensite lychee.conf
|
||||||
|
a2dissite 000-default.conf
|
||||||
|
|
||||||
|
# Recharger Apache
|
||||||
|
systemctl reload apache2
|
||||||
|
|
||||||
|
# Déterminer l'IP locale
|
||||||
|
IP=$(hostname -I | awk '{print $1}')
|
||||||
|
|
||||||
|
echo "Installation de Lychee terminée."
|
||||||
|
echo "Accédez à l’interface web pour finaliser la configuration : http://${IP}"
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
common_utils.sh
|
common_utils.sh
|
||||||
setup_debian.sh
|
setup_debian.sh
|
||||||
|
setup_mdns.sh
|
||||||
|
|||||||
@@ -78,17 +78,18 @@ check_dns() {
|
|||||||
if [[ -z "$FQDN_IP" ]]; then
|
if [[ -z "$FQDN_IP" ]]; then
|
||||||
echo "❌ Erreur : Impossible de récupérer l'adresse IP associée à $server_name via DIG."
|
echo "❌ Erreur : Impossible de récupérer l'adresse IP associée à $server_name via DIG."
|
||||||
echo "➡️ Vérifie la configuration DNS et l'existence du domaine."
|
echo "➡️ Vérifie la configuration DNS et l'existence du domaine."
|
||||||
exit 1
|
return 1 # Erreur bloquante uniquement ici
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Comparaison des IPs
|
# Comparaison des IPs mais uniquement en Alerte non bloquante
|
||||||
if [[ "$SERVER_IP" != "$FQDN_IP" ]]; then
|
if [[ "$SERVER_IP" != "$FQDN_IP" ]]; then
|
||||||
echo "⚠️ Alerte DNS : L'adresse IP résolue ($FQDN_IP) ne correspond pas à l'IP publique actuelle ($SERVER_IP)."
|
echo "⚠️ Alerte DNS : L'adresse IP résolue ($FQDN_IP) ne correspond pas à l'IP publique actuelle ($SERVER_IP)."
|
||||||
echo "➡️ Vérifie la configuration DNS et la propagation des enregistrements."
|
echo "➡️ Vérifie la configuration DNS et la propagation si nécessaire."
|
||||||
exit 1
|
else
|
||||||
|
echo "✅ Vérification réussie : $server_name pointe correctement vers $SERVER_IP."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ Vérification réussie : $server_name pointe correctement vers $SERVER_IP."
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,19 @@ configure_locales() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configure_timezone() {
|
||||||
|
echo "Détection de la timezone via l'IP publique..."
|
||||||
|
TIMEZONE=$(curl -s https://ipinfo.io/timezone)
|
||||||
|
|
||||||
|
# Définir la timezone via timedatectl
|
||||||
|
echo "Définition de la timezone à : $TIMEZONE"
|
||||||
|
timedatectl set-timezone "$TIMEZONE"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_paquets() {
|
||||||
|
apt install -y curl
|
||||||
|
}
|
||||||
|
|
||||||
### SECTION PRINCIPALE : Activer/Désactiver les options ici
|
### SECTION PRINCIPALE : Activer/Désactiver les options ici
|
||||||
update_system
|
update_system
|
||||||
install_sudo
|
install_sudo
|
||||||
@@ -145,6 +158,8 @@ add_admin_user
|
|||||||
configure_ssh
|
configure_ssh
|
||||||
install_fail2ban
|
install_fail2ban
|
||||||
configure_locales
|
configure_locales
|
||||||
|
install_paquets
|
||||||
|
configure_timezone
|
||||||
|
|
||||||
echo "Installation et configuration de base terminées."
|
echo "Installation et configuration de base terminées."
|
||||||
echo "Vous pouvez maintenant vous connecter avec l'utilisateur : $NEW_USER"
|
echo "Vous pouvez maintenant vous connecter avec l'utilisateur : $NEW_USER"
|
||||||
11
scripts/server-httpd/add_domain.sh
Normal file → Executable file
11
scripts/server-httpd/add_domain.sh
Normal file → Executable file
@@ -9,16 +9,15 @@ source "$(dirname "$0")/../common/common_utils.sh"
|
|||||||
# Vérifier si le script est exécuté en root
|
# Vérifier si le script est exécuté en root
|
||||||
check_root
|
check_root
|
||||||
|
|
||||||
# Vérification DNS
|
# Vérification DNS (alerte non bloquante)
|
||||||
check_dns "$DOMAIN"
|
if ! check_dns "$DOMAIN"; then
|
||||||
|
echo "⚠️ Attention : Résolution DNS impossible pour $DOMAIN. Vérifie si c'est bien ce que tu veux."
|
||||||
|
fi
|
||||||
|
|
||||||
REVERSED_DOMAIN=$(echo "$DOMAIN" | awk -F. '{for(i=NF; i>0; i--) printf "%s%s", $i, (i>1 ? "." : "")}')
|
REVERSED_DOMAIN=$(echo "$DOMAIN" | awk -F. '{for(i=NF; i>0; i--) printf "%s%s", $i, (i>1 ? "." : "")}')
|
||||||
VHOST_CONF="/etc/apache2/sites-available/$REVERSED_DOMAIN.conf"
|
VHOST_CONF="/etc/apache2/sites-available/$REVERSED_DOMAIN.conf"
|
||||||
|
|
||||||
# Créer les dossiers nécessaires
|
# Préparer le dossier du VirtualHost
|
||||||
mkdir -p "$BACKUP_DIR" "$TEMPLATE_DIR" "$CHALLENGE_DIR"
|
|
||||||
chown -R www-data:www-data "$CHALLENGE_DIR"
|
|
||||||
|
|
||||||
mkdir -p "/var/www/$REVERSED_DOMAIN"
|
mkdir -p "/var/www/$REVERSED_DOMAIN"
|
||||||
chown -R www-data:www-data "/var/www/$REVERSED_DOMAIN"
|
chown -R www-data:www-data "/var/www/$REVERSED_DOMAIN"
|
||||||
chmod -R 755 "/var/www/$REVERSED_DOMAIN"
|
chmod -R 755 "/var/www/$REVERSED_DOMAIN"
|
||||||
|
|||||||
0
scripts/server-httpd/add_domain_ssl.sh
Normal file → Executable file
0
scripts/server-httpd/add_domain_ssl.sh
Normal file → Executable file
91
scripts/server-httpd/install-php8-3.sh
Normal file → Executable file
91
scripts/server-httpd/install-php8-3.sh
Normal file → Executable file
@@ -20,6 +20,8 @@ apt update && apt upgrade -y || { echo -e "${RED}Échec de la mise à jour des p
|
|||||||
VERSION=$(lsb_release -sc)
|
VERSION=$(lsb_release -sc)
|
||||||
SUPPORTED_VERSIONS=("buster" "bullseye" "bookworm")
|
SUPPORTED_VERSIONS=("buster" "bullseye" "bookworm")
|
||||||
|
|
||||||
|
TIMEZONE=$(timedatectl show --value --property=Timezone)
|
||||||
|
|
||||||
if [[ ! " ${SUPPORTED_VERSIONS[@]} " =~ " ${VERSION} " ]]; then
|
if [[ ! " ${SUPPORTED_VERSIONS[@]} " =~ " ${VERSION} " ]]; then
|
||||||
echo -e "${RED}Version de Debian non supportée : $VERSION${RESET}"
|
echo -e "${RED}Version de Debian non supportée : $VERSION${RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -41,13 +43,53 @@ fi
|
|||||||
# Définition de la version PHP souhaitée
|
# Définition de la version PHP souhaitée
|
||||||
PHP_VERSION="8.3"
|
PHP_VERSION="8.3"
|
||||||
|
|
||||||
|
PHP_INI_CLI="/etc/php/${PHP_VERSION}/cli/php.ini"
|
||||||
|
PHP_INI_APACHE="/etc/php/${PHP_VERSION}/apache2/php.ini"
|
||||||
|
|
||||||
# Vérification de l'installation de PHP
|
# Vérification de l'installation de PHP
|
||||||
echo -e "${YELLOW}Installation de PHP $PHP_VERSION et des modules courants...${RESET}"
|
echo -e "${YELLOW}Installation de PHP $PHP_VERSION et des modules courants...${RESET}"
|
||||||
apt install -y php$PHP_VERSION php$PHP_VERSION-cli php$PHP_VERSION-fpm \
|
|
||||||
php$PHP_VERSION-mysql php$PHP_VERSION-curl php$PHP_VERSION-gd \
|
# Base des modules PHP à installer
|
||||||
php$PHP_VERSION-mbstring php$PHP_VERSION-xml php$PHP_VERSION-zip \
|
PHP_MODULES=(
|
||||||
php$PHP_VERSION-bcmath php$PHP_VERSION-soap php$PHP_VERSION-intl \
|
php${PHP_VERSION}
|
||||||
php$PHP_VERSION-readline php$PHP_VERSION-ldap php$PHP_VERSION-imagick || { echo -e "${RED}Échec de l'installation de PHP${RESET}"; exit 1; }
|
php${PHP_VERSION}-cli
|
||||||
|
php${PHP_VERSION}-fpm
|
||||||
|
php${PHP_VERSION}-curl
|
||||||
|
php${PHP_VERSION}-gd
|
||||||
|
php${PHP_VERSION}-mbstring
|
||||||
|
php${PHP_VERSION}-xml
|
||||||
|
php${PHP_VERSION}-zip
|
||||||
|
php${PHP_VERSION}-bcmath
|
||||||
|
php${PHP_VERSION}-soap
|
||||||
|
php${PHP_VERSION}-intl
|
||||||
|
php${PHP_VERSION}-readline
|
||||||
|
php${PHP_VERSION}-ldap
|
||||||
|
php${PHP_VERSION}-imagick
|
||||||
|
php${PHP_VERSION}-exif
|
||||||
|
php${PHP_VERSION}-gmp
|
||||||
|
php${PHP_VERSION}-apcu
|
||||||
|
php${PHP_VERSION}-opcache
|
||||||
|
php${PHP_VERSION}-sqlite3
|
||||||
|
)
|
||||||
|
|
||||||
|
# Vérification MySQL / MariaDB
|
||||||
|
if dpkg -l | grep -qE 'mysql-server|mariadb-server'; then
|
||||||
|
echo -e "${GREEN}MySQL/MariaDB détecté. Ajout du module php-mysql.${RESET}"
|
||||||
|
PHP_MODULES+=(php${PHP_VERSION}-mysql)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Vérification PostgreSQL
|
||||||
|
if dpkg -l | grep -q postgresql; then
|
||||||
|
echo -e "${GREEN}PostgreSQL détecté. Ajout du module php-pgsql.${RESET}"
|
||||||
|
PHP_MODULES+=(php${PHP_VERSION}-pgsql)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Installation des modules PHP
|
||||||
|
echo -e "${GREEN}Installation des modules PHP...${RESET}"
|
||||||
|
apt install -y "${PHP_MODULES[@]}" || {
|
||||||
|
echo -e "${RED}❌ Échec de l'installation de PHP ou des modules.${RESET}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Vérification si Apache est installé et installation du module PHP si nécessaire
|
# Vérification si Apache est installé et installation du module PHP si nécessaire
|
||||||
if systemctl list-units --type=service --all | grep -q "apache2.service"; then
|
if systemctl list-units --type=service --all | grep -q "apache2.service"; then
|
||||||
@@ -60,6 +102,7 @@ fi
|
|||||||
|
|
||||||
# Configuration de PHP-FPM si ce n'est pas déjà fait
|
# Configuration de PHP-FPM si ce n'est pas déjà fait
|
||||||
PHP_INI="/etc/php/$PHP_VERSION/fpm/php.ini"
|
PHP_INI="/etc/php/$PHP_VERSION/fpm/php.ini"
|
||||||
|
PHP_INI_DIR="/etc/php/${PHP_VERSION}/fpm/conf.d"
|
||||||
|
|
||||||
if grep -q "memory_limit = 512M" "$PHP_INI"; then
|
if grep -q "memory_limit = 512M" "$PHP_INI"; then
|
||||||
echo -e "${GREEN}Configuration de PHP-FPM déjà optimisée.${RESET}"
|
echo -e "${GREEN}Configuration de PHP-FPM déjà optimisée.${RESET}"
|
||||||
@@ -74,17 +117,49 @@ else
|
|||||||
systemctl restart php$PHP_VERSION-fpm || { echo -e "${RED}Échec du redémarrage de PHP-FPM${RESET}"; exit 1; }
|
systemctl restart php$PHP_VERSION-fpm || { echo -e "${RED}Échec du redémarrage de PHP-FPM${RESET}"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vérification des modules PHP installés
|
# Configuration OPCache
|
||||||
echo -e "${GREEN}Modules PHP installés :${RESET}"
|
OPCACHE_INI="${PHP_INI_DIR}/10-opcache.ini"
|
||||||
php -m
|
cat > "$OPCACHE_INI" <<EOF
|
||||||
|
; Configuration OPcache optimisée
|
||||||
|
opcache.enable=1
|
||||||
|
opcache.memory_consumption=128
|
||||||
|
opcache.interned_strings_buffer=16
|
||||||
|
opcache.max_accelerated_files=10000
|
||||||
|
opcache.revalidate_freq=60
|
||||||
|
opcache.fast_shutdown=1
|
||||||
|
opcache.enable_cli=1
|
||||||
|
EOF
|
||||||
|
echo "==> Fichier $OPCACHE_INI mis à jour."
|
||||||
|
|
||||||
|
# Configuration APCu
|
||||||
|
APCU_INI="${PHP_INI_DIR}/20-apcu.ini"
|
||||||
|
cat > "$APCU_INI" <<EOF
|
||||||
|
; Configuration APCu optimisée
|
||||||
|
apc.enabled=1
|
||||||
|
apc.shm_size=64M
|
||||||
|
apc.ttl=7200
|
||||||
|
apc.enable_cli=0
|
||||||
|
EOF
|
||||||
|
echo "==> Fichier $APCU_INI mis à jour."
|
||||||
|
|
||||||
|
# Définir la timezone PHP pour CLI et Apache
|
||||||
|
sed -i "s|^;*date.timezone =.*|date.timezone = ${TIMEZONE}|" "${PHP_INI_CLI}"
|
||||||
|
sed -i "s|^;*date.timezone =.*|date.timezone = ${TIMEZONE}|" "${PHP_INI_APACHE}"
|
||||||
|
|
||||||
# Test de la configuration Apache
|
# Test de la configuration Apache
|
||||||
if systemctl is-active --quiet apache2; then
|
if systemctl is-active --quiet apache2; then
|
||||||
|
read -rp "Voulez-vous tester le support de PHP par Apache ? (o/n) : " test_php
|
||||||
|
if [[ "$test_php" =~ ^[oOyY]$ ]]; then
|
||||||
echo -e "${YELLOW}Vérification du support de PHP par Apache...${RESET}"
|
echo -e "${YELLOW}Vérification du support de PHP par Apache...${RESET}"
|
||||||
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
|
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
|
||||||
chown www-data:www-data /var/www/html/info.php
|
chown www-data:www-data /var/www/html/info.php
|
||||||
chmod 644 /var/www/html/info.php
|
chmod 644 /var/www/html/info.php
|
||||||
echo -e "${GREEN}Vous pouvez tester PHP en accédant à : http://<IP_SERVEUR>/info.php${RESET}"
|
echo -e "${GREEN}Vous pouvez tester PHP en accédant à : http://<IP_SERVEUR>/info.php${RESET}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Test PHP annulé.${RESET}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${RED}Le service Apache n'est pas actif.${RESET}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}Installation terminée avec succès ! 🚀${RESET}"
|
echo -e "${GREEN}Installation terminée avec succès ! 🚀${RESET}"
|
||||||
|
|||||||
0
scripts/server-httpd/set-permissions-www.sh
Normal file → Executable file
0
scripts/server-httpd/set-permissions-www.sh
Normal file → Executable file
0
scripts/server-httpd/setup_httpd.sh
Normal file → Executable file
0
scripts/server-httpd/setup_httpd.sh
Normal file → Executable file
@@ -1,2 +1,4 @@
|
|||||||
|
check_mysql_secure.sh
|
||||||
create_db.sh
|
create_db.sh
|
||||||
|
set_root_password.sh
|
||||||
setup_mariadb.sh
|
setup_mariadb.sh
|
||||||
|
|||||||
0
scripts/server-mariadb/check_mysql_secure.sh
Normal file → Executable file
0
scripts/server-mariadb/check_mysql_secure.sh
Normal file → Executable file
0
scripts/server-mariadb/create_db.sh
Normal file → Executable file
0
scripts/server-mariadb/create_db.sh
Normal file → Executable file
0
scripts/server-mariadb/set_root_password.sh
Normal file → Executable file
0
scripts/server-mariadb/set_root_password.sh
Normal file → Executable file
0
scripts/server-mariadb/setup_mariadb.sh
Normal file → Executable file
0
scripts/server-mariadb/setup_mariadb.sh
Normal file → Executable file
3
scripts/server-postgres/.list_files.txt
Normal file
3
scripts/server-postgres/.list_files.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
create_pg_db.sh
|
||||||
|
create_pg_role.sh
|
||||||
|
setup-postgres.sh
|
||||||
52
scripts/server-postgres/create_pg_db.sh
Executable file
52
scripts/server-postgres/create_pg_db.sh
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Basé sur un travail de Cédric Abonnel / Cédrix sous licence CC BY-NC 4.0
|
||||||
|
|
||||||
|
# Importer les fonctions communes
|
||||||
|
source "$(dirname "$0")/../common/common_utils.sh"
|
||||||
|
|
||||||
|
# Vérifier si le script est exécuté en root
|
||||||
|
check_root
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "👉 Nom de la base de données à créer : "
|
||||||
|
read DB_NAME
|
||||||
|
|
||||||
|
echo "👉 Nom de l'utilisateur PostgreSQL propriétaire : "
|
||||||
|
read DB_USER
|
||||||
|
|
||||||
|
# Lecture du mot de passe en mode sécurisé
|
||||||
|
read -s -p "🔑 Mot de passe PostgreSQL de l'utilisateur 'postgres' : " DB_PASS
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Exporter le mot de passe temporairement
|
||||||
|
export PGPASSWORD="$DB_PASS"
|
||||||
|
|
||||||
|
echo "🔎 Vérification de l'existence de l'utilisateur PostgreSQL '$DB_USER'..."
|
||||||
|
USER_EXISTS=$(sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='${DB_USER}'")
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$USER_EXISTS" != "1" ]]; then
|
||||||
|
echo "❌ L'utilisateur '$DB_USER' n'existe pas dans PostgreSQL."
|
||||||
|
unset PGPASSWORD
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
echo "✅ L'utilisateur '$DB_USER' existe."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🔎 Vérification de l'existence de la base de données '$DB_NAME'..."
|
||||||
|
DB_EXISTS=$(sudo -u postgres psql -tAc "SELECT 1 FROM pg_database WHERE datname='${DB_NAME}'")
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$DB_EXISTS" == "1" ]]; then
|
||||||
|
echo "⚠️ La base de données '$DB_NAME' existe déjà."
|
||||||
|
else
|
||||||
|
echo "🛠 Création de la base de données '$DB_NAME' avec le propriétaire '$DB_USER'..."
|
||||||
|
sudo -u postgres createdb -O "$DB_USER" "$DB_NAME"
|
||||||
|
echo "✅ Base de données '$DB_NAME' créée avec succès."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Nettoyage de la variable d'environnement
|
||||||
|
unset PGPASSWORD
|
||||||
|
|
||||||
|
echo "🎉 Opération terminée."
|
||||||
73
scripts/server-postgres/create_pg_role.sh
Executable file
73
scripts/server-postgres/create_pg_role.sh
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Basé sur un travail de Cédric Abonnel / Cédrix sous licence CC BY-NC 4.0
|
||||||
|
|
||||||
|
# Importer les fonctions communes
|
||||||
|
source "$(dirname "$0")/../common/common_utils.sh"
|
||||||
|
|
||||||
|
# Vérifier si le script est exécuté en root
|
||||||
|
check_root
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Demande interactive si le rôle n’est pas passé en paramètre
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
ROLE_NAME="$1"
|
||||||
|
else
|
||||||
|
read -p "👤 Entrez le nom du rôle PostgreSQL à créer : " ROLE_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$ROLE_NAME" ]]; then
|
||||||
|
echo "❌ Le nom du rôle est obligatoire."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Demander le mot de passe de l'utilisateur 'postgres'
|
||||||
|
read -s -p "🔑 Entrez le mot de passe de l'utilisateur 'postgres' : " POSTGRES_PASSWORD
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Générer le mot de passe du rôle
|
||||||
|
echo "🔐 Génération d'un mot de passe fort pour le rôle '$ROLE_NAME'..."
|
||||||
|
ROLE_PASSWORD=$(generate_token 20)
|
||||||
|
|
||||||
|
# Générer un fichier SQL temporaire pour la vérification + création
|
||||||
|
SQL_FILE=$(mktemp)
|
||||||
|
|
||||||
|
cat <<EOF > "$SQL_FILE"
|
||||||
|
DO \$\$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${ROLE_NAME}') THEN
|
||||||
|
RAISE NOTICE '🛠 Création du rôle "${ROLE_NAME}"...';
|
||||||
|
CREATE ROLE ${ROLE_NAME} WITH LOGIN PASSWORD '${ROLE_PASSWORD}';
|
||||||
|
ELSE
|
||||||
|
RAISE NOTICE '⚠️ Le rôle "${ROLE_NAME}" existe déjà.';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
\$\$;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 644 "$SQL_FILE"
|
||||||
|
|
||||||
|
# Une seule exécution de psql via sudo avec mot de passe PostgreSQL exporté
|
||||||
|
echo "🔎 Exécution des commandes SQL avec sudo..."
|
||||||
|
sudo -u postgres bash -c "PGPASSWORD='${POSTGRES_PASSWORD}' psql -v ON_ERROR_STOP=1 -f '${SQL_FILE}'"
|
||||||
|
|
||||||
|
rm -f "$SQL_FILE"
|
||||||
|
|
||||||
|
# Affichage des identifiants si création
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------"
|
||||||
|
echo " Nom du rôle : ${ROLE_NAME}"
|
||||||
|
echo " Mot de passe : ${ROLE_PASSWORD}"
|
||||||
|
echo "-------------------------------------------"
|
||||||
|
|
||||||
|
# Proposer d’enregistrer dans ~/.pgpass
|
||||||
|
read -p "💾 Voulez-vous enregistrer ces identifiants dans ~/.pgpass ? (y/n) " SAVE_PASS
|
||||||
|
if [[ "$SAVE_PASS" =~ ^[Yy]$ ]]; then
|
||||||
|
PGPASS_FILE="${HOME}/.pgpass"
|
||||||
|
echo "*:*:*:${ROLE_NAME}:${ROLE_PASSWORD}" >> "$PGPASS_FILE"
|
||||||
|
chmod 600 "$PGPASS_FILE"
|
||||||
|
echo "✅ Identifiants sauvegardés dans $PGPASS_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "⚠️ Pensez à sauvegarder ces informations si vous ne les enregistrez pas."
|
||||||
|
echo "🎉 Opération terminée."
|
||||||
77
scripts/server-postgres/setup-postgres.sh
Executable file
77
scripts/server-postgres/setup-postgres.sh
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Basé sur un travail de Cédric Abonnel / Cédrix sous licence CC BY-NC 4.0
|
||||||
|
|
||||||
|
# Importer les fonctions communes
|
||||||
|
source "$(dirname "$0")/../common/common_utils.sh"
|
||||||
|
|
||||||
|
# Vérifier si le script est exécuté en root
|
||||||
|
check_root
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "📦 Mise à jour des paquets..."
|
||||||
|
apt update -y
|
||||||
|
|
||||||
|
echo "📚 Installation de postgresql-common (pour script de dépôt officiel)..."
|
||||||
|
apt install -y postgresql-common
|
||||||
|
|
||||||
|
echo "➕ Ajout automatique du dépôt officiel PostgreSQL (via pgdg script)..."
|
||||||
|
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🧩 Versions disponibles dans le dépôt :"
|
||||||
|
AVAILABLE_VERSIONS=$(apt-cache search "^postgresql-[0-9][0-9]$" | awk '{print $1}' | cut -d'-' -f2 | sort -nr)
|
||||||
|
echo "$AVAILABLE_VERSIONS"
|
||||||
|
|
||||||
|
read -p "➡️ Entrez la version PostgreSQL à installer (ex: 17) : " PG_VERSION
|
||||||
|
|
||||||
|
if ! echo "$AVAILABLE_VERSIONS" | grep -q "^${PG_VERSION}$"; then
|
||||||
|
echo "❌ Version PostgreSQL invalide ou non disponible : ${PG_VERSION}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📦 Installation de PostgreSQL $PG_VERSION..."
|
||||||
|
apt update -y
|
||||||
|
apt install -y "postgresql-${PG_VERSION}"
|
||||||
|
|
||||||
|
echo "🚀 Activation et démarrage du service PostgreSQL..."
|
||||||
|
systemctl enable postgresql
|
||||||
|
systemctl start postgresql
|
||||||
|
|
||||||
|
echo "⏳ Attente du démarrage du service PostgreSQL..."
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
echo "✅ Vérification du service..."
|
||||||
|
if ! systemctl is-active --quiet postgresql; then
|
||||||
|
echo "❌ Le service PostgreSQL ne fonctionne pas correctement."
|
||||||
|
journalctl -xeu postgresql --no-pager | tail -n 20
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🧪 Test de connexion à PostgreSQL..."
|
||||||
|
if ! sudo -u postgres psql -c '\q' 2>/dev/null; then
|
||||||
|
echo "❌ Échec de la connexion à PostgreSQL. Vérifiez que le socket est disponible."
|
||||||
|
echo " Astuce : systemctl status postgresql"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🔐 Génération d'un mot de passe fort pour l'utilisateur postgres..."
|
||||||
|
POSTGRES_PASSWORD=$(generate_token 20)
|
||||||
|
|
||||||
|
echo "🔧 Configuration du mot de passe de l'utilisateur postgres..."
|
||||||
|
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';"
|
||||||
|
|
||||||
|
echo "🔧 Configuration de l'accès local en md5..."
|
||||||
|
PG_HBA="/etc/postgresql/${PG_VERSION}/main/pg_hba.conf"
|
||||||
|
sed -i "s/^\(local\s\+all\s\+postgres\s\+\)peer/\1md5/" "$PG_HBA"
|
||||||
|
|
||||||
|
echo "♻️ Redémarrage de PostgreSQL pour appliquer les changements..."
|
||||||
|
systemctl restart postgresql
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ Installation de PostgreSQL ${PG_VERSION} terminée."
|
||||||
|
echo "-------------------------------------------"
|
||||||
|
echo " Mot de passe de l'utilisateur postgres :"
|
||||||
|
echo " ${POSTGRES_PASSWORD}"
|
||||||
|
echo "-------------------------------------------"
|
||||||
|
echo " Pensez à le sauvegarder en lieu sûr."
|
||||||
Reference in New Issue
Block a user