Skip to content

Disallow root script run #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions dochat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ set -eo pipefail
# 2020-04-01: 2.7.1.85
# 2020-08-24: 3.3.0.115 (not working yet)
# 2020-09-01: 3.3.0.115 (alpha testing)

if [ "$EUID" -eq 0 ] && [ "${ALLOWROOT:-0}" -ne "1" ]
then
echo "Please do not run this script as root."
echo "see https://github.com/huan/docker-wechat/pull/209"
exit 1
fi

DEFAULT_WECHAT_VERSION=3.3.0.115

#
Expand Down Expand Up @@ -79,7 +87,7 @@ function main () {
for DEVICE in /dev/video* /dev/snd; do
DEVICE_ARG+=('--device' "$DEVICE")
done
if [[ $(lshw -C display | grep vendor) =~ NVIDIA ]]; then
if [[ $(lshw -C display 2> /dev/null | grep vendor) =~ NVIDIA ]]; then
DEVICE_ARG+=('--gpus' 'all' '--env' 'NVIDIA_DRIVER_CAPABILITIES=all')
fi

Expand Down Expand Up @@ -121,7 +129,12 @@ function main () {
\
"$DOCHAT_IMAGE_VERSION"

echo
#
# Do not put any command between
# the above "docker run" and
# the below "echo"
# because we need to output error code $?
#
echo "📦 DoChat Exited with code [$?]"
echo
echo '🐞 Bug Report: https://github.com/huan/docker-wechat/issues'
Expand Down