Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stripedpurple/45248f981ef05033d714520726da0409 to your computer and use it in GitHub Desktop.
Save stripedpurple/45248f981ef05033d714520726da0409 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check to see if the script was run as Root
if [[ "$EUID" -ne 0 ]]; then
echo "Sorry, you need to run this as root"
exit 1
fi
# This script has only been tested on Ubuntu Server 14.04 X64
# Install apt repositories
add-apt-repository 'deb http://dl.google.com/linux/chrome/deb/ stable main'
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
apt-get update
# Install required software
apt-get -y install --no-install-recommends xorg openbox google-chrome-stable
apt-get -y install xinput-calibrator unclutter x11vnc scrot feh
# configure kiosk startup script
mkdir -p /opt/bht/bin
ln -s /opt/bht/biobrain/bin/kiosk.sh /opt/bht/bin/kiosk.sh
cat <<EOF > /etc/init/kiosk.conf
start on (filesystem and stopped udevtrigger)
stop on runlevel [06]
console output
emits starting-x
respawn
exec sudo -u bht startx /etc/X11/Xsession /opt/bht/bin/kiosk.sh --
EOF
# reconfigure X
dpkg-reconfigure x11-common # set to Anybody
cp /etc/X11/xorg.conf /etc/X11/xorg.conf.orig
cat <<EOF > /etc/X11/xorg.conf
Section "Device"
Identifier "uga"
driver "fbdev"
Option "fbdev" "/opt/bht/dev/framebuffer"
# Option "ShadowFB" "off"
EndSection
Section "Monitor"
Identifier "monitor"
EndSection
Section "Screen"
Identifier "screen"
Device "uga"
Monitor "monitor"
EndSection
Section "ServerLayout"
Identifier "default"
Screen 0 "screen" 0 0
Option "Xinerama" "on"
EndSection
EOF
# Configure framebuffer detection
mkdir -p /opt/bht/dev
ln -s /dev/fb1 /opt/bht/dev/framebuffer
echo "blacklist udl" >> /etc/modprobe.d/blacklist-framebuffer.conf
sed -i 's/blacklist udlfb/# blacklist udlfb/g' /etc/modprobe.d/blacklist-framebuffer.conf
echo 'ACTION=="add",ATTRS{idVendor}=="17e9",RUN+="/opt/bht/bin/detect-display.sh"' > /etc/udev/rules.d/99-bht-display.rules
cat <<'EOF' > /opt/bht/bin/detect-display.sh
#!/bin/bash
newfb=`dmesg | grep -i udl | grep dev | grep attached | tail -1 | grep -o 'fb[0-9]'`
if [ "$newfb" != "" ]; then
rm -f /opt/bht/dev/framebuffer
ln -s /dev/$newfb /opt/bht/dev/framebuffer
stop kiosk
start kiosk
fi
EOF
chmod +x /opt/bht/bin/detect-display.sh
# Configure VNC
cat <<EOF > /etc/init/x11vnc.conf
# description "Start x11vnc at boot"
description "x11vnc"
start on runlevel [2345]
stop on runlevel [^2345]
console log
respawn
respawn limit 20 5
exec sudo -u bht /usr/bin/x11vnc -safer -allow 127.0.0.1 -loop -nopw -auth /var/lib/gdm/:0.Xauth -display :0
EOF
# install the latest biohitech-kiosk-chrome-extension
mkdir -p /opt/bht/extra/chrome/extensions/kiosk-extension
cd /opt/bht/extra/chrome/extensions/kiosk-extension
wget https://digester-admin.biohitechcloud.com/releases/kiosk-chrome-extension/latest/kiosk-chrome-extension.tgz
tar zxvf kiosk-chrome-extension.tgz
rm kiosk-chrome-extension.tgz
# download background image
mkdir -p /opt/bht/etc/openbox
cd /opt/bht/etc/openbox
wget http://static.biohitechcloud.com/biobrain/openbox/bht-background.png
# create a temporary kiosk script
mkdir -p /opt/bht/biobrain/bin
cat <<EOF > /opt/bht/biobrain/bin/kiosk.sh
#!/bin/bash
xset -dpms
xset s off
openbox-session &
/usr/bin/feh --bg-scale /opt/bht/etc/openbox/bht-background.png
/usr/bin/unclutter -idle 5.00 -root &
while true; do
/usr/bin/google-chrome %u --load-extension=/opt/bht/extra/chrome/extensions/kiosk-extension --no-first-run --incognito --start-maximized https://www.google.com
sleep 1s
done
EOF
chmod +x /opt/bht/biobrain/bin/kiosk.sh
mkdir /etc/X11/xorg.conf.d
chown -R bht:bht /opt/bht
# Run Post Install
cd /tmp
wget https://bitbucket.org/biohitechcloud/biohitech-biobrain-init/raw/master/postInstall.sh
chmod +x postInstall.sh
./postInstall.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment