From ea87b7bf9321c4d6d33d18b71056675b17bfe9e4 Mon Sep 17 00:00:00 2001 From: Douglas Barone Date: Wed, 7 Jun 2023 10:53:15 -0400 Subject: [PATCH] Require root --- pdc-add-user-aluno.sh | 6 ++++++ pdc-add-user-professor.sh | 6 ++++++ pdc-add-user-servidor.sh | 6 ++++++ pdc-del-user.sh | 6 ++++++ pdc-reset-password.sh | 6 ++++++ pdc-setquota.sh | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/pdc-add-user-aluno.sh b/pdc-add-user-aluno.sh index 9ee7027..1564e0e 100755 --- a/pdc-add-user-aluno.sh +++ b/pdc-add-user-aluno.sh @@ -6,6 +6,12 @@ # For use with Zential Server # ############################### +# Check if is running as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + USERNAME=$1 NAME=$2 DEFAULT_QUOTA=256000 # 256MB diff --git a/pdc-add-user-professor.sh b/pdc-add-user-professor.sh index c00f0bd..59eb62f 100755 --- a/pdc-add-user-professor.sh +++ b/pdc-add-user-professor.sh @@ -6,6 +6,12 @@ # For use with Zential Server # ############################### +# Check if is running as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + USERNAME=$1 NAME=$2 DEFAULT_QUOTA=256000 # 256MB diff --git a/pdc-add-user-servidor.sh b/pdc-add-user-servidor.sh index 61bd13e..cbfb929 100755 --- a/pdc-add-user-servidor.sh +++ b/pdc-add-user-servidor.sh @@ -6,6 +6,12 @@ # For use with Zential Server # ############################### +# Check if is running as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + USERNAME=$1 NAME=$2 DEFAULT_QUOTA=256000 # 256MB diff --git a/pdc-del-user.sh b/pdc-del-user.sh index 7ba7368..29130e7 100755 --- a/pdc-del-user.sh +++ b/pdc-del-user.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Check if is running as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + USERNAME=$1 # Check if arguments are not empty diff --git a/pdc-reset-password.sh b/pdc-reset-password.sh index ae2b103..d8c7238 100755 --- a/pdc-reset-password.sh +++ b/pdc-reset-password.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Check if is running as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + USERNAME=$1 DEFAULT_PASSWORD=123456789 PASSWORD=${2:-$DEFAULT_PASSWORD} diff --git a/pdc-setquota.sh b/pdc-setquota.sh index 07d59d1..b90317c 100755 --- a/pdc-setquota.sh +++ b/pdc-setquota.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Check if is running as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + USERNAME=$1 QUOTA=$2