refactor: conformité XDG Base Directory Specification
- Logs déplacés vers $XDG_STATE_HOME/scripts-bash (au lieu de ~/log ou ~/logs) - Liste d'installation déplacée vers $XDG_DATA_HOME/scripts-bash/uninstall-list - updateall : hosts → $XDG_CONFIG_HOME/updateall/hosts, stats → $XDG_STATE_HOME/updateall/stats - generate_playlist : config → $XDG_CONFIG_HOME/generate-playlist - random_music_player, play_tophaire : config via $XDG_CONFIG_HOME - trierPhotos.php : logs via $XDG_STATE_HOME - Toutes les variables XDG avec fallback (~/.local/state, ~/.local/share, ~/.config) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-7
@@ -12,6 +12,12 @@ NC='\033[0m' # No Color
|
||||
|
||||
# Mise à jour des machines présentes dans .ssh/config avec choix d'ignorer certaines.
|
||||
|
||||
# Chemins XDG
|
||||
UPDATEALL_HOSTS="${XDG_CONFIG_HOME:-$HOME/.config}/updateall/hosts"
|
||||
UPDATEALL_CUSTOM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/updateall.d"
|
||||
UPDATEALL_STATS="${XDG_STATE_HOME:-$HOME/.local/state}/updateall/stats"
|
||||
mkdir -p "$(dirname "$UPDATEALL_HOSTS")" "$(dirname "$UPDATEALL_STATS")"
|
||||
|
||||
# fonction run_ssh et run_scp avec timeout + options
|
||||
SSH_OPTS="-o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=accept-new"
|
||||
SSH_TIMEOUT="5"
|
||||
@@ -141,8 +147,7 @@ EOF
|
||||
now=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# Fichier de stats
|
||||
stats_file="$HOME/.config/updateall-stats"
|
||||
mkdir -p "$(dirname "$stats_file")"
|
||||
stats_file="$UPDATEALL_STATS"
|
||||
|
||||
# Ajouter l’en-tête si le fichier est vide
|
||||
if [ ! -s "$stats_file" ]; then
|
||||
@@ -259,9 +264,9 @@ confirm_update() {
|
||||
local machine="$1"
|
||||
read -p " - Executer la mise à jour pour $machine ? (o/n) " choice
|
||||
if [ "$choice" = "o" ]; then
|
||||
echo "$machine 1" >> ~/.config/updateall-hosts
|
||||
echo "$machine 1" >> "$UPDATEALL_HOSTS"
|
||||
else
|
||||
echo "$machine 0" >> ~/.config/updateall-hosts
|
||||
echo "$machine 0" >> "$UPDATEALL_HOSTS"
|
||||
continue
|
||||
fi
|
||||
}
|
||||
@@ -285,7 +290,7 @@ check_host() {
|
||||
|
||||
run_custom_script() {
|
||||
local machine="$1"
|
||||
local custom_script="$HOME/.config/updateall.d/$machine"
|
||||
local custom_script="$UPDATEALL_CUSTOM_DIR/$machine"
|
||||
|
||||
if [ -f "$custom_script" ]; then
|
||||
echo -e " - Exécution du script spécifique pour ${GREEN}$machine${NC}"
|
||||
@@ -328,7 +333,7 @@ current=0
|
||||
|
||||
for machine in "${machines[@]}"; do
|
||||
|
||||
# Vérification si le nom de machine est présent dans le fichier .config/updateall-hosts
|
||||
# Vérification si le nom de machine est présent dans $UPDATEALL_HOSTS
|
||||
|
||||
echo -e "\n"
|
||||
((current++))
|
||||
@@ -364,7 +369,7 @@ for machine in "${machines[@]}"; do
|
||||
matched=1
|
||||
break
|
||||
fi
|
||||
done < ~/.config/updateall-hosts
|
||||
done < "$UPDATEALL_HOSTS"
|
||||
|
||||
if [ "$matched" != "1" ]; then
|
||||
check_host "$machine"
|
||||
|
||||
Reference in New Issue
Block a user