https://www.icyphoenix.com/viewtopic.php?f=30&t=477 ----------------------------------- moreteavicar Tue 10 Oct, 2006 01:51 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: [codeblock] # 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[/codeblock] 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? ----------------------------------- moreteavicar Tue 10 Oct, 2006 02:43 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. [codeblock] "; } else { echo "successfully chmodded ($path_name[$i])
"; } for ( $i = 18; $i <=20; $i++) if (!chmod ($path_name[$i], 0666)) { echo "unable to change permission of ($path_name[$i])
"; } else { echo "successfully chmodded ($path_name[$i])
"; } ?>[/codeblock] 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 ;) ----------------------------------- Matt-Savage Tue 10 Oct, 2006 09:38 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... :loveit: ----------------------------------- Mighty Gorgon Mon 16 Oct, 2006 01:18 Re: Simple chmod script for Linux shell users ----------------------------------- How can you read my To Do List? :lol: This was on my To Do List... but now that you did it, I can delete this task... :lol: Thanks! ----------------------------------- moreteavicar Tue 17 Oct, 2006 00:47 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! ----------------------------------- Mighty Gorgon Tue 24 Oct, 2006 22:02 Re: Simple CHMOD Script For Linux Shell Users ----------------------------------- I've rewritten it a bit for the new project... this is for XS plus CT5. :wink: [codeblock syntax=php]Unable to change permission of (' . $chmod_777[$i] . ')
'; } else { echo 'Successfully chmodded (' . $chmod_777[$i] . ')
'; } } for ( $i = 0; $i < count($chmod_666); $i++ ) { if (!chmod ($chmod_666[$i], 0666)) { echo 'Unable to change permission of (' . $chmod_666[$i] . ')
'; } else { echo 'Successfully chmodded (' . $chmod_666[$i] . ')
'; } } ?>[/codeblock] [quote user="moreteavicar" post="3889"]I think we both suffer from multiple installing! [/quote] Yes... of course! :mrb: [quote user="moreteavicar" post="3889"]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![/quote] 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! :lol: ----------------------------------- casimedicos Wed 25 Oct, 2006 20:17 Re: Simple CHMOD Script For Linux Shell Users ----------------------------------- i think that is better an installer like joomla installer ----------------------------------- moreteavicar Thu 26 Oct, 2006 12:34 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? ----------------------------------- moreteavicar Tue 31 Oct, 2006 03:45 Re: Simple CHMOD Script For Linux Shell Users ----------------------------------- @MG I like the colour scheme :mrgreen: 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 [codeblock]if (!function_exists('chmod'))[/codeblock] on line 105 to [codeblock]if (function_exists('chmod'))[/codeblock]. 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** ----------------------------------- moreteavicar Tue 31 Oct, 2006 22:18 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! :roll: ----------------------------------- Mighty Gorgon Sat 04 Nov, 2006 00:28 Re: Simple CHMOD Script For Linux Shell Users ----------------------------------- [quote user="casimedicos" post="4116"]i think that is better an installer like joomla installer[/quote] Don't worry, I have rewritten the install procedure... you will like the new one. :wink: [b]moreteavicar[/b], I'll test what you did. Thank you. ----------------------------------- casimedicos Tue 07 Nov, 2006 13:43 Re: Simple CHMOD Script For Linux Shell Users ----------------------------------- ok, thanks ----------------------------------- moreteavicar Tue 07 Nov, 2006 16:01 Updated chmod script ----------------------------------- [quote user="moreteavicar" post="4311"]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.[/quote] 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: [codeblock]$str = dirname($_SERVER["PHP_SELF"]); //gets the root directory of install $arr = split('/', $str); $num = count($arr); $num = $num - 2; $current_dir = $arr[$num]; [/codeblock] 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.