22 lines
779 B
Python
22 lines
779 B
Python
import os
|
|
import shutil
|
|
|
|
if __name__ == "__main__":
|
|
source_dir = r'/etc/systemd/system'
|
|
info_file = 'restart_services.sh'
|
|
items = os.listdir(source_dir)
|
|
print(items)
|
|
with open(info_file, 'r') as file:
|
|
for line in file:
|
|
filename = line.strip().split()[-1]
|
|
print(filename)
|
|
if filename != 'nginx':
|
|
socket_file = os.path.join(source_dir,f'{filename}.socket')
|
|
service_file = os.path.join(source_dir,f'{filename}.service')
|
|
if os.path.isfile(socket_file):
|
|
shutil.copyfile(socket_file, f'./systemd/{filename}.socket')
|
|
if os.path.isfile(service_file):
|
|
shutil.copyfile(service_file,f'./systemd/{filename}.service')
|
|
|
|
|