tp08
This commit is contained in:
parent
fac92127ea
commit
a2dccc6c6b
41
SCR.1.2/TP08/bin2dot-withfor.sh
Executable file
41
SCR.1.2/TP08/bin2dot-withfor.sh
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ $# -lt 2 ]]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <mumarg1> <numarg2>"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f $2 ]]
|
||||||
|
then
|
||||||
|
read -p "File $2 exists. Overwrite ? Yes/ No --->" answer
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [[ $answer != "Yes" ]]
|
||||||
|
then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
cp /dev/null $2
|
||||||
|
fi
|
||||||
|
|
||||||
|
ARG=$1
|
||||||
|
ARG2=$2
|
||||||
|
addr=$1
|
||||||
|
|
||||||
|
for addr in (cat "$ARG");
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
binaire1=$(expr substr $addr 1 8)
|
||||||
|
octet1=$((2#$binaire1))
|
||||||
|
binaire2=$(expr substr $addr 9 8)
|
||||||
|
octet2=$((2#$binaire2))
|
||||||
|
binaire3=$(expr substr $addr 17 8)
|
||||||
|
octet4=$((2#$binaire3))
|
||||||
|
binaire4=$(expr substr $addr 25 8)
|
||||||
|
octet4=$((2#$binaire4))
|
||||||
|
|
||||||
|
echo addr_dot="$octet1.$octet2.octet3.octet4" >> $ARG2
|
||||||
|
|
||||||
|
done
|
||||||
|
exit
|
3
SCR.1.2/TP08/bin_ipv4_adress.dat
Normal file
3
SCR.1.2/TP08/bin_ipv4_adress.dat
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
10110010111000101000011101110010
|
||||||
|
11100101110001010101100101010010
|
||||||
|
00110010111001101000010001110010
|
1
SCR.1.2/TP08/dot_ipv4_addres.dat
Normal file
1
SCR.1.2/TP08/dot_ipv4_addres.dat
Normal file
@ -0,0 +1 @@
|
|||||||
|
Usage: ./bin2dot-withfor.sh <mumarg1> <numarg2>
|
29
SCR.1.2/TP08/fichier-reponses-tp08.txt
Normal file
29
SCR.1.2/TP08/fichier-reponses-tp08.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
TP08
|
||||||
|
|
||||||
|
3.
|
||||||
|
|
||||||
|
[yolou@archlinux TP08]$ read x
|
||||||
|
7888
|
||||||
|
[yolou@archlinux TP08]$ echo $x
|
||||||
|
7888
|
||||||
|
[yolou@archlinux TP08]$ echo $?
|
||||||
|
0
|
||||||
|
|
||||||
|
Explication : Code de sortie pour $?
|
||||||
|
|
||||||
|
[yolou@archlinux TP08]$ read x (CRTL+D)
|
||||||
|
|
||||||
|
[yolou@archlinux TP08]$ echo "$? x=$x"
|
||||||
|
1 x=
|
||||||
|
|
||||||
|
Explication : CRTL+D ça signie fin de fichier sur l'entrée standards. On va donc utiliser le fait que read renvoie un code different de 0 lorsqu'ell rencontre une fin de fichier.
|
||||||
|
|
||||||
|
Pour le code : for addr in $(cat $1)
|
||||||
|
cp bin2dot-withfor.sh bin2dot-with-read.sh
|
||||||
|
|
||||||
|
while read addr
|
||||||
|
do
|
||||||
|
|
||||||
|
addr_dot=
|
||||||
|
echo $addr_dot >> $2
|
||||||
|
done
|
27
SCR.1.2/TP08/mult_mat.sh
Executable file
27
SCR.1.2/TP08/mult_mat.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ $# -lt 2 ]]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <mumarg1> <numarg2>"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $1 -gt $2 ]]
|
||||||
|
then
|
||||||
|
echo "Tu dois donne un 1er paramètre moins gros que celui de le deuxieme paramètre"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
ARG=$1
|
||||||
|
ARG2=$2
|
||||||
|
|
||||||
|
for ((i=ARG; i<=ARG2;i++))
|
||||||
|
do
|
||||||
|
for((j=ARG; j<=ARG2;j++))
|
||||||
|
do
|
||||||
|
echo -n $((i*j))" "
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
exit
|
13
SCR.1.2/TP08/my_seq.sh
Executable file
13
SCR.1.2/TP08/my_seq.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ $# -lt 1 ]]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <arg_numeric>"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
for (( i=1; i<=$1 ;i++ ))
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done
|
||||||
|
exit
|
0
SCR.1.2/TP09/TREE/lib/auth/transm.d
Normal file
0
SCR.1.2/TP09/TREE/lib/auth/transm.d
Normal file
8
SCR.1.2/TP09/TREE/lib/kernel/install.d/50-depmod.install
Executable file
8
SCR.1.2/TP09/TREE/lib/kernel/install.d/50-depmod.install
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
12
SCR.1.2/TP09/TREE/lib/kernel/install.d/50-mkinitcpio.install
Executable file
12
SCR.1.2/TP09/TREE/lib/kernel/install.d/50-mkinitcpio.install
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
add)
|
||||||
|
mkinitcpio -k "$2" -g "$3"/initrd
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
rm -f -- "$3"/initrd
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# vim: set ft=sh ts=4 sw=4 et:
|
89
SCR.1.2/TP09/TREE/lib/kernel/install.d/90-loaderentry.install
Executable file
89
SCR.1.2/TP09/TREE/lib/kernel/install.d/90-loaderentry.install
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
COMMAND="$1"
|
||||||
|
KERNEL_VERSION="$2"
|
||||||
|
BOOT_DIR_ABS="$3"
|
||||||
|
KERNEL_IMAGE="$4"
|
||||||
|
|
||||||
|
if [[ -f /etc/machine-id ]]; then
|
||||||
|
read MACHINE_ID < /etc/machine-id
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ $MACHINE_ID ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION"
|
||||||
|
LOADER_ENTRY="/boot/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
|
||||||
|
|
||||||
|
if [[ $COMMAND == remove ]]; then
|
||||||
|
exec rm -f "$LOADER_ENTRY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ $COMMAND == add ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ $KERNEL_IMAGE ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f /etc/os-release ]]; then
|
||||||
|
. /etc/os-release
|
||||||
|
elif [[ -f /usr/lib/os-release ]]; then
|
||||||
|
. /usr/lib/os-release
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ $PRETTY_NAME ]]; then
|
||||||
|
PRETTY_NAME="Linux $KERNEL_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -a BOOT_OPTIONS
|
||||||
|
|
||||||
|
if [[ -f /etc/kernel/cmdline ]]; then
|
||||||
|
readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ ${BOOT_OPTIONS[*]} ]]; then
|
||||||
|
readarray -t line < /proc/cmdline
|
||||||
|
for i in ${line[*]}; do
|
||||||
|
if [[ "${i#initrd=*}" == "$i" ]]; then
|
||||||
|
BOOT_OPTIONS[${#BOOT_OPTIONS[@]}]="$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ ${BOOT_OPTIONS[*]} ]]; then
|
||||||
|
echo "Could not determine the kernel command line parameters." >&2
|
||||||
|
echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" &&
|
||||||
|
chown root:root "$BOOT_DIR_ABS/linux" &&
|
||||||
|
chmod 0644 "$BOOT_DIR_ABS/linux" || {
|
||||||
|
echo "Could not copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir -p "${LOADER_ENTRY%/*}" || {
|
||||||
|
echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "title $PRETTY_NAME"
|
||||||
|
echo "version $KERNEL_VERSION"
|
||||||
|
echo "machine-id $MACHINE_ID"
|
||||||
|
echo "options ${BOOT_OPTIONS[*]}"
|
||||||
|
echo "linux $BOOT_DIR/linux"
|
||||||
|
[[ -f $BOOT_DIR_ABS/initrd ]] && \
|
||||||
|
echo "initrd $BOOT_DIR/initrd"
|
||||||
|
:
|
||||||
|
} > "$LOADER_ENTRY" || {
|
||||||
|
echo "Could not create loader entry '$LOADER_ENTRY'." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
exit 0
|
48
SCR.1.2/TP09/TREE/lib/krb5/plugins/inout.dev
Normal file
48
SCR.1.2/TP09/TREE/lib/krb5/plugins/inout.dev
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/db2.so
Normal file
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/db2.so
Normal file
Binary file not shown.
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/kldap.so
Normal file
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/kldap.so
Normal file
Binary file not shown.
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/play.in
Normal file
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/play.in
Normal file
Binary file not shown.
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/otp.so
Normal file
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/otp.so
Normal file
Binary file not shown.
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/pkinit.so
Normal file
BIN
SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/pkinit.so
Normal file
Binary file not shown.
16
SCR.1.2/TP09/TREE/lib/krb5/synch/atom.install
Normal file
16
SCR.1.2/TP09/TREE/lib/krb5/synch/atom.install
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
24
SCR.1.2/TP09/TREE/lib/krb5/synch/settings.sh
Normal file
24
SCR.1.2/TP09/TREE/lib/krb5/synch/settings.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||||
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||||
|
|
||||||
|
[[ $1 == "add" ]] || exit 0
|
||||||
|
[[ $2 ]] || exit 1
|
||||||
|
|
||||||
|
exec depmod -a "$2"
|
BIN
SCR.1.2/TP09/arch_for_find.tar.gz
Normal file
BIN
SCR.1.2/TP09/arch_for_find.tar.gz
Normal file
Binary file not shown.
48
SCR.1.2/TP09/fichier-reponses-tp08.txt
Normal file
48
SCR.1.2/TP09/fichier-reponses-tp08.txt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
TP09
|
||||||
|
|
||||||
|
I-
|
||||||
|
|
||||||
|
[yolou@archlinux TREE]$ mkdir lib/kernel/config/AA && mkdir lib/kernel/config/AA/BB && mkdir lib/kernel/config/AA/BB/DD && mkdir lib/kernel/config/AA/BB/DD/YY && mkdir lib/kernel/config/AA/BB/CC && mkdir lib/kernel/config/AA/BB/CC/XX
|
||||||
|
|
||||||
|
1)
|
||||||
|
|
||||||
|
[yolou@archlinux TREE]$ find -name "*.install" -type d
|
||||||
|
./lib/krb5/plugins/custom.install
|
||||||
|
|
||||||
|
la commande find permet trouver les fichier a parti d'un bout de l'expression / d'éleemnt donné (-type d permet de preciser le type de fichier trouve soit file ou directory) (l'option -name permet nous donne les noms de repertoires dans l'arborescence du repectoire courant).
|
||||||
|
|
||||||
|
2)
|
||||||
|
|
||||||
|
[yolou@archlinux TREE]$ find -name "*.d" -type f
|
||||||
|
./lib/auth/transm.d
|
||||||
|
|
||||||
|
Explication : A peu près l'explication précédente, ici -type d permet de preciser le type de fichier trouve soit file ou directory).
|
||||||
|
|
||||||
|
3) [yolou@archlinux TREE]$ find -empty -type d
|
||||||
|
./lib/kernel/config/AA/BB/DD/YY
|
||||||
|
./lib/kernel/config/AA/BB/CC/XX
|
||||||
|
./lib/krb5/plugins/custom.install
|
||||||
|
|
||||||
|
Explication : -empty l'option permet montrer les fichiers ou repertoires vide.
|
||||||
|
|
||||||
|
4)
|
||||||
|
[yolou@archlinux TREE]$ find . -size -1000c -type f
|
||||||
|
./lib/kernel/install.d/50-depmod.install
|
||||||
|
./lib/kernel/install.d/50-mkinitcpio.install
|
||||||
|
./lib/krb5/synch/atom.install
|
||||||
|
./lib/krb5/synch/settings.sh
|
||||||
|
./lib/auth/transm.d
|
||||||
|
|
||||||
|
Explication : l'option -size permet de preciser la taille en octet du fichier ou repertoire trouvé et l'opérateur - ou + permet d'effectuer une comparaison dans ce cas trouver les fichier inférieur à 1000 bytes (-1000) en précisant la lettre c on indique le l'unité est l'octet
|
||||||
|
|
||||||
|
5) [yolou@archlinux TREE]$ find -size +30000c -type f
|
||||||
|
./lib/krb5/plugins/preauth/pkinit.so
|
||||||
|
./lib/krb5/plugins/kdb/db2.so
|
||||||
|
|
||||||
|
Explication : l'option -size permet de preciser la taille en octet du fichier ou repertoire trouvé et l'opérateur - ou + permet d'effectuer une comparaison dans ce cas trouver les fichiers supérieur à 30000 bytes (+30000) en précisant la lettre c on indique le l'unité est l'octet
|
||||||
|
|
||||||
|
6)
|
||||||
|
[yolou@archlinux TREE]$ find -size 1024c -type f
|
||||||
|
./lib/krb5/plugins/play.in
|
||||||
|
|
||||||
|
Explication : l'option -size permet de preciser la taille en octet du fichier ou repertoire trouvé et l'opérateur - ou + permet d'effectuer une comparaison dans ce cas trouver les fichiers égale à 1024 bytes (1024) en précisant la lettre c on indique le l'unité est l'octet
|
Loading…
Reference in New Issue
Block a user