Install File Auto-Remove

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Install File Auto-Remove

Post by MichaelC »

When you have finished the phpBB first installation next to login a button saying 'Delete install file' which would then remove /install/

So basiclly means the end-user does not have to go into FTP and delete /install/ themselves after installation.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Install File Auto-Remove

Post by Oleg »

Most Unix-like environments would not have permissions set allowing such button to work, I would think. Could be handy for other environments though, but in those you may be unable to remove a directory in which the file being executed is placed (you were thinking of having this functionality in installer, yes?).

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: Install File Auto-Remove

Post by naderman »

nn- wrote:Could be handy for other environments though, but in those you may be unable to remove a directory in which the file being executed is placed (you were thinking of having this functionality in installer, yes?).
Since the actual executable is either the webserver or PHP that should not be an issue.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Install File Auto-Remove

Post by Oleg »

If php either 1) does chdir into directory of script being executed, which is a very reasonable expectation considering how file-related functions work, or 2) holds script file open for reading while the script is being executed, I suspect windows will not allow you to remove the script's directory.

If so, auto-remove functionality as described would only work in a very limited number of environments.

I suggest writing a script which attempts to delete itself and the directory it's in, and running it on windows to ascertain whether this approach works.

E.g. try this code under cygwin:

Code: Select all

mkdir -p install &&
cat >install/remove.php <<EOT &&
<?php
unlink("$PWD/install/remove.php");
rmdir("$PWD/install");
EOT
php install/remove.php &&
! test -e install &&
echo Success
Edit: running php from console does not change working directory; for proper results you'll have to invoke php script via web browser.

I tested it on my machine and it works with proper permissions, which of course I will never use on a production system if I have any choice over the matter.

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Install File Auto-Remove

Post by igorw »

I think this would be a good idea, the installer should check if it can delete the folder. If that's not possible, it can ask the user for FTP/SFTP credentials or to do it manually.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Install File Auto-Remove

Post by MichaelC »

First see if it already has permissions to delete it.
If not run the

Code: Select all

bool chmod  (  string $filename  ,  int $mode  )
command for the install file changing it so it can be deleted. (For more info about PHP chmodding files see here)

If that doesn't work as some webservers don't allow PHP to chmod it could ask for SFTP/FTP login credentials.

Basiclly what evil said except for the attempt to chmod the install file before asking the user for FTP details.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

Post Reply