105 lines
3.0 KiB
Bash
Executable File
105 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script para buscar usuarios que non sexan de sistema
|
|
|
|
# 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 ""
|
|
|
|
# Asegurarse de que existe Firefox en apt e non en snap
|
|
apt_firefox () {
|
|
# existe snap?
|
|
if snp=$(which snap); then
|
|
$snp list firefox
|
|
if [ $? -eq 0 ]; then
|
|
# probablemente estamos en Ubuntu, quitase do snap
|
|
$snp remove --purge firefox
|
|
|
|
# agregase repo de mozilla
|
|
add-apt-repository -y ppa:mozillateam/ppa
|
|
|
|
if [ ! -f /etc/apt/preferences.d/mozilla-firefox ]; then
|
|
echo '
|
|
Package: *
|
|
Pin: release o=LP-PPA-mozillateam
|
|
Pin-Priority: 1001
|
|
|
|
Package: firefox
|
|
Pin: version 1:1snap*
|
|
Pin-Priority: -1
|
|
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
apt purge -y firefox
|
|
apt install -y firefox
|
|
}
|
|
|
|
# Configura Firefox
|
|
set_firefox_config () {
|
|
USER=$1
|
|
HOME=$2
|
|
|
|
# Crea o perfil por defecto:
|
|
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
|
|
sudo -i -u $USER firefox -headless -no-remote -CreateProfile default
|
|
|
|
# Busca directorio do perfil e aplica a config
|
|
DIRECTORIO=""
|
|
for ruta in $(find $HOME -name profiles.ini);
|
|
do
|
|
if [[ $ruta == *".mozilla/firefox/profiles.ini"* ]]; then
|
|
DIRECTORIO=$(dirname $ruta)
|
|
fi
|
|
done
|
|
|
|
echo $DIRECTORIO
|
|
|
|
if [ -d "$DIRECTORIO" ]; 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
|
|
|
|
apt_firefox
|
|
|
|
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
|
|
|
|
# Restaurar Firefox con snap
|
|
# add-apt-repository -y -r ppa:mozillateam/ppa
|
|
# rm -rf /etc/apt/preferences.d/mozilla-firefox
|
|
# apt remove firefox && snap install firefox
|