I need some help with scripts after login but before the desktop loads.
First I'll show the scripts:
Script 1
Code: Select all
#!/bin/bash
HOSTNAME=`hostname`
if [[ $HOSTNAME = "LM17-Cinnamon" ]]
then
sudo reboot
fi
if [[ $HOSTNAME = "LM17-XFCE" ]]
then
sudo reboot
fi
Code: Select all
#!/bin/bash
#Assign existing hostname to $hostn
hostn=$(cat /etc/hostname)
#Display existing hostname
echo "Existing hostname is $hostn"
#Ask for new hostname $newhost
echo "Enter new hostname: "
read newhost
#change hostname in /etc/hosts & /etc/hostname
sudo sed -i "s/$hostn/$newhost/g" /etc/hosts
sudo sed -i "s/$hostn/$newhost/g" /etc/hostname
#display new hostname
echo "Your new hostname is $newhost"
#Press a key to reboot
read -s -n 1 -p "Press any key to reboot"
sudo reboot
The situation is as follows:
1. If the hostname of the machine equals: LM17-XFCE or LM17-Cinnamon reboot the system. The script which takes care of this is placed in the folder "/etc/skel/.config/autorun"
2. To avoid this: the users has to login via tty1, since autostart doesn't activate in text mode
3. The second script is located in the /root folder. After activating this script via sudo, the hostname is changed and user can login normally.
This is quite a annoying process to do and should be easier.
What I'm searching for is this solution:
If the user logins and the hostname is still LM17-XFCE of LM17-Cinnamon, the desktop wil load but only shows a empty background (no menu's etc). It does not matter if I have to force a gui-switch (for example IF the hostname hasn't change, the users logs in with a openbox gui).
Script 2 will automatically launch
I hope I gave you guys enough info and you can help me with this problem.
Thanks in advance
P.S. Clonzilla itself has a function to change the hostname of the client. However, this only works with MS-Windows hostnames.