Advertisement
sergio_educacionit

funciones

Oct 5th, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. # funcion
  5.  
  6. func_root () {
  7.  
  8.     test $UID -eq 0
  9. }
  10.  
  11. func_help () {
  12.     echo "Ejecute este script con privilegios de 'root'."
  13.     echo "Modo de uso:"
  14.     echo "  $0 opciones argumentos"
  15.     echo "  Donde argumentos es un usuaio del sistema"
  16.     echo ""
  17.     echo "-c    añade un cron"
  18.     echo "-d    elimna un cron"
  19.     echo "-i    imprime un cron"
  20.     echo "-h --help imprime esta ayuda"
  21.     echo ""
  22. }
  23.  
  24. func_user () {
  25.     local user=$1
  26.  
  27.     if grep ^$user /etc/passwd > /dev/null 2>&1 ; then
  28.            # si el usuario existe el exit status es 0
  29.         return 0
  30.     else
  31.            echo -e "El usuario no exite\n"
  32.            # de lo contrario es 1
  33.            return 1
  34.     fi
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement