Script to Extract ZIP Package for Install

Not sure where to post this, or how useful it will be overall, but I have been building out a more extensive set of test servers and have been testing CP installs on some of them as I go.

While not a huge issue, the CP download zip file is a bit clumsy to download, extract and move the files where I want them, so I modified one of my install scripts to grab the CP zip file and extract to the same folder the script is uploaded and run from. While set up to install the latest CP package, it has form inputs, so you could enter any file with the same structure (CP stores the package files one folder down and this script expects that to be the case, it installs what it finds one folder level into the archive).

It can be used as is to install CP on most servers I suspect, it will grab the zip file, extract package files to the folder it is in, delete temporary folders and itself, then offer a submit button to start the installer:

Is this an issue with CP zip only, or is it the same for WordPress? Just curious if there is anything we can fix and improve.

I think a lot of packages are zipped up that way (with the actual package files contained inside of the first folder rather than root). The official WP zip is the same way, I think WP has one file / one click installers offered by providers also, but to be honest that is not how I install WP, I just clone a VM, set a new machine-id and update.

I think it might be done that way so the unsuspecting user doesn’t unzip to a folder and end up with all the files dumped into that folder when that was not what they expected? For me though, I have to move the files back to root if I unzipped on the server, so this script eliminates those steps and should work with any zipped package created in a nested folder.

That script is basically a ‘one file’ installer, grabbing the zip, putting the files in the folder you uploaded to and then starting the actual CP installer, so it is easy and convenient.

I always put the CP, WP install in a folder,but then sometimes end up with the files, in a folder, in a folder, so have to move them anyway.
I find it tidier to have the install not in root, especially if the site has other things in root.
Also if doing a major update to site I do new install/clone into a new folder, then edit index.php to new folder wnen replacement site ready.

I suspect that is one reason they are packaged that way.
My script will install to whatever folder it is in, so if in root, the package is extracted to root, but if the script is uploaded to a subfolder, that is where the package would be extracted.

My server is local, so I can samba or ssh (WinSCP) easily, but for a quick install of a CP, this works nice and you can paste the URL for the nightly and install that instead of v1 if inclined to do so.

Overall doing it manually is good, but eventually you should be using wp-cli, all hosting providers have wp-cli built into their servers and if you are using local devs, then you probably want to use wp-cli to do most of the work.