Fixed missing arguments when sudoing.

This commit is contained in:
ryt51V 2016-03-04 10:22:26 +00:00
parent 5ecde852a0
commit 93c4525406

View file

@ -17,7 +17,7 @@ SUDO=""
function rerun_root() { function rerun_root() {
# Check if root, and if not then rerun with sudo. # Check if root, and if not then rerun with sudo.
# The parent script should pass its $0 and $@ to this function's $1 and $2 # The parent script should pass its $0 and $@ to this function.
echo ":::" echo ":::"
if [[ $EUID -eq 0 ]];then if [[ $EUID -eq 0 ]];then
echo "::: You are root." echo "::: You are root."
@ -26,8 +26,8 @@ function rerun_root() {
# Check if it is actually installed # Check if it is actually installed
# If it isn't, exit because the install cannot complete # If it isn't, exit because the install cannot complete
if [[ $(dpkg-query -s sudo) ]];then if [[ $(dpkg-query -s sudo) ]];then
echo "::: Running sudo $1 $2" echo "::: Running sudo $@"
sudo "$1" "$2" sudo "$@"
exit $? exit $?
else else
echo "::: Please install sudo." echo "::: Please install sudo."
@ -38,7 +38,7 @@ function rerun_root() {
function rerun_pihole() { function rerun_pihole() {
# Check if pihole user, and if not then rerun with sudo. # Check if pihole user, and if not then rerun with sudo.
# The parent script should pass its $0 and $@ to this function's $1 and $2 # The parent script should pass its $0 and $@ to this function.
echo ":::" echo ":::"
runninguser=$(whoami) runninguser=$(whoami)
if [[ "$runninguser" = "pihole" ]];then if [[ "$runninguser" = "pihole" ]];then
@ -48,8 +48,8 @@ function rerun_pihole() {
# Check if it is actually installed # Check if it is actually installed
# If it isn't, exit because the install cannot complete # If it isn't, exit because the install cannot complete
if [[ $(dpkg-query -s sudo) ]];then if [[ $(dpkg-query -s sudo) ]];then
echo "::: Running sudo -u pihole $1 $2" echo "::: Running sudo -u pihole $@"
sudo -u pihole "$1" "$2" sudo -u pihole "$@"
exit $? exit $?
else else
echo "::: Please install sudo." echo "::: Please install sudo."