test if running as root

This commit is contained in:
2026-07-02 10:39:13 +00:00
parent 01b3a189ed
commit 9f51718235
+7
View File
@@ -3,6 +3,13 @@
# "Using OTG mode on Raspberry Pi SBCs" # "Using OTG mode on Raspberry Pi SBCs"
# https://pip-assets.raspberrypi.com/categories/685-app-notes-guides-whitepapers/documents/RP-009276-WP/Using-OTG-mode-on-Raspberry-Pi-SBCs # https://pip-assets.raspberrypi.com/categories/685-app-notes-guides-whitepapers/documents/RP-009276-WP/Using-OTG-mode-on-Raspberry-Pi-SBCs
# This script only works if you are running it as root
if [ $(id -u) -ne 0 ]; then
echo "Please run as root or use sudo"
exit 1
fi
# Is the dwc2 overlay installed? Nothing will work if it isn't. # Is the dwc2 overlay installed? Nothing will work if it isn't.
if lsmod | grep -q "dwc2"; then if lsmod | grep -q "dwc2"; then
systemd-cat -t gadget.sh -p info echo "DWC2 module loaded, setting up OTG gadget serial and ethernet" systemd-cat -t gadget.sh -p info echo "DWC2 module loaded, setting up OTG gadget serial and ethernet"