fix: looping when switch user
This commit is contained in:
parent
c59b6e61d1
commit
78945bfd80
@ -34,6 +34,30 @@ function include () # $1: Lib
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_as_steamuser () # $@: command
|
||||||
|
{
|
||||||
|
include "/etc/steamcmd/steamcmd.conf"
|
||||||
|
|
||||||
|
if [[ "$(whoami)" == "$SteamUser" ]]; then
|
||||||
|
shift 2; cmd_main "$@"
|
||||||
|
elif [[ -n $(groups "$(whoami)" | grep -Fo 'wheel') ]] || [[ "$EUID" -eq 0 ]]; then
|
||||||
|
sudo -u "$SteamUser" "$@"
|
||||||
|
else
|
||||||
|
echo "You must be a $SteamUser, root or sudo-user to run this command."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_as_root () # $@: command
|
||||||
|
{
|
||||||
|
if [[ "$(whoami)" == "root" ]]; then
|
||||||
|
shift 2; cmd_main "$@"
|
||||||
|
elif [[ -n $(groups "$(whoami)" | grep -Fo 'wheel') ]]; then
|
||||||
|
sudo "$@"
|
||||||
|
else
|
||||||
|
echo "You must be root or sudo-user to run this command."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function is_help () # $1: Arg
|
function is_help () # $1: Arg
|
||||||
{
|
{
|
||||||
echo "$1" | grep -Piqo '^(-h|--help|help)$'
|
echo "$1" | grep -Piqo '^(-h|--help|help)$'
|
||||||
@ -146,9 +170,9 @@ elif [[ -d "$GroupPathname" ]]; then
|
|||||||
else
|
else
|
||||||
if function_exists "cmd_main"; then
|
if function_exists "cmd_main"; then
|
||||||
if function_exists "cmd_need_superuser" && cmd_need_superuser; then
|
if function_exists "cmd_need_superuser" && cmd_need_superuser; then
|
||||||
run_as_root "$ScriptFullname" "$Group" "$Command" "$@"
|
run_as_root "${ScriptFullname}${KF2POSTFIX}" "$Group" "$Command" "$@"
|
||||||
elif function_exists "cmd_need_steamuser" && cmd_need_steamuser; then
|
elif function_exists "cmd_need_steamuser" && cmd_need_steamuser; then
|
||||||
run_as_steamuser "$ScriptFullname" "$Group" "$Command" "$@"
|
run_as_steamuser "${ScriptFullname}${KF2POSTFIX}" "$Group" "$Command" "$@"
|
||||||
else
|
else
|
||||||
cmd_main "$@"
|
cmd_main "$@"
|
||||||
fi
|
fi
|
||||||
|
@ -19,30 +19,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
function run_as_steamuser () # $@: command
|
|
||||||
{
|
|
||||||
include /etc/steamcmd/steamcmd.conf
|
|
||||||
|
|
||||||
if [[ "$USER" == "$SteamUser" ]]; then
|
|
||||||
"$@"
|
|
||||||
elif [[ -n $(groups "$USER" | grep -Fo 'wheel') ]] || [[ "$EUID" -eq 0 ]]; then
|
|
||||||
sudo -u "$SteamUser" "$@"
|
|
||||||
else
|
|
||||||
echo "You must be a $SteamUser, root or sudo-user to run this command."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function run_as_root () # $@: command
|
|
||||||
{
|
|
||||||
if [[ "$EUID" -eq 0 ]]; then
|
|
||||||
"$@"
|
|
||||||
elif [[ -n $(groups "$USER" | grep -Fo 'wheel') ]]; then
|
|
||||||
sudo "$@"
|
|
||||||
else
|
|
||||||
echo "You must be root or sudo-user to run this command."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
InstallDir=":DEFINE_PREFIX:/games/kf2-srv${KF2POSTFIX}"
|
InstallDir=":DEFINE_PREFIX:/games/kf2-srv${KF2POSTFIX}"
|
||||||
AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64"
|
AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user