Icy Phoenix

     
 


Post new topic  Reply to topic 
Page 1 of 1
 
 
Reply with quote Download Post 
Post Automated CHMOD Script 
 
As I tend to install phpBBXS from scratch quite a bit, I have a simple linux shell script for chmodding all the files and directories, which would otherwise be extremely tedius.

Pretty much as you'd expect, it goes like this:
Code: [Download] [Hide] [Select]
# xschmod
# Script to chmod the phpBBXS files
# Script must be executed from within the root directory
# of phpBBXS
#

chmod 777 ./album_mod/upload
chmod 777 ./album_mod/upload/cache
chmod 777 ./album_mod/upload/med_cache
chmod 777 ./album_mod/upload/wm_cache
chmod 777 ./cache
chmod 777 ./ctracker/logfiles/logfile_attempt_counter.txt
chmod 777 ./ctracker/logfiles/logfile_blocklist.txt
chmod 777 ./ctracker/logfiles/logfile_malformed_logins.txt
chmod 777 ./ctracker/logfiles/logfile_spammer.txt
chmod 777 ./ctracker/logfiles/logfile_worms.txt
chmod 777 ./files
chmod 777 ./files/thumbs
chmod 777 ./images/avatars
chmod 777 ./pafiledb/uploads
chmod 777 ./pafiledb/cache
chmod 777 ./pafiledb/cache/templates
chmod 777 ./pafiledb/cache/templates/ca_aphrodite

chmod 666 ./includes/def_themes.php
chmod 666 ./includes/def_tree.php
chmod 666 ./includes/def_words.php


Using your favorite editor, put this in a file. mine is labelled xschmod. Place it in your newly extracted phpBBXS directory, make sure you give it execute permissions... e.g. chmod 755 xschmod. Then run it with ./xschmod. Voila, everything will have the right premissions in an instant.

Thought... why not modify the install scripts to create these files/directories with the right permissions?
 



 
Last edited by moreteavicar on Tue 07 Nov, 2006 16:03; edited 1 time in total 
moreteavicarSend private message  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Reply with quote Download Post 
Post Re: Simple chmod script for Linux shell users 
 
And if you don't have access to a linux shell, then why not do it in php! Just run this following script, to which I've added verbose capabilities.

Code: [Download] [Hide] [Select]
<?php
// xschmod.php
// Time saver script to chmod the phpBBXS files
// Script must be executed from within the root directory
// of phpBBXS
// May require safemode=off

$path_name[1] ='./album_mod/upload';
$path_name[2] ='./album_mod/upload/cache';
$path_name[3] ='./album_mod/upload/med_cache';
$path_name[4] ='./album_mod/upload/wm_cache';
$path_name[5] ='./cache';
$path_name[6] ='./ctracker/logfiles/logfile_attempt_counter.txt';
$path_name[7] ='./ctracker/logfiles/logfile_blocklist.txt';
$path_name[8] ='./ctracker/logfiles/logfile_malformed_logins.txt';
$path_name[9] ='./ctracker/logfiles/logfile_spammer.txt';
$path_name[10] ='./ctracker/logfiles/logfile_worms.txt';
$path_name[11] ='./files';
$path_name[12] ='./files/thumbs';
$path_name[13] ='./images/avatars';
$path_name[14] ='./pafiledb/uploads';
$path_name[15] ='./pafiledb/cache';
$path_name[16] ='./pafiledb/cache/templates';
$path_name[17] ='./pafiledb/cache/templates/ca_aphrodite';
$path_name[18] ='./includes/def_themes.php';
$path_name[19] ='./includes/def_tree.php';
$path_name[20] ='./includes/def_words.php';


for ( $i = 1; $i <=17; $i++)
if (!chmod ($path_name[$i], 0777))
{
echo "unable to change permission of ($path_name[$i]) <br />";
}
else
{
echo "successfully chmodded ($path_name[$i]) <br />";
}

for ( $i = 18; $i <=20; $i++)
if (!chmod ($path_name[$i], 0666))
{
echo "unable to change permission of ($path_name[$i]) <br />";
}
else
{
echo "successfully chmodded ($path_name[$i]) <br />";
}

