• viverna
  • ifj
  • Issues
  • #2

Closed
Open
Opened 2019-12-23T22:48Z by spiralofhope @spiralofhope

prompt for root password

If I may recommend:

https://github.com/spiralofhope/shell-random/blob/master/live/sh/scripts/examples/run-script-as-root.sh

if ! [ "$USER" = 'root' ]; then
  \\echo  'enter root password'
  /bin/su  --command  "$0"
else

# (code)

fi

Note thatsudomay be more appropriate than/bin/su, but a user may not have access to it.

Please solve the reCAPTCHA

We want to be sure it is you, please confirm you are not a robot.

Edited 2019-12-23T17:49Z by spiralofhope
  • spiralofhope @spiralofhope changed the description · 2019-12-23T17:49Z

    changed the description

  • viverna
    viverna @viverna · 2019-12-29T10:41Z

    Thanks for your contribution. However it is more simple return with error and allow the user use sudo or su. I have already implemented the change. I will commit as soon as possible.if ! [ "$USER" = 'root' ]; then printf "%s\ " "Run $0 as root" exit $EXIT_NO_ROOT fi

  • viverna @viverna closed · 2019-12-29T10:41Z

    closed

  • viverna @viverna mentioned in commit 53b7498e · 2019-12-29T10:54Z

    mentioned in commit 53b7498e