I am keeping this page for archival purposes in the hope that the material will be useful to others, but my teaching pages are not actively maintained and external links may break. I do not teach at the Villetaneuse IUT or at Université Sorbonne Paris Nord any longer; please see the home page for my current situation.

[2022: je vais garder cette page dans son état actuel, car certains scripts utilisés ailleurs dans mon site pourraient encore être utiles.
Cette page, à l'époque de mes enseignements, était à un autre URL. Je devrais avoir corrigé toute référence.]

Luca Saiu — enseignements — page avec remarques, liens temporaires et scripts

This is a page for random unorganized notes that I may need to share with others occasionally.

Anything here can change or be removed at any time. If you are interested in some piece of information shared in this page please save a copy for yourself.

Some of the notes below may involve Python, as used for teaching beginner classes.
I do not personally endorse Python except as a first language for absolute beginners, and even in that case not as my preferred first choice.


Ma fonction Bash add-prefix

Veuillez garder cette fonction Bash : on va la réutiliser à l'avenir.

J'ai aussi publié mon fichier .bashrc contenant la fonction et plein d'autres définitions, mais il ne sera probablement pas nécessaire.

HOSTNAME="$(hostname)"
function add-prefix {
    partial="no"
    case "$#" in
        1) prefix="$1";;
        2) prefix="$1"
           if [[ "$2" == "partial" ]]; then
               partial="yes"
           else
               echo "$0: the second argument, if specified, must be \"partial\"."
               return -1
           fi;;
        *) echo "$0: either one argument (the prefix path) or two: prefix path, \"partial\"."
           return -1;;
    esac
    case "$HOSTNAME" in
        sussman)
            TRIPLET="mipsel-linux-gnu"
            ;;
        abelson | moore)
            TRIPLET="x86_64-linux-gnu"
            ;;
        knuth)
            TRIPLET="powerpc-linux-gnu"
            ;;
        *)
            # Let's hope this exactly matches multilib paths
            TRIPLET="$(uname --machine)-linux-gnu"
            ;;
    esac
    # Let's hope $PATH is already defined...
    export PATH="$prefix/sbin:$prefix/bin:$PATH"

    # FIXME: is the order correct?
    export PATH="$prefix/libexec:$PATH"

    if [[ "$partial" != "yes" ]]; then
        if [[ "$LIBRARY_PATH" == "" ]]; then
            export LIBRARY_PATH="/lib/$TRIPLET:/lib:/usr/local/lib/$TRIPLET:/usr/local/lib:/usr/lib/$TRIPLET:/usr/lib:/usr/X11R6/lib:/lib64:/usr/local/lib64:/usr/lib64:/usr/X11R6/lib64"
        fi
        export LIBRARY_PATH="$prefix/lib/$TRIPLET:$prefix/lib:$prefix/lib64:$LIBRARY_PATH"

        if [[ "$LD_LIBRARY_PATH" == "" ]]; then
            export LD_LIBRARY_PATH="/lib/$TRIPLET:/lib:/usr/local/lib/$TRIPLET:/usr/local/lib:/usr/lib/$TRIPLET:/usr/lib:/usr/X11R6/lib:/lib64:/usr/local/lib64:/usr/lib64:/usr/X11R6/lib64"
            #export LD_LIBRARY_PATH="/lib:/usr/local/lib:/usr/lib:/usr/X11R6/lib:/lib64:/usr/local/lib64:/usr/lib64:/usr/X11R6/lib64:/lib/mipsel-linux-gnu"
        fi
        export LD_LIBRARY_PATH="$prefix/lib/$TRIPLET:$prefix/lib:$prefix/lib64:$LD_LIBRARY_PATH"
    fi

    if [[ "$MANPATH" == "" ]]; then
        export MANPATH="/usr/local/man:/usr/local/share/man:/usr/man:/usr/share/man:/usr/X11R6/man:/usr/X11R6/share/man"
    fi
    export MANPATH="$prefix/man:$prefix/share/man:$MANPATH"

    if [[ "$INFOPATH" == "" ]]; then
        export INFOPATH="/usr/local/info:/usr/local/share/info:/usr/info:/usr/share/info:/usr/X11R6/info:/usr/X11R6/share/info"
    fi

    export INFOPATH="$prefix/info:$prefix/share/info:$INFOPATH"
    if [[ "$partial" != "yes" ]]; then
        if [[ "$CPATH" == "" ]]; then
            export CPATH="/usr/local/include/$TRIPLET:/usr/local/include:/usr/include/$TRIPLET:/usr/include:/usr/X11R6/include:/usr/include/X11"
            #export CPATH="/usr/local/include:/usr/include:/usr/X11R6/include:/usr/include/X11"
        fi
        export CPATH="$prefix/include/$TRIPLET:$prefix/include:$CPATH"
        if [[ "$C_INCLUDE_PATH" == "" ]]; then
            export C_INCLUDE_PATH="/usr/local/include/$TRIPLET:/usr/local/include:/usr/include/$TRIPLET:/usr/include:/usr/X11R6/include:/usr/include/X11"
        fi
        export C_INCLUDE_PATH="$prefix/include/$TRIPLET:$prefix/include:$C_INCLUDE_PATH"

        if [[ "$CPLUS_INCLUDE_PATH" == "" ]]; then
            CPLUS_INCLUDE_PATH="/usr/local/include/$TRIPLET:/usr/local/include:/usr/include/$TRIPLET:/usr/include:/usr/X11R6/include:/usr/include/X11"
            #export CPLUS_INCLUDE_PATH="/usr/local/include:/usr/include:/usr/X11R6/include:/usr/include/X11"
        fi
        export CPLUS_INCLUDE_PATH="$prefix/include/$TRIPLET:$prefix/include:$CPLUS_INCLUDE_PATH"

        if [[ "$OBJC_INCLUDE_PATH" == "" ]]; then
            export OBJC_INCLUDE_PATH="/usr/local/include/$TRIPLET:/usr/local/include:/usr/include/$TRIPLET:/usr/include:/usr/X11R6/include:/usr/include/X11"
            #export OBJC_INCLUDE_PATH="/usr/local/include:/usr/include:/usr/X11R6/include:/usr/include/X11"
        fi
        export OBJC_INCLUDE_PATH="$prefix/include/$TRIPLET:$prefix/include:$OBJC_INCLUDE_PATH"

        if [[ "$PKG_CONFIG_PATH" == "" ]]; then
            export PKG_CONFIG_PATH=/usr/local/share/pkgconfig:/usr/share/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
        fi
        export PKG_CONFIG_PATH="$prefix/share/pkgconfig:$prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
    fi

    if [[ $ACLOCAL_PATH == "" ]]; then
        if [ -d /usr/share/aclocal ]; then
            export ACLOCAL_PATH="/usr/share/aclocal"
        fi
        if [ -d /usr/local/share/aclocal ]; then
            export ACLOCAL_PATH="/usr/local/share/aclocal:$ACLOCAL_PATH"
        fi
    fi
    export ACLOCAL_PATH="$prefix/share/aclocal:$ACLOCAL_PATH"
}

Installer rfoo

Installer rfoo à l'IUT.

pip3 install cython --user
git clone https://github.com/aaiyer/rfoo
cd rfoo
python3 setup.py build_ext --inplace

En alternative, on peut utiliser Python version 2:

pip install cython --user
git clone https://github.com/aaiyer/rfoo
cd rfoo
python2 setup.py build_ext --inplace

Une alternative pour installer pip:

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user

Non testé par moi :

python3 -m ensurepip

Pour ces qui ont accès comme root (apparemment il faut un libssl-dev récent; on accepte de le mettre à jour):

aptitude install python3-pip

Je n'ai pas trouvé un paquet debian python-rfoo pour Python 3, mais on peut l'installer banalement en utilisant pip sur Python 3 (vérifié par moi).


M1101: iptables

Ma façon de resetter l'état du pare-feu sur mon serveur :

for option in -{Z,F,X}; do
  iptables "${option}"
done
for table in filter nat mangle; do
  for option in -{F,X,Z}; do
    iptables -t "${table}" "${option}"
  done
done

J'utilise ces commandes dans un script avant de réconfigurer le filtrage et le routage avec iptables. En faisant comme ça j'évite de redémarrer la machine, et je peux exécuter ou tester des configurations alternatives à partir d'un état initial propre.



[hacker emblem]
Luca Saiu
Last modified: 2022-11-26

Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2022 Luca Saiu
Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.