docker-browser-box/start
2014-11-24 13:08:26 +05:30

56 lines
1.4 KiB
Bash

#!/bin/bash
set -e
case "$1" in
install)
echo "Installing browser-box..."
install -m 0755 /scripts/browser-box /target/
echo "Installing google-chrome..."
ln -sf browser-box /target/google-chrome
echo "Installing google-chrome-stable..."
ln -sf browser-box /target/google-chrome-stable
echo "Installing tor-browser..."
ln -sf browser-box /target/tor-browser
;;
uninstall)
echo "Uninstalling browser-box..."
rm -rf /target/browser-box
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
;;
bash)
exec $@
;;
*)
# uid and gid of host user
USER_UID=${USER_UID:-1000}
USER_GID=${USER_GID:-1000}
# create user group
if ! getent group anonymous >/dev/null; then
groupadd -f -g ${USER_GID} anonymous
fi
# create user with uid and gid matching that of the host user
if ! getent passwd anonymous >/dev/null; then
adduser --disabled-login --uid ${USER_UID} --gid ${USER_GID} \
--gecos 'Anonymous' anonymous
fi
extra_opts=
case "$1" in
google-chrome|google-chrome-stable)
extra_opts="--no-sandbox"
;;
esac
# launch application as anonymous
cd /home/anonymous
exec sudo -u anonymous -H PULSE_SERVER=/run/pulse/native $@ ${extra_opts}
;;
esac