This commit is contained in:
Konano 2023-07-23 01:42:13 +08:00
parent 52b5fc4aba
commit cc44fe9fa9
3 changed files with 4 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
scriptdir=$(dirname $(realpath $0))
tempdir="/tmp"
tempdir=$(mktemp -d)
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."

View File

@ -1,14 +1,14 @@
#!/bin/bash
scriptdir=$(dirname $(realpath $0))
tempdir="/tmp"
tempdir=$(mktemp -d)
if [[ $EUID -eq 0 ]]; then
echo "This script should not be run as root."
exit 1
fi
if ! sudo -v; then
if [[ $(sudo whoami) != "root" ]]; then
echo "Please get sudo access first."
exit 1
fi

3
run.sh
View File

@ -1,14 +1,13 @@
#!/bin/bash
scriptdir=$(dirname $(realpath $0))
tempdir="/tmp"
# ============================================================
if [[ $EUID -eq 0 ]]; then
echo "Running in root mode."
sh $scriptdir/init_root.sh
elif sudo -v; then
elif [[ $(sudo whoami) == "root" ]]; then
echo "Running in sudo mode."
sh $scriptdir/init_sudo.sh
else