Configurar CentOS 7 en modo kiosko con Chromium

#
# CONFIGURATION
#

user=kiosk
group=kiosk
home=/home/$user

#
# MAIN CODE
#

# Creación del usuario del modo Kiosko

useradd $user

# Instalación de los paquetes necesarios

yum -y install epel-release
yum -y install rsync
yum -y install matchbox-window-manager
yum -y groupinstall x11 fonts

# Configuración de AutoLogin

autologin=$( cat /etc/gdm/custom.conf | grep AutomaticLoginEnable=true )
loginname=$( cat /etc/gdm/custom.conf | grep AutomaticLogin=$user )
[ ! -n "$autologin" ] && sed -i "/daemon]/aAutomaticLoginEnable=true" /etc/gdm/custom.conf
[ ! -n "$loginname" ] && sed -i "/AutomaticLoginEnable=true/aAutomaticLogin=$user" /etc/gdm/custom.conf
[ ! -n "$loginname" ] && sed -i "/AutomaticLogin=$user/aDefaultSession=xinit-compat.desktop" /etc/gdm/custom.conf

# Configuración de Chromium

browser=$( /etc/chromium/master_preferences | grep "\"browser\"" )
[ ! -n "$browser" ] && sed -i '0,/{/ s/{/{\n  "browser":{"custom_chrome_frame":false},/' /etc/chromium/master_preferences

echo "{\"AllowFileSelectionDialogs\":false,\"PasswordManagerEnabled\":false,\"BookmarkBarEnabled\":false}" /etc/chromium/policies/managed/kiosk-mode.json
chmod 644 /etc/chromium/policies/managed/kiosk-mode.json

# Configuración del usuario para X11

touch /var/lib/AccountsService/users/$user
chmod 644 /var/lib/AccountsService/users/$user
echo "[User]" > /var/lib/AccountsService/users/$user
echo "Language=$LANG" >> /var/lib/AccountsService/users/$user
echo "XSession=xinit-compat" >> /var/lib/AccountsService/users/$user
echo "SystemAccount=false" >> /var/lib/AccountsService/users/$user

cat <<- 'EOF' > $home/.xsession
homepage=https://www.google.com
xset s off
xset s noblank
xset -dpms
matchbox-window-manager &
sleep 5
while true; do
  pkill -9 chromium
  rsync -qr --delete --exclude='.Xauthority' /opt/kiosk/ /home/kiosk/
  chromium-browser --no-first-run --disable --disable-infobars --disable-extensions --proxy-auto-detect --homepage=$homepage --kiosk $homepage
done
EOF

chmod +x $home/.xsession
ln -s $home/.xsession $home/.xinitrc
chown $user:$group $home/.xsession

echo "[Desktop]" > $home/.dmrc
echo "Session=xinit-compat" >> $home/.dmrc
echo "Language=$LANG" >> $home/.dmrc
chown $user:$group $home/.dmrc

cp -r $home /opt/
chmod 755 /opt/$user
chown $user:$group -R /opt/$user

# Configuración de X11

echo 'Section "Serverflags"' > /etc/X11/xorg.conf.d/kiosk-mode.conf
echo 'Option "DontVTSwitch" "yes"' >> /etc/X11/xorg.conf.d/kiosk-mode.conf
echo 'EndSection' >> /etc/X11/xorg.conf.d/kiosk-mode.conf

# Configuraciones varias

systemctl set-default graphical.target
echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot

# Tareas manuales

echo "Ejecutar [grub2-setpassword] para proteger la modificación de GRUB 2 por parte de los usuarios"
echo "Modificar /usr/lib64/chromium/chromium-browser.sh, antes de lanzar el binario:"
echo "if [ ! -f ~/.config/chromium/Default/Preferences ]; then cp /etc/chromium/master_preferences ~/.config/chromium/Default/Preferences; fi"

 

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *