fixing script. first check should be root user

This commit is contained in:
Claudio Maradonna 2020-07-31 16:29:24 +02:00
parent 585051f57b
commit 75fc188ce7
Signed by: claudiomaradonna
GPG Key ID: 0CBA58694C5680D9
1 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,18 @@
#!/bin/bash
REMOTE_USER="root"
function check_if_running_as_root {
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
echo "OK: Root user detected."
}
check_if_running_as_root
read -p "Did you run this script on the remote host? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
@ -16,17 +29,6 @@ then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
REMOTE_USER="root"
function check_if_running_as_root {
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
echo "OK: Root user detected."
}
function check_necessary_packages {
echo "NEXT: Checking for valid package manager."
@ -105,7 +107,6 @@ function setup_systemd_service_if_available {
fi
}
check_if_running_as_root
check_necessary_packages
check_for_autossh_user