diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-06-19 05:53:11 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-06-26 01:54:39 +0200 |
commit | 931d21bdec70419a2e54ca22f48524755899d031 (patch) | |
tree | 237733fbfb70afddda9ff51f0585451929e97315 | |
parent | 7a870899dbce365e780331598cfe24f47db12590 (diff) | |
download | vendor_replicant-scripts-931d21bdec70419a2e54ca22f48524755899d031.tar.gz vendor_replicant-scripts-931d21bdec70419a2e54ca22f48524755899d031.tar.bz2 vendor_replicant-scripts-931d21bdec70419a2e54ca22f48524755899d031.zip |
modem.sh: warn users if executing without root permissions
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-x | networking/modem/device-files/modem.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/networking/modem/device-files/modem.sh b/networking/modem/device-files/modem.sh index 626593b..b27aadd 100755 --- a/networking/modem/device-files/modem.sh +++ b/networking/modem/device-files/modem.sh @@ -34,10 +34,50 @@ usage() exit 1 } +check_permissions() +{ + modem_command="$1" + root_access="$(getprop persist.sys.root_access)" + uid="$(id -u)" + + # 0: Root access: Disabled, 2: Root access: ADB only + # For both the terminal application and ADB we have something + # like that: + # shell@i9100:/ $ su + # 255|shell@i9100:/ $ + # 1: Root access: Apps only + # From ADB: + # shell@i9100:/ $ su + # Permission denied + # 1|shell@i9100:/ $ + # From the terminal application + # u0_a51@i9100:/ $ su + # root@i9100:/ # + if [ "${uid}" != "0" ] ; then + echo "" + echo "This script requires root." + echo "To give it root:" + case "${root_access}" in + "0"|"1"|"2") + echo "- Go in Settings" + echo "- Go in Developer options" + echo "- Select Root access" + echo "- Set it to \"Apps and ADB\"" + ;; + esac + echo "- Run these 2 commands:" + echo " su" + echo " modem.sh ${modem_command}" + exit 1 + fi +} + modem() { command="$1" + check_permissions "${command}" + echo "Remounting system partition as writable..." mount -o rw,remount /system |