fix: defensive ServiceProvider (class_exists guards), fixed install.sh apply_patch logic
This commit is contained in:
32
scripts/fix_asp.py
Normal file
32
scripts/fix_asp.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fix AppServiceProvider — ensure AddonServiceProvider is registered."""
|
||||
import sys
|
||||
|
||||
f = '/var/www/pterodactyl/app/Providers/AppServiceProvider.php'
|
||||
content = open(f).read()
|
||||
|
||||
if 'AddonServiceProvider' in content and '$this->app->register' in content.split('AddonServiceProvider')[0].split('\n')[-2:][0]:
|
||||
print('Already correctly patched')
|
||||
sys.exit(0)
|
||||
|
||||
# Remove the broken line (the one without $this->)
|
||||
lines = content.splitlines(keepends=True)
|
||||
fixed = []
|
||||
for line in lines:
|
||||
# Replace the broken orphan line
|
||||
if '->app->register(\\Pterodactyl\\Addons\\AdvancedAdmin\\AddonServiceProvider::class)' in line and not '$this' in line:
|
||||
fixed.append(' $this->app->register(\\Pterodactyl\\Addons\\AdvancedAdmin\\AddonServiceProvider::class);\n')
|
||||
else:
|
||||
fixed.append(line)
|
||||
|
||||
content = ''.join(fixed)
|
||||
open(f, 'w').write(content)
|
||||
print('Fixed: $this-> added to AddonServiceProvider line')
|
||||
|
||||
# Verify
|
||||
result = open(f).read()
|
||||
if '$this->app->register(\\Pterodactyl\\Addons\\AdvancedAdmin\\AddonServiceProvider::class)' in result:
|
||||
print('Verification OK')
|
||||
else:
|
||||
print('ERROR: Verification failed')
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user