mirror of https://framagit.org/kyodev/kyopages.git
maj
This commit is contained in:
parent
add593df29
commit
53d8c9dc13
|
@ -6,23 +6,23 @@
|
||||||
version=1.0.0
|
version=1.0.0
|
||||||
date="28.11.2017"
|
date="28.11.2017"
|
||||||
|
|
||||||
# prefix_url="http://zone.spip.org/trac/spip-zone/changeset/latest/_plugins_/"
|
prefix_url="http://zone.spip.org/trac/spip-zone/changeset/latest/_plugins_/"
|
||||||
#sufix_url="?old_path=/&format=zip"
|
sufix_url="?old_path=/&format=zip"
|
||||||
#repToSave="/home/amilcar" # où sauver? à compléter, un RÉPERTOIRE
|
repToSave="/home/amilcar" # où sauver? à compléter, un RÉPERTOIRE
|
||||||
#repTemporaire="/tmp"
|
|
||||||
|
|
||||||
prefix_url="https://framagit.org/kyodev/kyopages/raw/master/scripts/tests"
|
|
||||||
sufix_url="#fake"
|
|
||||||
repToSave="/home/kyodev"
|
|
||||||
repTemporaire="/tmp"
|
repTemporaire="/tmp"
|
||||||
|
|
||||||
|
#prefix_url="https://framagit.org/kyodev/kyopages/raw/master/scripts/tests"
|
||||||
|
#sufix_url="#fake"
|
||||||
|
#repToSave="/home/kyodev"
|
||||||
|
#repTemporaire="/tmp"
|
||||||
|
|
||||||
# la liste des 66 plugins à charger, juste le nom
|
# la liste des 66 plugins à charger, juste le nom
|
||||||
toLoad=(
|
toLoad=(
|
||||||
# NOM_DU_PLUGIN1
|
NOM_DU_PLUGIN1
|
||||||
# NOM_DU_PLUGIN2
|
NOM_DU_PLUGIN2
|
||||||
# NOM_DU_PLUGIN2
|
NOM_DU_PLUGIN2
|
||||||
pluginsToLoad.sh
|
# pluginsToLoad.sh
|
||||||
test_alsa
|
# test_alsa
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,22 +35,13 @@ IFS=$' \t\n'
|
||||||
export PATH TERM IFS
|
export PATH TERM IFS
|
||||||
|
|
||||||
|
|
||||||
## fonctions utiles
|
### fonctions utiles
|
||||||
|
|
||||||
f__color(){ # 08/10/2017
|
|
||||||
YELLOW=$(tput setaf 3) # question
|
|
||||||
GREEN=$(tput setaf 2) # ok
|
|
||||||
BLUE=$(tput setaf 4) # info
|
|
||||||
RED=$(tput setaf 1) # alerte
|
|
||||||
STD=$(tput sgr0) # retour normal
|
|
||||||
BOLD=$(tput bold)
|
|
||||||
}
|
|
||||||
|
|
||||||
# test wget, $1 url à tester, sortie du script si $1 seul (même si url testée ok)
|
# test wget, $1 url à tester, sortie du script si $1 seul (même si url testée ok)
|
||||||
# si $2=print affiche url testée & entêtes http & location (si présente) et sortie normale fonction
|
# si $2=print affiche url testée & entêtes http & location (si présente) et sortie normale fonction
|
||||||
# si $2=loc affiche seulement location et sortie normale fonction
|
# si $2=loc affiche seulement location et sortie normale fonction
|
||||||
# si $2=test return 0 si ok, return 1 si ko
|
# si $2=test return 0 si ok, return 1 si ko
|
||||||
f__wget_test(){ # 06/11/2017
|
f__wget_test(){ # 28/11/2017
|
||||||
local file_test_wget retourWget retourHttp location
|
local file_test_wget retourWget retourHttp location
|
||||||
file_test_wget="/tmp/testWget-$$-$RANDOM"
|
file_test_wget="/tmp/testWget-$$-$RANDOM"
|
||||||
wget -Sq --timeout=10 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget"
|
wget -Sq --timeout=10 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget"
|
||||||
|
@ -86,7 +77,8 @@ f__wget_test(){ # 06/11/2017
|
||||||
fi
|
fi
|
||||||
if [ "$retourWget" ]; then
|
if [ "$retourWget" ]; then
|
||||||
rm "$file_test_wget"
|
rm "$file_test_wget"
|
||||||
f__error "wget, $retourWget" "$1" "$YELLOW$retourHttp" "location"
|
# f__error "wget, $retourWget" "$1" "$YELLOW$retourHttp" "$location"
|
||||||
|
echo -e "$RED errur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location"
|
||||||
fi
|
fi
|
||||||
if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then
|
if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then
|
||||||
echo -e "$GREEN\ntout est ok, réessayer\n$STD"
|
echo -e "$GREEN\ntout est ok, réessayer\n$STD"
|
||||||
|
@ -95,62 +87,74 @@ f__wget_test(){ # 06/11/2017
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 url à charger, $2 dossier temporaire
|
f__start(){ # 08/10/2017
|
||||||
f__wget(){
|
YELLOW=$(tput setaf 3) # question
|
||||||
local urlScript
|
GREEN=$(tput setaf 2) # ok
|
||||||
wget -q --tries=2 --timeout=15 -O "$2" "$urlScript"
|
BLUE=$(tput setaf 4) # info
|
||||||
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
|
RED=$(tput setaf 1) # alerte
|
||||||
if grep -q '#!/bin/bash' "$dirTemp/$script" ; then
|
STD=$(tput sgr0) # retour normal
|
||||||
cp -d "$dirTemp/$script" "$fileInstall"
|
BOLD=$(tput bold)
|
||||||
chmod 775 "$fileInstall" # rwx rwx r-x, proprio user_
|
|
||||||
chown "$user_:" "$fileInstall"
|
|
||||||
[ -z "$updateSpecial" ] && fscript_cronAnacron "upgrade"
|
|
||||||
f__info "log" "$script mis à jour en version $versionScript $updateSpecial"
|
|
||||||
else
|
|
||||||
rm -rf "$dirTemp/"
|
|
||||||
f__error "échec update" "mauvais téléchargement, réessayer plus tard"
|
|
||||||
fi
|
|
||||||
rm -rf "$dirTemp/"
|
|
||||||
|
|
||||||
|
[ "$(which figlet)" ] && figlet $( basename $0 | tr '`' "'")
|
||||||
|
echo "$GREEN$( basename $0 )$BLUE $version$STD du $BLUEE$date$STD"
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f_test_auDemarrage(){
|
||||||
## coeur du script
|
|
||||||
f__color
|
|
||||||
|
|
||||||
echo "$(basename $0 ) $version du $date"
|
|
||||||
[ "$EUID" == "0" ] && echo "attention aux droit si root.. ;)"
|
|
||||||
|
|
||||||
# on vérifie certains paramètres/variables
|
# on vérifie certains paramètres/variables
|
||||||
[ "${prefix_url::-1}" == "/" ] && prefix_url=${prefix_url::-1} # si présent, on enlève slash final
|
[ "${prefix_url::-1}" == "/" ] && prefix_url=${prefix_url::-1} # si présent, on enlève slash final
|
||||||
[ "${repToSave::-1}" == "/" ] && prefix_url=${repToSave::-1} # si présent, on enlève slash final
|
[ "${repToSave::-1}" == "/" ] && prefix_url=${repToSave::-1} # si présent, on enlève slash final
|
||||||
[ "${repTemporaire::-1}" == "/" ] && prefix_url=${repTemporaire::-1}
|
[ "${repTemporaire::-1}" == "/" ] && prefix_url=${repTemporaire::-1}
|
||||||
|
|
||||||
[ -d "$repToSave" ] || echo "Critique: répertoire cible où sauver"
|
if [ ! -d "$repToSave" ]; then
|
||||||
[ -d "$repTemporaire" ] || echo "Critique: répertoire temporaire inexistant"
|
echo -e "$REDCritique:$STD erreur, répertoire cible inexistant: $repToSave"
|
||||||
[ -d "$repToSave" ] || exit 1
|
exit 1
|
||||||
[ -d "$repTemporaire" ] || exit 1
|
elif [ ! -d "$repTemporaire" ]; then
|
||||||
|
echo -e "$REDCritique:$STD erreur, répertoire temporaire inexistant: $repTemporaire"
|
||||||
|
exit 1
|
||||||
|
elif [ "$EUID" == "0" ]; then
|
||||||
|
echo "attention aux droit si root.. ;)"
|
||||||
|
elif [ -z $( which wget ) ]; then
|
||||||
|
echo "$REDCritique:$STD wget requis: apt install wget"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### coeur du script
|
||||||
|
|
||||||
|
f__start
|
||||||
|
f_test_auDemarrage
|
||||||
|
|
||||||
|
# coeur du chargement, plugins chargés à partir du tableau complété en tête du script (toLoad)
|
||||||
for plugin in "${toLoad[@]}"; do
|
for plugin in "${toLoad[@]}"; do
|
||||||
local urlPlugin # déclaration variable comme locale à la fonction
|
|
||||||
|
echo "Chargement$BOLD $plugin $STD..." # affichage plugin en cours
|
||||||
|
|
||||||
urlPlugin="$prefix_url/$plugin/$sufix_url" # formation url complète
|
urlPlugin="$prefix_url/$plugin/$sufix_url" # formation url complète
|
||||||
echo "Chargement$BOLD $plugin $STD" # affichage plugin en cours
|
|
||||||
|
# pour débugguer, décommenter
|
||||||
|
# echo "$urlPlugin"
|
||||||
|
# echo "\$repTemporaire/\$plugin "$repTemporaire/$plugin""
|
||||||
|
# echo "\$repToSave/\$plugin $repToSave/$plugin"
|
||||||
|
|
||||||
# on télécharge
|
# on télécharge
|
||||||
wget -q --tries=2 --timeout=15 -O "$repTemporaire/$plugin" "$urlScript"
|
wget -q --tries=2 --timeout=15 -O "$repTemporaire/$plugin" "$urlPlugin"
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then # ERREUR wget
|
||||||
f__wget_test "$urlScript" # si erreur wget
|
f__wget_test "$urlPlugin"
|
||||||
else
|
else # OK, on traitements finaux
|
||||||
cp "$repTemporaire/$plugin" "$repToSave/$plugin" # copie à l'emplacement final
|
cp "$repTemporaire/$plugin" "$repToSave/$plugin" # copie à l'emplacement final
|
||||||
|
# chmod éventuel # autres traitements à faire
|
||||||
|
# chown éventuel # autres traitements à faire
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ménage
|
||||||
[ -e "$repTemporaire/$plugin" ] && rm "$repTemporaire/$plugin" # si encore présent, on efface le fichier temporaire
|
[ -e "$repTemporaire/$plugin" ] && rm "$repTemporaire/$plugin" # si encore présent, on efface le fichier temporaire
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
script:
|
||||||
|
|
||||||
|
wget -nv -O getInfo https://framagit.org/kyodev/kyopages/raw/master/scripts/tests/pluginsToLoad.sh
|
||||||
|
chmod +x getInfo && ./getInfo
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
version=1.4.1
|
version=1.5.0
|
||||||
date=23/10/2017
|
date=28.11.2017
|
||||||
|
|
||||||
BOLD=$(tput bold)
|
BOLD=$(tput bold)
|
||||||
STD=$(tput sgr0)
|
STD=$(tput sgr0)
|
||||||
|
@ -25,14 +25,14 @@ f__requis(){ # version spécifique
|
||||||
|
|
||||||
# $1=rep à scanner [$2=profondeur max|4 défaut] [$3=profondeur encours|0 défaut]
|
# $1=rep à scanner [$2=profondeur max|4 défaut] [$3=profondeur encours|0 défaut]
|
||||||
# affichage stdout si $fileOutput non définis, /usr/bin/strings (binutils) requis
|
# affichage stdout si $fileOutput non définis, /usr/bin/strings (binutils) requis
|
||||||
f__scandir(){ # 17/10/2017
|
f__scandir(){ # 28/11/2017
|
||||||
[ -d "$1" ] || f__error "erreur sur le répertoire à scanner"
|
[ -d "$1" ] || f__error "erreur sur le répertoire à scanner"
|
||||||
f__requis "strings>binutils" # requis pour fonctionnement programme
|
f__requis "strings>binutils" # requis pour fonctionnement programme
|
||||||
local repToScan irep rc text prof prof_max tempo
|
local repToScan irep rc text prof prof_max tempo
|
||||||
[ "${1: -1}" == "/" ] && repToScan="$1" || repToScan="$1/" # ajout / final si besoin
|
[ "${1: -1}" == "/" ] && repToScan="$1" || repToScan="$1/" # ajout / final si besoin
|
||||||
[ "$2" ] && prof_max="$2" || prof_max=4 # profondeur max par défaut si besoin
|
[ "$2" ] && prof_max="$2" || prof_max=4 # profondeur max par défaut si besoin
|
||||||
[ "$3" ] && prof=$3 || prof=0 # initialisation compteur profondeur en cours si nécessaire (début)
|
[ "$3" ] && prof=$3 || prof=0 # initialisation compteur profondeur en cours si nécessaire (début)
|
||||||
text="répertoire: $repToScan \n"
|
text=" >>> répertoire: $repToScan \n"
|
||||||
for irep in $(ls $repToScan); do # contenu du répertoire
|
for irep in $(ls $repToScan); do # contenu du répertoire
|
||||||
prof=$(( $prof+1 )) # niveau++
|
prof=$(( $prof+1 )) # niveau++
|
||||||
if [ -d "$repToScan$irep" ]; then # si c'est un répertoire
|
if [ -d "$repToScan$irep" ]; then # si c'est un répertoire
|
||||||
|
@ -40,13 +40,13 @@ f__scandir(){ # 17/10/2017
|
||||||
[ "$prof" -le "$prof_max" ] && f__scandir "$repToScan$irep/" "$prof_max" "$prof" || continue
|
[ "$prof" -le "$prof_max" ] && f__scandir "$repToScan$irep/" "$prof_max" "$prof" || continue
|
||||||
else # si c'est pas un répertoire
|
else # si c'est pas un répertoire
|
||||||
if [ ! -r "$repToScan$irep" ]; then # si fichier non lisible (read)
|
if [ ! -r "$repToScan$irep" ]; then # si fichier non lisible (read)
|
||||||
text+="$repToScan$irep : inaccessible en lecture \n"
|
text+="**:( $repToScan$irep : inaccessible en lecture \n"
|
||||||
continue # suivant dans la boucle
|
continue # suivant dans la boucle
|
||||||
fi
|
fi
|
||||||
# traitements fichier
|
# traitements fichier
|
||||||
[[ "$irep" == "uevent" || "$irep" == "modalias" ]] && rc=" \n" || unset rc
|
[[ "$irep" == "uevent" || "$irep" == "modalias" ]] && rc=" \n" || unset rc
|
||||||
tempo="$(strings -aw -n1 $repToScan$irep)" # au moins 1 caractère, inclus white space, all tout le fichier
|
tempo="$(strings -aw -n1 $repToScan$irep)" # au moins 1 caractère, inclus white space, all tout le fichier
|
||||||
[ "$tempo" ] && text+="$irep: $rc$tempo \n" || text+="$irep: <vide> \n"
|
[ "$tempo" ] && text+=" fichier <$irep>: $rc$tempo \n" || text+=" fichier <$irep>: <vide> \n"
|
||||||
fi
|
fi
|
||||||
prof=$(( prof-1 )) # niveau--
|
prof=$(( prof-1 )) # niveau--
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue