Skip to content

Instantly share code, notes, and snippets.

@maz-1
Last active August 26, 2018 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maz-1/557d438f46803409968c593658d25c66 to your computer and use it in GitHub Desktop.
Save maz-1/557d438f46803409968c593658d25c66 to your computer and use it in GitHub Desktop.
#!/bin/sh
stampfile=/tmp/sudo.${USER}.stamp
if [[ -t 1 ]]
then
if (test -f ${stampfile} && test `find "${stampfile}" -mmin +180`) || [ ! -f ${stampfile} ]
then
read -p "Are you sure to invoke this command in administrator mode? [Y/n] " answer
case $(echo $answer | tr [:upper:] [:lower:]) in
n|no)
return
;;
*)
touch ${stampfile}
exec /usr/bin/sudo "$@"
;;
esac
else
exec /usr/bin/sudo "$@"
fi
else
exec /usr/bin/sudo "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment