the-modem-distro / pinephone_modem_sdk

Pinephone Modem SDK: Tools to build your own bootloader, kernel and rootfs
GNU General Public License v3.0
595 stars 64 forks source link

Added support for using doas instead of sudo if sudo isnt there. #161

Closed Spagett1 closed 1 year ago

Spagett1 commented 1 year ago

Since distros running sxmo have doas installed some users (me included) have removed sudo, this patch adds a quick check to the flashall script which checks if sudo exists and otherwise runs doas if its not found.

Biktorgj commented 1 year ago

Maybe instead of trying to guess, we should just stop if user isn't root, and instruct him/her to elevate with whatever the user has?

Just adding something like this would be enough and we could get rid of any sudo, doas etc. if [[ $(id -u) -ne 0 ]] ; then echo "This script must be run as root!" ; exit 1 ; fi

As far as your commit goes,I don't see any problem on incorporating it, just wondering if adding checks for any implementation of sudo that might appear is worth , instead of... just stopping if user doesn't have enough privileges to run it?

Spagett1 commented 1 year ago

Honestly that is how i would do it, i just made this patch to keep in the style of the current formula, i would do if [ $(id -u) -ne 0 ] ; then echo "This script must be run as root!" ; exit 1 ; fi Instead though (no need for the double []) for posix compliancey with shells like dash.

Biktorgj commented 1 year ago

Honestly that is how i would do it, i just made this patch to keep in the style of the current formula, i would do if [ $(id -u) -ne 0 ] ; then echo "This script must be run as root!" ; exit 1 ; fi Instead though (no need for the double []) for posix compliancey with shells like dash.

If there's an assumption we can make, is that any Pinephone user will know well how to elevate as root :) Thanks for the help!