In italian:
Quante volte vi sarà capitato, dopo un installazione di un nuovo kernel,driver della scheda video,aggiornamento di gnome,fork bomb,pannolini, ecc. di dover riavviare il pc?
Quante volte siete stati costretti a reinserire utente e password al gdm, nonostante VOI avete ordinato il riavvio, e VOI siete ancora davanti allo schermo?Non è una cosa brutta,irritante,sconsiderata,pedante e simpatetica?Da oggi, con solo 100 dollari,esiste “AutomaticLogin Deluxe Edition”!! -_-’ ….non è vero.
Ho scritto questo script, che non fa altro che modificare il file di configurazione del gdm, e attivarne il login automatico per l’utente “$utente” specificato all inizio dello script.Avendo inserito una voce in /etc/rc.local , al riavvio, il login normale con utente e password verrà ristabilito. Andiamoci a creare uno script chiamato automaticLogin
sudo gedit /usr/local/bin/automaticLogin
in cui inserite, le seguenti righe:
#!/bin/bash
#Script che permette il login automatico solo al prossimo riavvio.
#L'utente viene specificato nella variabile che segue
nomeutente="piero";
if [ $# == 0 ] ; then
if ! grep $nomeutente /etc/gdm/gdm.conf >> /dev/null ; then
cat /etc/gdm/gdm.conf | sed -e "s:AutomaticLoginEnable=false:AutomaticLoginEnable=true:g" | sed -e "s:AutomaticLogin=:AutomaticLogin=$nomeutente:g" >> /tmp/gdm.conf.temp
mv /tmp/gdm.conf.temp /etc/gdm/gdm.conf
chmod 644 /etc/gdm/gdm.conf
chown root:root /etc/gdm/gdm.conf
fi
if ! grep loginAutomatico /etc/rc.local >> /dev/null ;then
cat /etc/rc.local | sed -e "s:exit 0:/usr/local/bin/loginAutomatico elimina:g" >> /tmp/rc.local.temp
echo "exit 0" >> /tmp/rc.local.temp
mv /tmp/rc.local.temp /etc/rc.local
chmod 755 /etc/rc.local
chown root:root /etc/rc.local
reboot
fi
else if [ $1 == "elimina" ] ; then
cat /etc/gdm/gdm.conf | sed -e "s:AutomaticLoginEnable=true:AutomaticLoginEnable=false:g" | sed -e "s:AutomaticLogin=$nomeutente:AutomaticLogin=:g" >> /tmp/gdm.conf.temp
mv /tmp/gdm.conf.temp /etc/gdm/gdm.conf
chmod 644 /etc/gdm/gdm.conf
chown root:root /etc/gdm/gdm.conf
cat /etc/rc.local | sed -e "s:/usr/local/bin/loginAutomatico elimina::g" > /tmp/rc.local.temp
mv /tmp/rc.local.temp /etc/rc.local
chmod 755 /etc/rc.local
chown root:root /etc/rc.local
else
echo "comando non conosciuto"
exit 1
fi
fi
exit 0
Modificate il valore della variabile “$nomeutente” , mettendo il vostro.
adesso diamo il permesso di esecuzione allo script,e l appartenenza all’utente root:
sudo chmod +x /usr/local/bin/automaticLogin
sudo chown root:root /usr/local/bin/automaticLogin
Adesso salvate tutti i documenti non salvati, e proviamo a dare dal terminale:
fatto!
In English
How many times It would happen, after a kernel,video driver installation,gnome upgrade,fork bomb,diapers, etc. to reboot your pc?
How many times you’re been forced to re-enter username and password even if YOU rebooted, and YOU are in front of pc yet?It’s a bad, annoying,dull operation, isn’t it?
Today, with only 100 dollars, there is “AutomaticLogin Deluxe Edition”!!! -_-’ that’s not true.
I wrote this scrip, that does nothing more that modify gdm configuration file, and activate the automatic login for user “$username”, specified at the beginning of the script.
Will be inserted a command in /etc/rc.local file too, so that for next boot, the “login&password” login will be restored.
Let’s create a script named automaticLogin
sudo gedit /usr/local/bin/automaticLogin
With the following code:
#!/bin/bash
#Script that enable automatic login, only for next boot.
#The username is specified in the var below
username="piero";
if [ $# == 0 ] ; then
if ! grep $username /etc/gdm/gdm.conf >> /dev/null ; then
cat /etc/gdm/gdm.conf | sed -e "s:AutomaticLoginEnable=false:AutomaticLoginEnable=true:g" | sed -e "s:AutomaticLogin=:AutomaticLogin=$username:g" >> /tmp/gdm.conf.temp
mv /tmp/gdm.conf.temp /etc/gdm/gdm.conf
chmod 644 /etc/gdm/gdm.conf
chown root:root /etc/gdm/gdm.conf
fi
if ! grep loginAutomatico /etc/rc.local >> /dev/null ;then
cat /etc/rc.local | sed -e "s:exit 0:/usr/local/bin/loginAutomatico elimina:g" >> /tmp/rc.local.temp
echo "exit 0" >> /tmp/rc.local.temp
mv /tmp/rc.local.temp /etc/rc.local
chmod 755 /etc/rc.local
chown root:root /etc/rc.local
reboot
fi
else if [ $1 == "delete" ] ; then
cat /etc/gdm/gdm.conf | sed -e "s:AutomaticLoginEnable=true:AutomaticLoginEnable=false:g" | sed -e "s:AutomaticLogin=$username:AutomaticLogin=:g" >> /tmp/gdm.conf.temp
mv /tmp/gdm.conf.temp /etc/gdm/gdm.conf
chmod 644 /etc/gdm/gdm.conf
chown root:root /etc/gdm/gdm.conf
cat /etc/rc.local | sed -e "s:/usr/local/bin/loginAutomatico delete::g" > /tmp/rc.local.temp
mv /tmp/rc.local.temp /etc/rc.local
chmod 755 /etc/rc.local
chown root:root /etc/rc.local
else
echo "command not found"
exit 1
fi
fi
exit 0
Now go to modify the value of “$username” var, putting yours.
Now let’s give execution permission to the script, and root membership:
sudo chmod +x /usr/local/bin/automaticLogin
sudo chown root:root /usr/local/bin/automaticLogin
Now let’s save all document’s, and type in a terminal:
done!!