?>


I've called it xschmod.php, although you can call it whatever you like. Run it from your newly created phpBBXS directory. NB, this may not work if you have safe mode enabled. There is a work around, using ftp_chmod protocol, but as I don't have this problem, I won't bother just yet
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple Chmod Script For Linux Shell Users 
 
Thanks,
I like things that make life a bit easier.
It's also great to see some thought going into easier ways to install phpBBXS.
Compliments to you for sharing your idea...  
 



 
Matt-SavageSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple chmod script for Linux shell users 
 
How can you read my To Do List?

This was on my To Do List... but now that you did it, I can delete this task...

Thanks!
 




____________
Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
 
Mighty GorgonSend private messageSend e-mail to userVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple chmod script for Linux shell users 
 
I think we both suffer from multiple installing!

If you're thinking of adding it into the install script, I was thinking about adding some logic to use the ftp_chmod protocol if the standard php chmod returns false (added to that, might be worth checking the file/folder exists before resorting to ftp). However, that would then require another screen prompt for users to input their ftp host, username and password. Although in all, it might not sound much quicker than a user doing it manually, it is a way of avoiding those common chmod installation errors as experienced by the average newcomer!
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
I've rewritten it a bit for the new project... this is for XS plus CT5.

Code: [Download] [Hide] [Select]
<?php
// chmod_xs.php
// Time saver script to chmod the phpBBXS files
// Script must be executed from within the root directory of phpBBXS
// May require safemode = off

$chmod_777 = array();
$chmod_777[] ='./album_mod/upload';
$chmod_777[] ='./album_mod/upload/cache';
$chmod_777[] ='./album_mod/upload/med_cache';
$chmod_777[] ='./album_mod/upload/wm_cache';
$chmod_777[] ='./cache';
$chmod_777[] ='./ctracker/logfiles/logfile_attempt_counter.txt';
$chmod_777[] ='./ctracker/logfiles/logfile_blocklist.txt';
$chmod_777[] ='./ctracker/logfiles/logfile_debug_mode.txt';
$chmod_777[] ='./ctracker/logfiles/logfile_malformed_logins.txt';
$chmod_777[] ='./ctracker/logfiles/logfile_spammer.txt';
$chmod_777[] ='./ctracker/logfiles/logfile_worms.txt';
$chmod_777[] ='./files';
$chmod_777[] ='./files/thumbs';
$chmod_777[] ='./images/avatars';
$chmod_777[] ='./pafiledb/uploads';
$chmod_777[] ='./pafiledb/cache';
$chmod_777[] ='./pafiledb/cache/templates';
$chmod_777[] ='./pafiledb/cache/templates/ca_aphrodite';

$chmod_666 = array();
$chmod_666[] ='./includes/def_themes.php';
$chmod_666[] ='./includes/def_tree.php';
$chmod_666[] ='./includes/def_words.php';


for (
$i = 0; $i < count($chmod_777); $i++ )
{
    if (!
chmod ($chmod_777[$i], 0777))
    {
        echo
'<font color="#DD3333"><b>Unable to change permission of (' . $chmod_777[$i] . ')</b></font><br />';
    }
    else
    {
        echo
'<font color="#228844"><b>Successfully chmodded (' . $chmod_777[$i] . ')</b></font><br />';
    }
}

for (
$i = 0; $i < count($chmod_666); $i++ )
{
    if (!
chmod ($chmod_666[$i], 0666))
    {
        echo
'<font color="#DD3333"><b>Unable to change permission of (' . $chmod_666[$i] . ')</b></font><br />';
    }
    else
    {
        echo
'<font color="#228844"><b>Successfully chmodded (' . $chmod_666[$i] . ')</b></font><br />';
    }
}

?>


moreteavicar wrote: [View Post]
I think we both suffer from multiple installing!

Yes... of course!

moreteavicar wrote: [View Post]
If you're thinking of adding it into the install script, I was thinking about adding some logic to use the ftp_chmod protocol if the standard php chmod returns false (added to that, might be worth checking the file/folder exists before resorting to ftp). However, that would then require another screen prompt for users to input their ftp host, username and password. Although in all, it might not sound much quicker than a user doing it manually, it is a way of avoiding those common chmod installation errors as experienced by the average newcomer!

