gists/set_firefox_config.sh
2024-11-07 16:39:53 +01:00

56 lines
1.8 KiB
Bash

#!/bin/bash
set -e
# Script para buscar usuarios que non sexan de sistema
# e configurarlles o firefox coas opciós de arkenfox
# Repo coa configuración
echo "Baixando configuración..."
rm -rf /tmp/user_js > /dev/null 2>&1
git clone https://github.com/arkenfox/user.js.git /tmp/user_js
echo ""
# Configura Firefox
set_firefox_config () {
USER=$1
HOME=$2
if DIRECTORIO=$(dirname $(find $HOME -name profiles.ini)) ; then
# Buscando directorio do perfil
if [[ $(grep '\[Profile[^0]\]' $DIRECTORIO/profiles.ini) ]]; then
PROFPATH=$(grep -E '^\[Profile|^Path|^Default' $DIRECTORIO/profiles.ini | grep -1 '^Default=1' | grep '^Path' | cut -c6-)
else
PROFPATH=$(grep 'Path=' $DIRECTORIO/profiles.ini | sed 's/^Path=//')
fi
PROFILE_DIR=$DIRECTORIO/$PROFPATH
# Xa temos o directorio, copiase a config
cp /tmp/user_js/prefsCleaner.sh $PROFILE_DIR
cp /tmp/user_js/updater.sh $PROFILE_DIR
cp /tmp/user_js/user.js $PROFILE_DIR
wget --quiet https://codeberg.org/Liassica/user-overrides/raw/branch/main/user-overrides/no-suggestions-no-password/user-overrides.js -P $PROFILE_DIR
echo "Firefox do usuario $USER configurado."
else
echo "Non se encontra o directorio do Firefox."
fi
}
# RUN
uid_min=$(grep -E '^UID_MIN' /etc/login.defs | awk '{print $2}')
uid_max=$(grep -E '^UID_MAX' /etc/login.defs | awk '{print $2}')
echo "Buscando usuarios con UID entre $uid_min e $uid_max..."
while read line; do
IFS=':' read -r usuario uid home <<< "$(echo $line | cut -d\: -f1,3,6)"
if [ $uid -ge $uid_min ] && [ $uid -le $uid_max ]; then
echo "Atopado $usuario con UID $uid en $home"
echo "Configurando Firefox..."
set_firefox_config $usuario $home
fi
done < /etc/passwd