[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] PostSession script, rm command and user directories



Having occasionally run into problems with scripts that cd to a directory and then do something, but which create havoc when the cd part fails and so the next step fires off in the wrong directory, I like to specify the full path where the work should be done, all in the same command. So, rather than cd and then tar, I'd suggest this:

rm -rf /home/terminal1
tar -xv /usr/BACKUP/terminal1.tar -C /home

This way, if /home were missing (which would have all sorts of other implications, but the principle is still valid), the tar won't happen and make a mess all over the root directory or elsewhere.

As for root not being able to remove the directory that the user creates, something is amiss. What happens if root manually tries to remove the /home/terminal1 directory from the command line? What are the permissions on the files and directories that the user creates?

Petre

Meelis Mihhailov wrote:
You could clean this up a little further, because it's not really
necessary to copy the tar file, extract it and then remove it.

--------------------------------------------------
rm -rf /home/terminal1
cd /home
tar -xf /usr/BACKUP/terminal1.tar
--------------------------------------------------

Nils Breunese.

Hi and thanks for the reply. This helped a bit and made the code nicer :) Thanks ! It removes all the old stuff except the ones user has made. For example saved a webpage/documents in his/her home directory. The ones on the desktop are erased ... this is a good thing :) but /home/custom_dir_name problem still remains ...




Meelis
---
meelis nlib ee
_______________________________________________
K12OSN mailing list
K12OSN redhat com
https://www.redhat.com/mailman/listinfo/k12osn
For more info see <http://www.k12os.org>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]