Skip to content

Commit 4057e63

Browse files
Xaytonlucarin91
andauthored
fix: add a way to run sudo commands with interactive password prompt (#646)
Co-authored-by: lucarin91 <lucarin@protonmail.com>
1 parent af553af commit 4057e63

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Taskfile.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,23 @@ tasks:
189189

190190
board:install-arduino-app-cli:
191191
desc: Install arduino-app-cli on the board
192+
interactive: true
192193
cmds:
193194
- rm ./build/*.deb || true
194195
- task: build-deb:arduino-app-cli
195196
- adb shell rm /tmp/*.deb || true
196197
- adb push ./build/arduino-app-cli_*_arm64.deb /tmp/
197-
- adb shell dpkg -i /tmp/arduino-app-cli*_arm64.deb
198+
- ./scripts/run-remote-sudo.sh "dpkg -i /tmp/arduino-app-cli*_arm64.deb && needrestart -r a"
198199

199200
board:install-router:
200201
desc: Install arduino-router on the board
202+
interactive: true
201203
cmds:
202204
- rm ./build/*.deb || true
203205
- task: build-deb:arduino-router
204206
- adb shell rm /tmp/*.deb || true
205207
- adb push ./build/arduino-router_*_arm64.deb /tmp/
206-
- adb shell dpkg -i /tmp/arduino-router_*_arm64.deb
208+
- ./scripts/run-remote-sudo.sh "dpkg -i /tmp/arduino-router_*_arm64.deb && needrestart -r a"
207209

208210
setup:examples:local:
209211
desc: Download and locally install the official examples

scripts/run-remote-sudo.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Runs a command as sudo on the board (adb shell), while prompting for the password interactively.
4+
# To be used in the taskfile.
5+
6+
read -s -p "Enter device sudo password: " SUDO_PASS
7+
echo
8+
9+
# Run the command remotely with sudo, piping the password
10+
echo "$SUDO_PASS" | adb shell "sudo -S sh -c \"$*\""

0 commit comments

Comments
 (0)