Skip to content

Commit 72a8a49

Browse files
committed
Check early for sudo.
In case of uncached credentials the user will be prompted for credentials on startup.
1 parent 39ab4cf commit 72a8a49

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

bin/get-node-status

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#!/bin/bash
22

3+
is_root=0
4+
35
execute_sudo() {
4-
if sudo -v &> /dev/null; then
5-
if [[ $(id -u) -eq 0 ]]; then
6-
bash -c "$*"
7-
else
8-
sudo bash -c "$*"
9-
fi
6+
if [[ ${is_root} -eq 1 ]]; then
7+
bash -c "$*"
108
else
11-
echo "The user does not have sudo privileges. Exiting the program."
12-
exit 1
9+
sudo bash -c "$*"
1310
fi
1411
}
1512

@@ -73,6 +70,15 @@ if [ -z "${container_id}" ]; then
7370
exit 1
7471
fi
7572

73+
if [[ $(id -u) -eq 0 ]]; then
74+
is_root=1
75+
else
76+
echo "Checking for sudo access, you may be prompted for your password."
77+
if ! sudo -v &> /dev/null; then
78+
abort "User does not have sudo access. Please run this script as a user with sudo access."
79+
fi
80+
fi
81+
7682
declare -A health_checks
7783

7884
if [[ $(docker exec -it "${container_id}" bash -c "goal node status") ]]; then

bin/migrate-from-host-setup

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ fi
1717

1818
if [[ $(id -u) -eq 0 ]]; then
1919
is_root=1
20+
else
21+
echo "Checking for sudo access, you may be prompted for your password."
22+
if ! sudo -v &> /dev/null; then
23+
abort "User does not have sudo access. Please run this script as a user with sudo access."
24+
fi
2025
fi
2126

2227
echo "This script will assist migrating your node from a host-based setups to Voi Swarm, if your node is already running a Voi or Algorand based setup."

bin/set-telemetry-name

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ fi
6363

6464
if [[ $(id -u) -eq 0 ]]; then
6565
is_root=1
66+
else
67+
echo "Checking for sudo access, you may be prompted for your password."
68+
if ! sudo -v &> /dev/null; then
69+
abort "User does not have sudo access. Please run this script as a user with sudo access."
70+
fi
6671
fi
6772

6873
if [[ $1 && $2 ]]; then

install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,11 @@ fi
804804

805805
if [[ $(id -u) -eq 0 ]]; then
806806
is_root=1
807+
else
808+
echo "Checking for sudo access, you may be prompted for your password."
809+
if ! sudo -v &> /dev/null; then
810+
abort "User does not have sudo access. Please run this script as a user with sudo access."
811+
fi
807812
fi
808813

809814
# Get Linux OS distribution

0 commit comments

Comments
 (0)