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
|
||||
date="28.11.2017"
|
||||
|
||||
# prefix_url="http://zone.spip.org/trac/spip-zone/changeset/latest/_plugins_/"
|
||||
#sufix_url="?old_path=/&format=zip"
|
||||
#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"
|
||||
prefix_url="http://zone.spip.org/trac/spip-zone/changeset/latest/_plugins_/"
|
||||
sufix_url="?old_path=/&format=zip"
|
||||
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"
|
||||
|
||||
# la liste des 66 plugins à charger, juste le nom
|
||||
toLoad=(
|
||||
# NOM_DU_PLUGIN1
|
||||
# NOM_DU_PLUGIN2
|
||||
# NOM_DU_PLUGIN2
|
||||
pluginsToLoad.sh
|
||||
test_alsa
|
||||
NOM_DU_PLUGIN1
|
||||
NOM_DU_PLUGIN2
|
||||
NOM_DU_PLUGIN2
|
||||
# pluginsToLoad.sh
|
||||
# test_alsa
|
||||
)
|
||||
|
||||
|
||||
|
@ -35,22 +35,13 @@ IFS=$' \t\n'
|
|||
export PATH TERM IFS
|
||||
|
||||
|
||||
## 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)
|
||||
}
|
||||
### fonctions utiles
|
||||
|
||||
# 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=loc affiche seulement location et sortie normale fonction
|
||||
# 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
|
||||
file_test_wget="/tmp/testWget-$$-$RANDOM"
|
||||
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
|
||||
if [ "$retourWget" ]; then
|
||||
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
|
||||
if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then
|
||||
echo -e "$GREEN\ntout est ok, réessayer\n$STD"
|
||||
|
@ -95,62 +87,74 @@ f__wget_test(){ # 06/11/2017
|
|||
exit 0
|
||||
}
|
||||
|
||||
# $1 url à charger, $2 dossier temporaire
|
||||
f__wget(){
|
||||
local urlScript
|
||||
wget -q --tries=2 --timeout=15 -O "$2" "$urlScript"
|
||||
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
|
||||
if grep -q '#!/bin/bash' "$dirTemp/$script" ; then
|
||||
cp -d "$dirTemp/$script" "$fileInstall"
|
||||
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/"
|
||||
f__start(){ # 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)
|
||||
|
||||
[ "$(which figlet)" ] && figlet $( basename $0 | tr '`' "'")
|
||||
echo "$GREEN$( basename $0 )$BLUE $version$STD du $BLUEE$date$STD"
|
||||
echo
|
||||
}
|
||||
|
||||
f_test_auDemarrage(){
|
||||
# on vérifie certains paramètres/variables
|
||||
[ "${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
|
||||
[ "${repTemporaire::-1}" == "/" ] && prefix_url=${repTemporaire::-1}
|
||||
|
||||
if [ ! -d "$repToSave" ]; then
|
||||
echo -e "$REDCritique:$STD erreur, répertoire cible inexistant: $repToSave"
|
||||
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__color
|
||||
|
||||
echo "$(basename $0 ) $version du $date"
|
||||
[ "$EUID" == "0" ] && echo "attention aux droit si root.. ;)"
|
||||
|
||||
# on vérifie certains paramètres/variables
|
||||
[ "${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
|
||||
[ "${repTemporaire::-1}" == "/" ] && prefix_url=${repTemporaire::-1}
|
||||
|
||||
[ -d "$repToSave" ] || echo "Critique: répertoire cible où sauver"
|
||||
[ -d "$repTemporaire" ] || echo "Critique: répertoire temporaire inexistant"
|
||||
[ -d "$repToSave" ] || exit 1
|
||||
[ -d "$repTemporaire" ] || exit 1
|
||||
### 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
|
||||
local urlPlugin # déclaration variable comme locale à la fonction
|
||||
|
||||
urlPlugin="$prefix_url/$plugin/$sufix_url" # formation url complète
|
||||
echo "Chargement$BOLD $plugin $STD" # affichage plugin en cours
|
||||
echo "Chargement$BOLD $plugin $STD..." # affichage plugin en cours
|
||||
|
||||
urlPlugin="$prefix_url/$plugin/$sufix_url" # formation url complète
|
||||
|
||||
# pour débugguer, décommenter
|
||||
# echo "$urlPlugin"
|
||||
# echo "\$repTemporaire/\$plugin "$repTemporaire/$plugin""
|
||||
# echo "\$repToSave/\$plugin $repToSave/$plugin"
|
||||
|
||||
# on télécharge
|
||||
wget -q --tries=2 --timeout=15 -O "$repTemporaire/$plugin" "$urlScript"
|
||||
if [ "$?" != "0" ]; then
|
||||
f__wget_test "$urlScript" # si erreur wget
|
||||
else
|
||||
cp "$repTemporaire/$plugin" "$repToSave/$plugin" # copie à l'emplacement final
|
||||
wget -q --tries=2 --timeout=15 -O "$repTemporaire/$plugin" "$urlPlugin"
|
||||
if [ "$?" != "0" ]; then # ERREUR wget
|
||||
f__wget_test "$urlPlugin"
|
||||
else # OK, on traitements finaux
|
||||
cp "$repTemporaire/$plugin" "$repToSave/$plugin" # copie à l'emplacement final
|
||||
# chmod éventuel # autres traitements à faire
|
||||
# chown éventuel # autres traitements à faire
|
||||
fi
|
||||
[ -e "$repTemporaire/$plugin" ] && rm "$repTemporaire/$plugin" # si encore présent, on efface le fichier temporaire
|
||||
|
||||
# ménage
|
||||
[ -e "$repTemporaire/$plugin" ] && rm "$repTemporaire/$plugin" # si encore présent, on efface le fichier temporaire
|
||||
|
||||
done
|
||||
|
||||
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
|
||||
|
||||
version=1.4.1
|
||||
date=23/10/2017
|
||||
version=1.5.0
|
||||
date=28.11.2017
|
||||
|
||||
BOLD=$(tput bold)
|
||||
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]
|
||||
# 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"
|
||||
f__requis "strings>binutils" # requis pour fonctionnement programme
|
||||
local repToScan irep rc text prof prof_max tempo
|
||||
[ "${1: -1}" == "/" ] && repToScan="$1" || repToScan="$1/" # ajout / final 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)
|
||||
text="répertoire: $repToScan \n"
|
||||
text=" >>> répertoire: $repToScan \n"
|
||||
for irep in $(ls $repToScan); do # contenu du répertoire
|
||||
prof=$(( $prof+1 )) # niveau++
|
||||
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
|
||||
else # si c'est pas un répertoire
|
||||
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
|
||||
fi
|
||||
# traitements fichier
|
||||
[[ "$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" ] && text+="$irep: $rc$tempo \n" || text+="$irep: <vide> \n"
|
||||
[ "$tempo" ] && text+=" fichier <$irep>: $rc$tempo \n" || text+=" fichier <$irep>: <vide> \n"
|
||||
fi
|
||||
prof=$(( prof-1 )) # niveau--
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue