From 1d657e728b355c8766d95ecd59c93cb6a8ec62da Mon Sep 17 00:00:00 2001 From: ycharbi Date: Sun, 11 Feb 2024 15:06:36 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20deux=20variables=20globales=20cont?= =?UTF-8?q?enant=20le=20chemin=20des=20binaires=20"ip"=20et=20"bridge"=20a?= =?UTF-8?q?fin=20de=20permettre=20leur=20ex=C3=A9cution=20en=20dehors=20de?= =?UTF-8?q?=20"$PATH"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qemu-adm | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/qemu-adm b/qemu-adm index 86fc262..0a46216 100755 --- a/qemu-adm +++ b/qemu-adm @@ -5,6 +5,8 @@ base_chemin_mv="/tmp/ramdisk/qemu-adm" bin_qemu="/usr/bin/qemu-system-x86_64" bin_qemu_img="/usr/bin/qemu-img" +bin_ip="/usr/bin/ip" +bin_bridge="/usr/sbin/bridge" chemin_services_demons="/usr/local/etc/systemd/system" chemin_services_production="/etc/systemd/system" nom_script=$(basename $0) @@ -551,11 +553,11 @@ genCmdIntRzo(){ # Création d'une interface simple if [[ "${pont_init}" -eq 1 && "${vlan_init}" -eq 2 && "${interface_init}" -eq 1 ]]; then # Commandes à executer au demarrage - commandes_a_executer_on+=( "ip tuntap add ${interface} mode tap" ) - commandes_a_executer_on+=( "ip link set ${interface} up" ) - commandes_a_executer_on+=( "ip link set ${interface} master ${pont}" ) + commandes_a_executer_on+=( "${bin_ip} tuntap add ${interface} mode tap" ) + commandes_a_executer_on+=( "${bin_ip} link set ${interface} up" ) + commandes_a_executer_on+=( "${bin_ip} link set ${interface} master ${pont}" ) # Commandes à exectuer à l'arrêt - commandes_a_executer_off+=( "ip link del ${interface}" ) + commandes_a_executer_off+=( "${bin_ip} link del ${interface}" ) # Réinitialisation des variables témoins pont_init=0 @@ -565,13 +567,13 @@ genCmdIntRzo(){ # Création d'une interface non étiqueté (access) elif [[ "${pont_init}" -eq 1 && "${vlan_init}" -eq 1 && "${interface_init}" -eq 1 ]]; then # Commandes à executer au demarrage - commandes_a_executer_on+=( "ip tuntap add ${interface} mode tap" ) - commandes_a_executer_on+=( "ip link set ${interface} up" ) - commandes_a_executer_on+=( "ip link set ${interface} master ${pont}" ) - commandes_a_executer_on+=( "bridge vlan del dev ${interface} vid 1 PVID untagged master" ) - commandes_a_executer_on+=( "bridge vlan add dev ${interface} vid ${vlan} pvid untagged master" ) + commandes_a_executer_on+=( "${bin_ip} tuntap add ${interface} mode tap" ) + commandes_a_executer_on+=( "${bin_ip} link set ${interface} up" ) + commandes_a_executer_on+=( "${bin_ip} link set ${interface} master ${pont}" ) + commandes_a_executer_on+=( "${bin_bridge} vlan del dev ${interface} vid 1 PVID untagged master" ) + commandes_a_executer_on+=( "${bin_bridge} vlan add dev ${interface} vid ${vlan} pvid untagged master" ) # Commandes à exectuer à l'arrêt - commandes_a_executer_off+=( "ip link del ${interface}" ) + commandes_a_executer_off+=( "${bin_ip} link del ${interface}" ) # Réinitialisation des variables témoins pont_init=0 @@ -580,15 +582,15 @@ genCmdIntRzo(){ # Création d'une interface étiqueté (trunk) elif [[ "${pont_init}" -eq 1 && "${ieee8021q_init}" -eq 1 && "${interface_init}" -eq 1 ]]; then - commandes_a_executer_on+=( "ip tuntap add ${interface} mode tap" ) - commandes_a_executer_on+=( "ip link set ${interface} up" ) - commandes_a_executer_on+=( "ip link set ${interface} master ${pont}" ) - commandes_a_executer_on+=( "bridge vlan del dev ${interface} vid 1 PVID untagged master" ) + commandes_a_executer_on+=( "${bin_ip} tuntap add ${interface} mode tap" ) + commandes_a_executer_on+=( "${bin_ip} link set ${interface} up" ) + commandes_a_executer_on+=( "${bin_ip} link set ${interface} master ${pont}" ) + commandes_a_executer_on+=( "${bin_bridge} vlan del dev ${interface} vid 1 PVID untagged master" ) for ((id_label_vlan=0 ; "${nb_params_label}" - "${id_label_vlan}" ; id_label_vlan++)); do - commandes_a_executer_on+=( "bridge vlan add dev ${interface} vid ${label_vlan[${id_label_vlan}]} tagged master" ) + commandes_a_executer_on+=( "${bin_bridge} vlan add dev ${interface} vid ${label_vlan[${id_label_vlan}]} tagged master" ) done # Commandes à exectuer à l'arrêt - commandes_a_executer_off+=( "ip link del ${interface}" ) + commandes_a_executer_off+=( "${bin_ip} link del ${interface}" ) # Réinitialisation des variables témoins pont_init=0 @@ -611,7 +613,7 @@ recupParams(){ # Récupération des données d'après le fichier de configuration if [ "${nom_param}" == "PONT" ]; then if [[ ${verif_params} == "vrai" ]]; then - if [[ $(ip link show "${val_param}" 2> /dev/null) ]]; then + if [[ $(${bin_ip} link show "${val_param}" 2> /dev/null) ]]; then pont="${val_param}" pont_init=1 else @@ -651,7 +653,7 @@ recupParams(){ done elif [ "${nom_param}" == "INTERFACE" ]; then if [[ ${verif_params} == "vrai" ]]; then - if [[ ! $(ip link show "${val_param}" 2> /dev/null) ]]; then + if [[ ! $(${bin_ip} link show "${val_param}" 2> /dev/null) ]]; then if [[ "${vlan_init}" -eq 1 || "${vlan_init}" -eq 2 || "${ieee8021q_init}" -eq 1 ]]; then interface="${val_param}" interface_init=1