diff --git a/SCR.1.2/TP08/bin2dot-withfor.sh b/SCR.1.2/TP08/bin2dot-withfor.sh new file mode 100755 index 0000000..aee36d9 --- /dev/null +++ b/SCR.1.2/TP08/bin2dot-withfor.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [[ $# -lt 2 ]] +then +echo "Usage: $0 " +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 \ No newline at end of file diff --git a/SCR.1.2/TP08/bin_ipv4_adress.dat b/SCR.1.2/TP08/bin_ipv4_adress.dat new file mode 100644 index 0000000..c765b63 --- /dev/null +++ b/SCR.1.2/TP08/bin_ipv4_adress.dat @@ -0,0 +1,3 @@ +10110010111000101000011101110010 +11100101110001010101100101010010 +00110010111001101000010001110010 \ No newline at end of file diff --git a/SCR.1.2/TP08/dot_ipv4_addres.dat b/SCR.1.2/TP08/dot_ipv4_addres.dat new file mode 100644 index 0000000..f9d0ae4 --- /dev/null +++ b/SCR.1.2/TP08/dot_ipv4_addres.dat @@ -0,0 +1 @@ +Usage: ./bin2dot-withfor.sh diff --git a/SCR.1.2/TP08/fichier-reponses-tp08.txt b/SCR.1.2/TP08/fichier-reponses-tp08.txt new file mode 100644 index 0000000..90966bd --- /dev/null +++ b/SCR.1.2/TP08/fichier-reponses-tp08.txt @@ -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 \ No newline at end of file diff --git a/SCR.1.2/TP08/mult_mat.sh b/SCR.1.2/TP08/mult_mat.sh new file mode 100755 index 0000000..a220509 --- /dev/null +++ b/SCR.1.2/TP08/mult_mat.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [[ $# -lt 2 ]] +then +echo "Usage: $0 " +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 diff --git a/SCR.1.2/TP08/my_seq.sh b/SCR.1.2/TP08/my_seq.sh new file mode 100755 index 0000000..9e67a41 --- /dev/null +++ b/SCR.1.2/TP08/my_seq.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ $# -lt 1 ]] +then +echo "Usage: $0 " +exit +fi + +for (( i=1; i<=$1 ;i++ )) +do + echo $i +done +exit diff --git a/SCR.1.2/TP09/TREE/lib/auth/transm.d b/SCR.1.2/TP09/TREE/lib/auth/transm.d new file mode 100644 index 0000000..e69de29 diff --git a/SCR.1.2/TP09/TREE/lib/kernel/install.d/50-depmod.install b/SCR.1.2/TP09/TREE/lib/kernel/install.d/50-depmod.install new file mode 100755 index 0000000..68c24be --- /dev/null +++ b/SCR.1.2/TP09/TREE/lib/kernel/install.d/50-depmod.install @@ -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" diff --git a/SCR.1.2/TP09/TREE/lib/kernel/install.d/50-mkinitcpio.install b/SCR.1.2/TP09/TREE/lib/kernel/install.d/50-mkinitcpio.install new file mode 100755 index 0000000..c8f51ba --- /dev/null +++ b/SCR.1.2/TP09/TREE/lib/kernel/install.d/50-mkinitcpio.install @@ -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: diff --git a/SCR.1.2/TP09/TREE/lib/kernel/install.d/90-loaderentry.install b/SCR.1.2/TP09/TREE/lib/kernel/install.d/90-loaderentry.install new file mode 100755 index 0000000..c17b8a9 --- /dev/null +++ b/SCR.1.2/TP09/TREE/lib/kernel/install.d/90-loaderentry.install @@ -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 diff --git a/SCR.1.2/TP09/TREE/lib/krb5/plugins/inout.dev b/SCR.1.2/TP09/TREE/lib/krb5/plugins/inout.dev new file mode 100644 index 0000000..0e36aef --- /dev/null +++ b/SCR.1.2/TP09/TREE/lib/krb5/plugins/inout.dev @@ -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" diff --git a/SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/db2.so b/SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/db2.so new file mode 100644 index 0000000..2ff0f07 Binary files /dev/null and b/SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/db2.so differ diff --git a/SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/kldap.so b/SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/kldap.so new file mode 100644 index 0000000..b9561fa Binary files /dev/null and b/SCR.1.2/TP09/TREE/lib/krb5/plugins/kdb/kldap.so differ diff --git a/SCR.1.2/TP09/TREE/lib/krb5/plugins/play.in b/SCR.1.2/TP09/TREE/lib/krb5/plugins/play.in new file mode 100644 index 0000000..06d7405 Binary files /dev/null and b/SCR.1.2/TP09/TREE/lib/krb5/plugins/play.in differ diff --git a/SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/otp.so b/SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/otp.so new file mode 100644 index 0000000..2362086 Binary files /dev/null and b/SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/otp.so differ diff --git a/SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/pkinit.so b/SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/pkinit.so new file mode 100644 index 0000000..48b9b60 Binary files /dev/null and b/SCR.1.2/TP09/TREE/lib/krb5/plugins/preauth/pkinit.so differ diff --git a/SCR.1.2/TP09/TREE/lib/krb5/synch/atom.install b/SCR.1.2/TP09/TREE/lib/krb5/synch/atom.install new file mode 100644 index 0000000..a793689 --- /dev/null +++ b/SCR.1.2/TP09/TREE/lib/krb5/synch/atom.install @@ -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" diff --git a/SCR.1.2/TP09/TREE/lib/krb5/synch/settings.sh b/SCR.1.2/TP09/TREE/lib/krb5/synch/settings.sh new file mode 100644 index 0000000..ada62ea --- /dev/null +++ b/SCR.1.2/TP09/TREE/lib/krb5/synch/settings.sh @@ -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" diff --git a/SCR.1.2/TP09/arch_for_find.tar.gz b/SCR.1.2/TP09/arch_for_find.tar.gz new file mode 100644 index 0000000..65a41e0 Binary files /dev/null and b/SCR.1.2/TP09/arch_for_find.tar.gz differ diff --git a/SCR.1.2/TP09/fichier-reponses-tp08.txt b/SCR.1.2/TP09/fichier-reponses-tp08.txt new file mode 100644 index 0000000..6210c00 --- /dev/null +++ b/SCR.1.2/TP09/fichier-reponses-tp08.txt @@ -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 \ No newline at end of file