diff --git a/set_firefox_config.sh b/set_firefox_config.sh old mode 100644 new mode 100755 index e03f296..8579138 --- a/set_firefox_config.sh +++ b/set_firefox_config.sh @@ -1,9 +1,6 @@ #!/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..." @@ -11,12 +8,57 @@ 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 + $snp remove --purge firefox + + # estamos en ubuntu, 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 - if DIRECTORIO=$(dirname $(find $HOME -name profiles.ini)) ; then + # 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-) @@ -38,6 +80,9 @@ set_firefox_config () { } # 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}') @@ -53,3 +98,7 @@ while read line; do 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