@@ -86,6 +86,7 @@ public function onRunJob() {
8686
8787 }
8888 if (is_array ($ jailkit_programs ) && !empty ($ jailkit_programs )) $ this ->run_jk_cp ($ site ['document_root ' ], $ jailkit_programs );
89+ $ this ->fix_broken_symlinks ($ site ['document_root ' ]);
8990
9091 if ($ set_php_symlink ){
9192 // create symlink from /usr/bin/php to current PHP version
@@ -163,6 +164,30 @@ private function run_jk_cp($document_root, $programs) {
163164 chmod ($ document_root .'/dev/tty ' , 0666 );
164165 }
165166 }
167+
168+ private function fix_broken_symlinks ($ document_root ){
169+ global $ app ;
170+
171+ exec ('cd ' .escapeshellarg ($ document_root ).' && find . -type l \( ! -name web \) -xtype l ' , $ output , $ retval );
172+
173+ if (is_array ($ output ) && !empty ($ output )){
174+ foreach ($ output as $ link ){
175+ $ link = trim ($ link );
176+ if (preg_match ('@\.so(\.\d+)*$@ ' ,$ link )){
177+ if (substr ($ link , 0 , 1 ) == '. ' ) $ link = substr ($ link , 1 );
178+ //echo $link."\n";
179+ $ path = $ document_root .$ link ;
180+ //if(is_link($path)) echo "Ist Link\n";
181+ //if(!file_exists($path)) echo "Aber Link ist kaputt!\n";
182+ if (is_link ($ path ) && !file_exists ($ path )){
183+ //echo $path."\n";
184+ @unlink ($ path );
185+ $ this ->run_jk_cp ($ document_root , array ($ link ));
186+ }
187+ }
188+ }
189+ }
190+ }
166191
167192 private function exec_log ($ cmd ) {
168193 global $ app ;
@@ -187,4 +212,4 @@ public function onAfterRun() {
187212
188213}
189214
190- ?>
215+ ?>
0 commit comments