commit f756ca2991632faaa86a026e8ae53b6dd0b4b2ce Author: TheHackdes Date: Mon May 4 18:33:16 2026 +0200 feat(README.md): add README for Manage OpenLDAP script feat(fnox.toml): add fnox provider configuration feat(main.sh): create main shell script for Manage OpenLDAP feat(mise.toml): add tools and env configurations for mise feat(sources/functions.sh): create functions shell script for Manage OpenLDAP diff --git a/README.md b/README.md new file mode 100644 index 0000000..757cfc9 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Manage OpenLDAP + +Script interactif en Bash pour gérer les utilisateurs OpenLDAP (ajout, suppression). + +## Prérequis + +- `bash` +- `fzf` (sélecteur interactif) +- `figlet` (génération de bannières) +- `lolcat` (couleurs arc-en-ciel) +- `mise` (gestion des outils, optionnel) + +Installation rapide avec `mise` : + +```bash +mise install +``` + +## Utilisation + +```bash +./main.sh +``` + +Un menu interactif s'affiche via `fzf` permettant de : +1. Ajouter un nouvel utilisateur +2. Supprimer un utilisateur diff --git a/fnox.toml b/fnox.toml new file mode 100644 index 0000000..2cae1ab --- /dev/null +++ b/fnox.toml @@ -0,0 +1,8 @@ +default_provider = "age" + +[providers.age] +type = "age" +recipients = ["age10cr6p37zvr77xwjs2rpqnqnasaztpyzyt993dhze90fjtntnuu3s8fmnjz"] + +[secrets] +TEST= { provider = "age", value = "YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBkMmxtMTZmNWVZdzJ6MkdtMGJZUjNpMDhqZ0pLUDJDaFdMOG0zUU5Kb0dJClVabGZkL1ZkYlN3UmN4UFg4R3RGaXJ4WDNRM1VEa0xrY3BIcy8xUmp3cWsKLT4gcjs0LWdyZWFzZSArZX1IKHQiTiBdJG8jITxvIEMxIl58IFAKYXRmWE9nUE5DaUJqMXd5TUVWZ2wrVEVQa2R3NVV4QVNmT3Rya2dwdlhRdzFrZWJQb2FCSDBLNTVhME9uK3cxQgpIK2J0ZXBIRkxVMAotLS0gekFSNG9HQzJZcHRTcjBRZ1hmRG54Vm93YURPMk5GT1ZNMEppRjZ4T2lGSQr+hZBytIlC8QnI/NlRSwYOEdY1U7DrQdDCDqOhweZJ2jyH5vw=", description = "test test" } diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..7ee2c85 --- /dev/null +++ b/main.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +clear + +source ./sources/functions.sh + +banner "Manage OpenLDAP" + +CHOIX=( + "1. Ajouter un nouveau utilisateur" + "2. Supprimer un utilisateur" +) + +select_option() { + local choice + choice=$(printf "%s\n" "${CHOIX[@]}" | fzf --height=4 --reverse --cycle --prompt="❯ Choix : " --layout=reverse) + log info "Selection - ${choice}" +} + +sleep 1.5 + +select_option diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..783e7f6 --- /dev/null +++ b/mise.toml @@ -0,0 +1,9 @@ +[tools] +age = "latest" +fnox = "latest" +fzf = "latest" +lazygit = "latest" +npm = "latest" + +[env] +PROVIDER = "ollama" diff --git a/sources/functions.sh b/sources/functions.sh new file mode 100755 index 0000000..5209cc8 --- /dev/null +++ b/sources/functions.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +export CREATOR_NAME="Guillaume DENIS" + +C_BLEU="\e[34m" +C_ROUGE="\e[31m" +C_VERT="\e[32m" +C_ORANGE="\e[33m" +C_VIOLET="\e[35m" + +C_INVERSE="\e[7m" +C_RESET="\e[0m" + +function banner() { + figlet -w 200 ${1} | lolcat + echo -e "Created by ${CREATOR_NAME}\n" +} + +function log() { + + DATE_NOW=$(date +%H:%M:%S) + + if [[ -n ${1} ]]; then + if [[ -n ${2} ]]; then + case ${1} in + info) + echo -e "${C_BLEU}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_BLEU} - Info : ${2}${C_RESET}" + ;; + warning) + echo -e "${C_ORANGE}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_ORANGE} - Warning : ${2}${C_RESET}" + ;; + success) + echo -e "${C_VERT}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_VERT} - Success : ${2}${C_RESET}" + ;; + error) + echo -e "${C_ROUGE}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_ROUGE} - Error : ${2}${C_RESET}" + ;; + *) + echo -e "${C_ROUGE}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_ROUGE} - Error : Soit info / warning / success / error${C_RESET}" + ;; + esac + + else + echo -e "${C_ROUGE}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_ROUGE} - Error : Il manque le deuxieme argument${C_RESET}" + fi + else + echo -e "${C_ROUGE}${C_INVERSE}[${DATE_NOW}]${C_RESET}${C_ROUGE} - Error : Il manque le premier argument${C_RESET}" + fi +}