Commit 50ab4f2d authored by kyodev's avatar kyodev

release 4.15.0

parent dab2aff0
......@@ -7,6 +7,10 @@ date au format: YYYY-MM-DD
## [ Unreleased ]
## [ 4.15.0 ] - 2018.07.3
* synchro: f__requis, f__sort_uniq
## [ 4.14.1 ] - 2018.06.13
* rewriting: f__archive_test, fflash_get_version
......
# getFlashPlayer
![version: 4.14.1](https://img.shields.io/badge/version-4.14.1-blue.svg?longCache=true&style=for-the-badge)
![version: 4.15.0](https://img.shields.io/badge/version-4.15.0-blue.svg?longCache=true&style=for-the-badge)
![bash langage](https://img.shields.io/badge/bash-4-brightgreen.svg?longCache=true&style=for-the-badge)
![license LPRAB / WTFPL](https://img.shields.io/badge/license-LPRAB%20%2F%20WTFPL-blue.svg?longCache=true&style=for-the-badge)
......
#!/bin/bash
version=4.14.1
date="13/06/2018"
version=4.15.0
date="03/07/2018"
script="getFlashPlayer"
# contact="IRC ##sdeb@freenode.net ou https://framagit.org/sdeb/getFlashPlayer/issues"
......@@ -119,8 +119,10 @@ f__log(){ # 05/03/2018
# recherche commandes/paquets, $1 liste: cmd1|cmd2[>paquet] (séparées par espaces) ex: "gawk|mawk>gawk wget"
# si manque, return 1 & affiche commandes manquantes (si debian, ajout proposition paquet à installer)
f__requis(){ # 11/06/2018
local ENV_DEBIAN c_echo ireq cmds package commands command commandsMissing packagesMissing
# requiert f__sort_uniq
f__requis(){ # 30/06/2018
local ENV_DEBIAN c_echo ireq cmds package commands command
local commandsMissing packagesMissing t_commandsMissing t_packagesMissing
if type -p dpkg &>/dev/null ; then
ENV_DEBIAN="oui" # debian
......@@ -132,36 +134,76 @@ f__requis(){ # 11/06/2018
fi
for ireq in $1; do
IFS='>' read -r cmds package <<< "$ireq" # ex: "awk|gawk>gawk wget file tar killall>psmisc"
mapfile -t -d '|' commands <<< "${cmds}"
[ -z "$package" ] && package=${commands[0]%$'\n'} # pas de packages dans les options, donc = commands[0]
IFS='|' read -ra commands <<< "${cmds}"
[ -z "$package" ] && package=${commands[0]} # pas de packages dans les options, donc = commands[0]
unset t_commandsMissing t_packagesMissing
for command in "${commands[@]%$'\n'}"; do
if type -p "$command" &>/dev/null ; then
unset commandsMissing packagesMissing
unset t_commandsMissing t_packagesMissing
break
else # inexistant
commandsMissing+="$command "
packagesMissing+="$package "
t_commandsMissing+="$command "
t_packagesMissing="$package "
fi
done
[ "$t_commandsMissing" ] && commandsMissing+="$t_commandsMissing "
[ "$t_packagesMissing" ] && packagesMissing+="$t_packagesMissing "
done
# dédoublonnage & triage
commandsMissing=$( echo "$commandsMissing" | tr ' ' '\n' | sort --unique | tr '\n' ' ' )
packagesMissing=$( echo "$packagesMissing" | tr ' ' '\n' | sort --unique | tr '\n' ' ' )
# suppression éventuel espace final
commandsMissing=${commandsMissing% }
packagesMissing=${packagesMissing% }
# dédoublonnage & tri
commandsMissing=$( f__sort_uniq "$commandsMissing" )
packagesMissing=$( f__sort_uniq "$packagesMissing" )
# affichage final
if [ "$commandsMissing" ] && [ "$ENV_DEBIAN" ]; then
$c_echo "${RED}erreur critique, manquant: $STD$BOLD$commandsMissing" \
"vous devriez exécuter:$GREEN apt install $packagesMissing"
$c_echo "${RED}erreur critique, manquant: $STD$BOLD$commandsMissing$STD" \
"vous devriez exécuter:$GREEN apt install $packagesMissing$STD"
elif [ "$commandsMissing" ]; then
$c_echo "${RED}erreur critique, manquant: $STD$BOLD$commandsMissing"
$c_echo "${RED}erreur critique, manquant: $STD$BOLD$commandsMissing$STD"
fi
[ "$commandsMissing" ] && return 1 || return 0
}
# options: liste à trier [-lf], affiche flat liste (\n enlevés en sortie) ou si -ln liste avec \n à chaque ligne
# des caractères non permis =$/`... sont transformés en ø
f__sort_uniq(){ # 02/07/2018
local lf list array result item
while (( $# )) ; do
case "$1" in
-lf ) lf='yes' ;;
* ) list=${1} ;;
esac
shift
done
while read -r ; do # lecture ligne
[ -z "$REPLY" ] && continue
REPLY=${REPLY# } # trim gauche simple
REPLY=${REPLY% } # trim droite simple
REPLY=${REPLY// /\~} # espace remplacé avec ~
# interdits/remplacés: ()/`; ø utilisé comme indicateur, ~ remplacé pas espace
REPLY=${REPLY//[^a-zA-Z0-9~.,\{\}!\[\]#*%µ£°⇉:_+-]/ø} # caractère <> de autorisé remplacés par ø
if [ "$lf" ]; then
array+=( "${REPLY}" )
else
IFS='~' read -ra array <<< "$REPLY"
fi
done <<< "${list}"
result=$(
for item in "${array[@]}"; do
eval "alias ${item}=ls"
done
alias
)
result=${result//alias }
result=${result//=\'ls\'}
result=${result//\~/ }
[ "$lf" ] && echo "${result}" || echo "${result//$'\n'/ }"
}
# $@=cmd à lancer en root avec su ou sudo. si sudo possible: prioritairesu su
f__sudo(){ # 11/06/2018
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment