Files
server/opt/psa/admin/sbin/modules/panel-migrator/plesk-migrator
cutemeli 0bfc6c8425 Initial
2025-12-22 10:32:59 +00:00

45 lines
1.5 KiB
Python
Executable File

#!/opt/plesk/python/3/bin/python
# Copyright 1999-2024. Plesk International GmbH. All rights reserved.
import platform
import os
import sys
if platform.system() != 'Windows':
# Configure migrator so:
# - nobody except root and Plesk user under which migrator is running can read/modify the files.
# - both backend (running as superuser) and frontend (running as "psaadm") could work with the files.
# Expected permissions for files created by backend are:
# rw-rw---- root psaadm
# Expected permissions for directories created by backend are:
# rwxrwx--- root psaadm
# So, frontend could work with files by group "psadm", and backend could work with the files as superuser.
import grp
try:
frontend_group_entry = grp.getgrnam('psaadm')
except KeyError:
frontend_group_entry = None
if frontend_group_entry is not None:
frontend_group_id = frontend_group_entry.gr_gid
os.setegid(frontend_group_id)
# Do not allow others to work with files
os.umask(0o007)
execution_path = __file__
while os.path.islink(execution_path):
execution_path = os.readlink(execution_path)
base_dir = '/usr/local/psa/admin/plib/modules/panel-migrator/backend'
lib_dir = '/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib'
var_dir = '/usr/local/psa/var/modules/panel-migrator'
sys.path.extend([os.path.join(lib_dir, 'python')])
from parallels.core.cli.migration_cli import run
if __name__ == '__main__':
sys.exit(run(base_dir, var_dir, execution_path, sys.argv[1:]))