Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def check_file(dir):
- files = os.listdir(os.getcwd() + '/' + dir)
- configs = []
- for file in files:
- if dir != file.split('.txt')[0]:
- configs.append(file.split('.txt')[0])
- return configs
- def config_file(data, domain):
- data = data.replace('%domain%', domain)
- new_file = open(domain + '.conf', 'w')
- new_file.write(data)
- new_file.close()
- def read_file(server, type):
- f = open(os.getcwd() + '/' + type + '/'+ server + '.txt', 'r')
- data = f.read()
- f.close()
- return data
- if __name__ == '__main__':
- server = input('Выберите сервер: 1 Apache, 2 Nginx: ')
- domain = input('Введите домен сайта: ')
- if int(server) == 1:
- if len(check_file('apache')) == 0:
- config_file(read_file('apache', 'apache'), domain)
- else:
- configs = input('У нас есть несколько кофигов на Apache Выберите, пожалуйста: '+','.join(check_file('apache')))
- config_file(read_file(configs, 'apache'), domain)
- else:
- if len(check_file('nginx')) == 0:
- config_file(read_file('nginx', 'nginx'), domain)
- else:
- configs = input('У нас есть несколько кофигов на Nginx Выберите, пожалуйста: '+','.join(check_file('nginx'))+' ')
- config_file(read_file(configs, 'nginx'), domain)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement