mirror of
https://github.com/sameersbn/docker-browser-box
synced 2024-11-01 09:20:21 +00:00
56 lines
1.4 KiB
Bash
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
|