From 19f9693478aafd236942aeaabb311606e8e40757 Mon Sep 17 00:00:00 2001 From: serxoz Date: Thu, 7 Nov 2024 16:38:33 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adir=20set=5Ffirefox=5Fconfig.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configurador do Firefox coas opciós de privacidade de arkenfox. --- set_firefox_config.sh | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 set_firefox_config.sh diff --git a/set_firefox_config.sh b/set_firefox_config.sh new file mode 100644 index 0000000..96e74a0 --- /dev/null +++ b/set_firefox_config.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -e + +# 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 "" + +# 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 +