mirror of
https://github.com/NLnetLabs/routinator.git
synced 2024-05-19 06:50:04 +00:00
22 lines
665 B
Plaintext
22 lines
665 B
Plaintext
![]() |
#!/bin/bash
|
||
|
CMD="routinator --config /etc/routinator/routinator.conf init $@"
|
||
|
|
||
|
if [[ $EUID -eq $(id -u routinator) ]]; then
|
||
|
# We are the routinator user, go!
|
||
|
echo "Running command: $CMD"
|
||
|
$CMD
|
||
|
elif [[ $EUID -eq 0 ]]; then
|
||
|
# We are root, become routinator then go!
|
||
|
echo "Running command as user routinator: $CMD"
|
||
|
su -s /bin/sh -c "$CMD" routinator
|
||
|
else
|
||
|
# We are some other user, is sudo installed?
|
||
|
if command -v sudo &> /dev/null; then
|
||
|
echo "Running command as user routinator via sudo: $CMD"
|
||
|
sudo -u routinator $CMD
|
||
|
else
|
||
|
echo >&2 "Error: Unable to become user 'routinator' to run command: $CMD"
|
||
|
exit 1
|
||
|
fi
|
||
|
fi
|