+9
-11
configure-gadget.sh
+9
-11
configure-gadget.sh
···
1
-
#!/bin/bash
2
# setup_gadget_mode.sh - Script to configure USB gadget mode on a Raspberry Pi SD card
3
4
-
# Check if running as root
5
-
if [ "$EUID" -ne 0 ]; then
6
-
echo "Please run as root"
7
-
exit 1
8
-
fi
9
-
10
# Check if SD card boot partition is provided
11
if [ $# -lt 1 ]; then
12
-
echo "Usage: $0 /path/to/sd_card_boot_partition"
13
-
exit 1
14
fi
15
-
16
-
BOOT_PARTITION=$1
17
18
# Verify the boot partition exists
19
if [ ! -d "$BOOT_PARTITION" ]; then
···
1
+
#!/usr/bin/env bash
2
# setup_gadget_mode.sh - Script to configure USB gadget mode on a Raspberry Pi SD card
3
4
# Check if SD card boot partition is provided
5
if [ $# -lt 1 ]; then
6
+
if [ -d "/run/media/$(whoami)/bootfs" ]; then
7
+
BOOT_PARTITION="/run/media/$(whoami)/bootfs"
8
+
else
9
+
echo "Usage: $0 /path/to/sd_card_boot_partition"
10
+
exit 1
11
+
fi
12
+
else
13
+
BOOT_PARTITION=$1
14
fi
15
16
# Verify the boot partition exists
17
if [ ! -d "$BOOT_PARTITION" ]; then
setup.sh
setup.sh