You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docker-browser-box/entrypoint.sh

69 lines
1.9 KiB
Bash

10 years ago
#!/bin/bash
set -e
case "$1" in
install)
echo "Installing browser-box..."
install -m 0755 /scripts/browser-box /target/
10 years ago
echo "Installing google-chrome..."
ln -sf browser-box /target/google-chrome
10 years ago
echo "Installing google-chrome-stable..."
ln -sf browser-box /target/google-chrome-stable
10 years ago
echo "Installing tor-browser..."
ln -sf browser-box /target/tor-browser
echo "Installing chromium-browser..."
ln -sf browser-box /target/chromium-browser
echo "Installing firefox..."
ln -sf browser-box /target/firefox
10 years ago
;;
uninstall)
echo "Uninstalling browser-box..."
rm -rf /target/browser-box
10 years ago
echo "Uninstalling google-chrome..."
rm -rf /target/google-chrome
echo "Uninstalling google-chrome-stable..."
rm -rf /target/google-chrome-stable
echo "Uninstalling tor-browser..."
rm -rf /target/tor-browser
echo "Uninstalling chromium-browser..."
rm -rf /target/chromium-browser
echo "Uninstalling firefox..."
rm -rf /target/firefox
10 years ago
;;
bash)
exec $@
;;
*)
10 years ago
# uid and gid of host user
USER_UID=${USER_UID:-1000}
USER_GID=${USER_GID:-1000}
# create user group
if ! getent group ${WEB_BROWSER_USER} >/dev/null; then
groupadd -f -g ${USER_GID} ${WEB_BROWSER_USER}
fi
10 years ago
# create user with uid and gid matching that of the host user
if ! getent passwd ${WEB_BROWSER_USER} >/dev/null; then
adduser --disabled-login --uid ${USER_UID} --gid ${USER_GID} \
--gecos 'Browser Box' ${WEB_BROWSER_USER}
fi
10 years ago
# grant access to video devices
for device in /dev/video*
do
if [[ -c $device ]]; then
VIDEO_GID=$(stat -c %g $device)
break
fi
done
if [[ -n $VIDEO_GID ]]; then
usermod -a -G $VIDEO_GID ${WEB_BROWSER_USER}
fi
cd /home/${WEB_BROWSER_USER}
exec sudo -u ${WEB_BROWSER_USER} -H PULSE_SERVER=/run/pulse/native $@ ${extra_opts}
10 years ago
;;
esac