View previous topic :: View next topic |
Author |
Message |
muhsinzubeir l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/gallery/Terminator/movie_the_terminator_machine.gif)
Joined: 29 Sep 2007 Posts: 948 Location: /home/muhsin
|
Posted: Sun Aug 03, 2008 1:07 pm Post subject: copying directory permissions{resolved} |
|
|
Introduction:
I have a directory hosting my webpage, but I am not a security expert so i really want to maintain all permissions the way they are in there.But this means a user is not allowed to edit files in it.So I decided i will create the same directory on my home with all access, edit the website(multi-page) and then update the directory on my server.This becomes tedious so i wanted to write a script(but im limited as im not fluent in bash-programming)...but i thought should be fine as its a simple program:
Code: | #!/bin/bash
#we have 3 directories, latest(with user permissions full access to rwx), apache(some server permissions) apache.ackup(maintain server permissions)
cp -rv /home/user/apache /home/user/apache.backup #create backup, permissions maintained here in the backup directory
#chmod of the /home/user/latest to match my server directory /home/user/apache before uploading/copy new directory
cp -rv /home/user/latest /home/user/apache
#chmod of the /home/user/latest to 777 to allower user to use GUI editors target kate
chmod -R 777 /home/user/latest |
So thats the script, but im stuck on changing (latest) permissions to (apache) permissions.How would one accomplish this?Hopefully its not a lot of bash
thanks _________________ ~x86
p5k-se
Intel Core 2 Duo
Nvidia GT200
http://www.zanbytes.com
Last edited by muhsinzubeir on Sat Aug 16, 2008 8:34 pm; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
notHerbert Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/164163717447df0b64d6b53.png)
Joined: 11 Mar 2008 Posts: 2228 Location: 45N 73W
|
Posted: Sun Aug 03, 2008 3:26 pm Post subject: |
|
|
Code: | man cp
...
...
-p same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,time-
stamps), if possible additional attributes: context, links, all
|
Is this what you're looking for? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
muhsinzubeir l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/gallery/Terminator/movie_the_terminator_machine.gif)
Joined: 29 Sep 2007 Posts: 948 Location: /home/muhsin
|
Posted: Sun Aug 03, 2008 3:41 pm Post subject: |
|
|
i want to copy only the permissions (excluding files) en apply them to another directory....before i replace them.But im not sure if the whole idea is possible...
Edit:
If no good idea then its probably bad programming practices/idea, ill have to use files instead of directories.That way I think ill make it, in much easier way. _________________ ~x86
p5k-se
Intel Core 2 Duo
Nvidia GT200
http://www.zanbytes.com
Last edited by muhsinzubeir on Sun Aug 03, 2008 8:01 pm; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
muhsinzubeir l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/gallery/Terminator/movie_the_terminator_machine.gif)
Joined: 29 Sep 2007 Posts: 948 Location: /home/muhsin
|
Posted: Sun Aug 03, 2008 7:58 pm Post subject: |
|
|
Code: | #!/bin/bash
#simple script to update my server from newly edited files.
#uncomment the restore part during nightmares.
#backup of the htdocs
cd /var/www/muhsinzubeir.homeftp.net
tar -cvjf /home/muhsin/htdocs.tar.gz htdocs/
#copy latest files over the server
cp -rv /home/muhsin/home_page/* /var/www/muhsinzubeir.homeftp.net/htdocs/
|
Code: |
#restore from backup during nightmares
#remove messed folder
rm -rv /var/www/muhsinzubeir.homeftp.net/htdocs/
#move to the server locations && restore the backup
cd /var/www/muhsinzubeir.homeftp.net/
tar -xvf /home/muhsin/htdocs.tar.gz |
Thats what i came up with ...if u have any better idea pls let me know.
P:S
Pls dont use any info against me
Edit:
Any cool idea for instance to make that backup part like not to overwrite the existing tarbal instead give it number...like log file stuffs?
to fix overwritting stuffs:
Code: | tar -cvjf tar -cvjf /home/muhsin/htdocs-`date '+%d-%B-%Y'`.tar.gz htdocs/ |
_________________ ~x86
p5k-se
Intel Core 2 Duo
Nvidia GT200
http://www.zanbytes.com |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|