aysu 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. # aysu: sudo kullanarak root olun
  3. if [ ! -f /usr/bin/zenity ] ; then
  4. echo "önce zenity kurulacak, otomatik kurulmaz ise elle kurun"
  5. sudo paket kur zenity
  6. fi
  7. PRGNAME=$(basename "$0")
  8. # Check which mode to operate in based upon which name we were called as.
  9. if [ "$PRGNAME" = xfsu ]; then
  10. MODE=as_root # run with root priviliges and root's environment variables
  11. else
  12. MODE=as_sudo # run with root priviliges and user's environment variables
  13. fi
  14. # Check if command line argument specified or not
  15. if [ -z "$1" ]; then
  16. zenity --title='Ay-Su' --error --text='Program belirtilmedi'
  17. exit 1
  18. fi
  19. # Check for -h option
  20. if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  21. echo "Kullanımı: $PRGNAME <program>"
  22. exit 1
  23. fi
  24. # Check if the program called exists
  25. #if ! type -p "$1" &>/dev/null; then
  26. # zenity --title='xfsudo' --error --text='Non existing program specified'
  27. # exit 1
  28. #fi
  29. # Get the password
  30. PASS=$(zenity --title='Ay-Su' --password) || exit 1
  31. flag=0
  32. # Pass the password and command-line arguments to sudo
  33. if [ "$MODE" = as_sudo ]; then
  34. echo "$PASS" | sudo -p "" -SkE "$@" >/dev/null 2>&1 | grep "incorrect password" && flag=1
  35. else
  36. echo "$PASS" | sudo -p "" -Sik "$@" >/dev/null 2>&1 | grep "incorrect password" && flag=1
  37. fi
  38. if [ "$flag" -eq 1 ]; then
  39. zenity --title='Ay-Su' --error --text='Yanlış parola girdiniz'
  40. fi
  41. # Done
  42. exit $?