add arrays
This commit is contained in:
parent
d29718d9bf
commit
4e6c984c91
37
grabber.sh
37
grabber.sh
@ -37,7 +37,14 @@ apt list --installed 2> >(tee -a $ERROR_LOG) >$DIR/apt-installed.cmd \
|
|||||||
&& echo "[OK]: Fichier apt-installed.cmd généré" |tee -a $SUCCESS_LOG \
|
&& echo "[OK]: Fichier apt-installed.cmd généré" |tee -a $SUCCESS_LOG \
|
||||||
|| echo "[ECHEC]: Erreur à la génération de apt-installed.cmd" |tee -a $ERROR_LOG
|
|| echo "[ECHEC]: Erreur à la génération de apt-installed.cmd" |tee -a $ERROR_LOG
|
||||||
|
|
||||||
|
# Commande array
|
||||||
|
tee -a $SUCCESS_LOG $ERROR_LOG <<EOF4
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
Commandes arrays
|
||||||
|
|
||||||
|
-------------------------------------
|
||||||
|
EOF4
|
||||||
declare -a DEVICES
|
declare -a DEVICES
|
||||||
mapfile -t DEVICES < <(lsblk -dn -o NAME |grep -v loop)
|
mapfile -t DEVICES < <(lsblk -dn -o NAME |grep -v loop)
|
||||||
|
|
||||||
@ -48,6 +55,36 @@ FILES=(
|
|||||||
"group.file" "/etc/group"
|
"group.file" "/etc/group"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
declare -A PARTITIONS_BY_DISK
|
||||||
|
for disk in ${DEVICES[@]}; do
|
||||||
|
disk_path=$(printf '/dev/%s' "$disk")
|
||||||
|
disk_parts=$(lsblk -nr -o PKNAME,PATH $disk_path |grep -vE "^ " |cut -d \ -f2)
|
||||||
|
PARTITIONS_BY_DISK[$disk]=${disk_parts[@]}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Combien de disques sur l'ordinateur ? ${#DEVICES[@]}"
|
||||||
|
echo "keys: ${!PARTITIONS_BY_DISK[@]}"
|
||||||
|
echo "values: ${PARTITIONS_BY_DISK[@]}"
|
||||||
|
|
||||||
|
echo DEVICES=${DEVICES[@]} >$DIR/status.log
|
||||||
|
|
||||||
|
for disk in ${!PARTITIONS_BY_DISK[@]}; do
|
||||||
|
echo "PARTS_$disk=$(printf '%s ' ${PARTITIONS_BY_DISK[$disk]})" >>$DIR/status.log
|
||||||
|
done
|
||||||
|
|
||||||
|
treat_file() {
|
||||||
|
echo "Les arguments: $@"
|
||||||
|
echo "Argument 1: $1"
|
||||||
|
cat $2 >>$DIR/$1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
treat_file sources_list.file /etc/apt/sources.list
|
||||||
|
|
||||||
|
for file in ${!FILES[@]}; do
|
||||||
|
treat_file $file ${FILES[$file]}
|
||||||
|
done
|
||||||
|
|
||||||
#cat /etc/passwd > $DIR/passwd.file
|
#cat /etc/passwd > $DIR/passwd.file
|
||||||
#cat /etc/group > $DIR/group.file
|
#cat /etc/group > $DIR/group.file
|
||||||
#lspci -nn > $DIR/lspci.cmd
|
#lspci -nn > $DIR/lspci.cmd
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user