Regarding this I have to think about it... I don't know how to implement it... if you have some ideas, please go working on it!
 




____________
Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
 
Mighty GorgonSend private messageSend e-mail to userVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
i think that is better an installer like joomla installer
 




____________
jack of all trades, master of none
http://www.mieloma.com/ - http://www.casimedicos.com/ - http://www.egalego.com/ - http://www.casimedicos.com.es/ - http://www.medicosmir.com/
 
casimedicosSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
Sorry casimedicos, I don't understand. Do you mean to make an installer like the joomla installer? What is it you like about the joomla installer?
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
@MG I like the colour scheme  
I just noticed that there is one small problem with the array assignment (partly my fault for using direct assignments) - the for loops should now start from 0 not 1.

Anyway, for a little fun, I have just re-built this script to include ftp capabilities... From doing some reading, it appears that php 4 doesn't support chmod through php anyway, so this new routine checks for this, then decides on appropriate method. If ftp is chosen, it checks if ftp_chmod exists, because not all servers have this enabled. If not, it creates the ftp_chmod function using SITE command. The input form is checked at every stage of ftp (first for connection, then for login) if along the way there is a fault, the user is prompted to check/enter the correct details.. and at any time they can cancel the ftp system and the file list is given so they can do it manually.

File attached as its too big to post here now! To test the ftp section (if you have php chmod on your server), simply change this line
Code: [Download] [Hide] [Select]
if (!function_exists('chmod'))
on line 105 to
Code: [Download] [Hide] [Select]
if (function_exists('chmod'))
. It would be nice to see how other people find the ftp compatibility, because I have a feeling some servers act differently, for example on my server, I found the path had to relative to /public_html/, so it has been set up for that. However, some might find it is /home/public_html/ (I hope not but....)

The way this has been coded, it isn't dependent on its filename, so you can copy and paste it to the end of the install script if you wanted to.

**Attachment removed, as it has been updated**
 



 
Last edited by moreteavicar on Tue 07 Nov, 2006 16:05; edited 1 time in total 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
Just did a quick try of integrating with install script. After changing the path setup to account for root/install/, cracker tracker blocks it!
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
casimedicos wrote: [View Post]
i think that is better an installer like joomla installer

Don't worry, I have rewritten the install procedure... you will like the new one.

moreteavicar, I'll test what you did.

Thank you.
 




____________
Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
 
Mighty GorgonSend private messageSend e-mail to userVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Simple CHMOD Script For Linux Shell Users 
 
ok, thanks
 




____________
jack of all trades, master of none
http://www.mieloma.com/ - http://www.casimedicos.com/ - http://www.egalego.com/ - http://www.casimedicos.com.es/ - http://www.medicosmir.com/
 
casimedicosSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Updated chmod script 
 
moreteavicar wrote: [View Post]
The way this has been coded, it isn't dependent on its filename, so you can copy and paste it to the end of the install script if you wanted to.


Sorry, forgot to say this isn't completely true. When in the install directory, you have to unccoment some of the lines at the top:
Code: [Download] [Hide] [Select]
$str = dirname($_SERVER["PHP_SELF"]);  //gets the root directory of install
$arr = split('/', $str);
$num = count($arr);
$num = $num - 2;
$current_dir = $arr[$num];


And change all '.' to '..' in the bottom of the file.

However, instead of anyone needing to do that, I've changed the script to even fully automate that part...

So, to recap, it will run in root or install directory (or install_old if you rename it to that). You can call the root directory what you like, it will find the name of that directory (an important point since the ftp routine has to be called with respect to public_html).

And to use ftp only, change the line to $use_ftp=1; at the top of the file.

xschmod.zip
Description: An even more automated chmod script 
Download
Filename: xschmod.zip
Filesize: 2.67 KB
Downloaded: 615 Time(s)

 



 
moreteavicarSend private message  
Back to topPage bottom
Post new topic  Reply to topic  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events


  

 

  cron