#!/bin/bash # # vpanel-stack # https://git.stack-source.com/msb/vpanel-stack # Copyright (c) 2022 Matthew Saunders Brown # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # first switch to root if [ "$USER" != "root" ]; then exec sudo -u root $0 $@ fi help() { thisfilename=$(basename -- "$0") echo "Check if specified user has vpanel sudo access." echo "" echo "usage: $thisfilename -u [-h]" echo "" echo " -u Username to check." echo " -h Print this help." } while getopts "hu:" opt ; do case "${opt}" in h ) # display help and exit help exit ;; u ) # username username=${OPTARG,,} ;; \? ) echo "Invalid option: $OPTARG" exit 1 ;; : ) echo "Invalid option: $OPTARG requires an argument" exit 1 ;; esac done # check for username if [[ -z $username ]]; then echo "username is required" exit 1 fi # check sudo rights if /usr/bin/sudo -l -U $username vpanel-verify-access.sh >/dev/null; then echo TRUE exit 0 else echo FALSE exit 1 fi