Test mounted folder and try to mount

    0

    0

    bashmounttest

    This function mounts a file or directory if it is detected on the system, and then prints a message if the mountpoint fails.

    Library: Scripting et automatismes

    function montagedossier {
    if mountpoint -q -- "$1"
    then
      echo "Mount ok"
      # it is a mountpoint ok
    else
      mount $1
      if mountpoint -q -- "$1"
      then
        echo "Mount ok apres montage"
        # after mount, it is mounted ok
      else
        printf '%s\n' "$1 n'est toujours pas monté après tentative, arret du script"
        exit 1
      fi
    fi
    
    # utilisation
    montagedossier "/mon/dossier"
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.