Last active
April 27, 2021 08:22
-
-
Save sebastianbrosch/bf282dfc90a791c78146 to your computer and use it in GitHub Desktop.
A script to create the symlinks for TYPO3 on a Hetzner webspace.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //---------------------------------------------------------\\ | |
| // This script can be used on a webserver to create \\ | |
| // the symlinks for a TYPO3 installation. \\ | |
| // \\ | |
| // This script works with the following folder structure: \\ | |
| // Webspace-Root \\ | |
| // |- Website-Root \\ | |
| // | |- hetzner-symlink.php \\ | |
| // |- TYPO3-Source-Folder \\ | |
| // | |- typo3 \\ | |
| // | |- vendor \\ | |
| // | |- index.php \\ | |
| //---------------------------------------------------------\\ | |
| //display the absolute path of the webspace. | |
| $absolute_path = realpath(getcwd().'/../'); | |
| echo 'Working Directory: '.$absolute_path.'<br>'; | |
| //get the path to the folder which will be linked. | |
| $version_folder = $absolute_path.'/typo3_src-9.5.26'; | |
| //check if the source folder is available. | |
| if (is_dir($version_folder)) { | |
| echo 'Source Directory: '.$version_folder.'<br>'; | |
| //check whether one of the symlink folders is a real folder (and not a symlink). | |
| if (is_link('typo3_src') === false || is_link('typo3') === false || is_link('vendor') === false) { | |
| //there is no vendor directory on older versions of TYPO3. | |
| //just make sure the folder doesn't exists. | |
| if (file_exists('vendor')) { | |
| echo 'One of the folders typo3_src, typo3 or vendor is not a symbolic link.<br>'; | |
| ShowSymlinkStatus(); | |
| exit; | |
| } | |
| } | |
| //check whether one of the symlink files is a real file (and not a symlink). | |
| if (is_link('index.php') === false) { | |
| echo 'The file index.php is not a symbolic link.<br>'; | |
| ShowSymlinkStatus(); | |
| exit; | |
| } | |
| //remove the current TYPO3 folders and files. | |
| if (is_link('typo3_src')) unlink('typo3_src'); | |
| if (is_link('typo3')) unlink('typo3'); | |
| if (is_link('vendor')) unlink('vendor'); | |
| if (is_link('index.php')) unlink('index.php'); | |
| echo 'Removed current TYPO3 files and folders.<br>'; | |
| //create the symlinks of TYPO3 files and folders. | |
| symlink($version_folder, 'typo3_src'); | |
| symlink('typo3_src/typo3', 'typo3'); | |
| symlink('typo3_src/vendor', 'vendor'); | |
| symlink('typo3_src/index.php', 'index.php'); | |
| //check whether all symlinks could be created. | |
| if (is_link('typo3_src') && is_link('typo3') && is_link('vendor') && is_link('index.php')) { | |
| echo 'Successfully created all symlinks.<br>'; | |
| } else { | |
| echo 'One or more symlinks could not be created!<br>'; | |
| } | |
| } else { | |
| echo 'Source-Directory doesn\'t exists!<br>'; | |
| echo 'No changes were made.'; | |
| } | |
| function ShowSymlinkStatus() { | |
| echo 'typo3_src: '.(is_link('typo3_src') ? 'OK' : 'Not OK').'<br>'; | |
| echo 'typo3: '.(is_link('typo3') ? 'OK' : 'Not OK').'<br>'; | |
| echo 'vendor: '.(is_link('vendor') ? 'OK' : 'Not OK').'<br>'; | |
| echo 'index.php: '.(is_link('index.php') ? 'OK' : 'Not OK').'<br>'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment