コード例 #1
0
import cgi
import cgitb
import subprocess
from commoninclude import print_simple_header, print_simple_footer, close_cpanel_liveapisock, print_success, print_error, terminal_call


__author__ = "Anoop P Alias"
__copyright__ = "Copyright Anoop P Alias"
__license__ = "GPL"
__email__ = "*****@*****.**"


installation_path = "/opt/nDeploy"  # Absolute Installation Path

cgitb.enable()

cpanelhome = os.environ['HOME']
close_cpanel_liveapisock()
form = cgi.FieldStorage()

print_simple_header()

nginx_log = cpanelhome+'/logs/nginx.log'
if os.path.isfile(nginx_log):
    terminal_call('/usr/bin/tail -100 '+nginx_log, 'Displaying last 100 lines of '+nginx_log, 'Nginx log dump complete!')
    print_success('Displaying last 100 lines in the terminal window below.')
else:
    print_error('Nginx log file is not present!')

print_simple_footer()
コード例 #2
0
from commoninclude import print_simple_header, print_simple_footer, close_cpanel_liveapisock, terminal_call, print_success, print_info


__author__ = "Anoop P Alias"
__copyright__ = "Copyright Anoop P Alias"
__license__ = "GPL"
__email__ = "*****@*****.**"


cpanelhome = os.environ["HOME"]
php_log = cpanelhome+"/logs/php_error_log"

cgitb.enable()

close_cpanel_liveapisock()

form = cgi.FieldStorage()

print_simple_header()


if os.path.isfile(php_log):
    print_success('The PHP log has been written to the terminal!')
    terminal_call('/usr/bin/tail -100 '+php_log, 'Showing last 100 entries of '+cpanelhome+'/logs/php_error_log', 'PHP log dump completed!')
else:
    print_info('No PHP log file detected!')
    terminal_call('ls '+cpanelhome+'/logs/', 'Showing contents of '+cpanelhome+'/logs/', 'No PHP log file detected!')

print_simple_footer()
コード例 #3
0
if form.getvalue('domain') and form.getvalue('backend_category') and form.getvalue('backend_version') and form.getvalue('document_root'):
    mydomain = form.getvalue('domain')
    mybackend = form.getvalue('backend_category')
    mybackendversion = form.getvalue('backend_version')
    mydocroot = form.getvalue('document_root')
    terminal_call('','Project root: '+mydocroot,'')

    if mybackend == 'RUBY':

        if os.path.isfile(mydocroot+'/Gemfile'):

            if os.path.isfile('/usr/local/rvm/gems/'+mybackendversion+'/bin/bundle'):
                install_cmd = '/usr/local/rvm/bin/rvm '+mybackendversion+' do bundle install --path vendor/bundle'
                terminal_call(install_cmd, 'Installing Ruby project dependencies','Ruby project dependencies install complete!','',mydocroot)
                terminal_call('','','If the install failed, run the following command in your shell to proceed with manual installation: <kbd>cd '+mydocroot+';/usr/local/rvm/bin/rvm '+mybackendversion+' do bundle install --path vendor/bundle</kbd>')
                print_success('Ruby project dependencies install complete!')
            else:
                print_error('Bundler command not found!')

        else:
            terminal_call('','','Gemfile not found for <kbd>RUBY</kbd> project. Specify project dependencies in: '+mydocroot+'/Gemfile')
            print_error('Gemfile not found!')

    elif mybackend == 'NODEJS':

        if os.path.isfile(mydocroot+'/package.json'):
            if os.path.isfile('/usr/local/nvm/versions/node/'+mybackendversion+'/bin/npm'):
                install_cmd = '/usr/local/nvm/versions/node/'+mybackendversion+'/bin/npm -q install --production'
                my_env = os.environ.copy()
                my_env["PATH"] = "/usr/local/nvm/versions/node/"+mybackendversion+"/bin:"+my_env["PATH"]
                terminal_call(install_cmd, 'Installing NodeJS project dependencies','NodeJS project dependencies install complete!', my_env, mydocroot)
コード例 #4
0
        yaml_parsed_profileyaml['append_requesturi'] = append_requesturi
    else:
        commoninclude.print_error('Error: Forbidden::append_requesturi')
        sys.exit(0)
    # dev_mode
    if 'dev_mode' in form.keys():
        dev_mode = form.getvalue('dev_mode')
        current_dev_mode = yaml_parsed_profileyaml.get('dev_mode', 'disabled')
        if dev_mode == 'enabled' and current_dev_mode == 'disabled':
            yaml_parsed_profileyaml['dev_open_file_cache'] = yaml_parsed_profileyaml.get('open_file_cache')
            yaml_parsed_profileyaml['dev_set_expire_static'] = yaml_parsed_profileyaml.get('set_expire_static')
            yaml_parsed_profileyaml['dev_proxy_to_master'] = yaml_parsed_profileyaml.get('proxy_to_master')
            yaml_parsed_profileyaml['dev_mode'] = 'enabled'
            yaml_parsed_profileyaml['open_file_cache'] = 'disabled'
            yaml_parsed_profileyaml['set_expire_static'] = 'disabled'
            yaml_parsed_profileyaml['proxy_to_master'] = 'enabled'
        elif dev_mode == 'disabled' and current_dev_mode == 'enabled':
            yaml_parsed_profileyaml['dev_mode'] = 'disabled'
            yaml_parsed_profileyaml['open_file_cache'] = yaml_parsed_profileyaml.get('dev_open_file_cache', 'enabled')
            yaml_parsed_profileyaml['set_expire_static'] = yaml_parsed_profileyaml.get('dev_set_expire_static', 'enabled')
            yaml_parsed_profileyaml['proxy_to_master'] = yaml_parsed_profileyaml.get('dev_proxy_to_master', 'disabled')
    else:
        commoninclude.print_error('Error: Forbidden::dev_mode')
        sys.exit(0)
with open(profileyaml, 'w') as yaml_file:
    yaml.dump(yaml_parsed_profileyaml, yaml_file, default_flow_style=False)

commoninclude.print_success('Server settings saved!')

print_simple_footer()
コード例 #5
0
        # Lets deal with settings that are mutually exclusive
        if 'redis' in myapptemplate:
            the_subdir_dict['pagespeed'] = 'disabled'
            the_subdir_dict['mod_security'] = 'disabled'
            terminal_call(
                '',
                'Note: Turned off pagespeed and mod_security options as they are incompatible with Full Page cache. The cache will not work if you turn on these options!'
            )
        if 'noextra' in myapptemplate:
            the_subdir_dict['set_expire_static'] = 'disabled'
            the_subdir_dict['gzip'] = 'disabled'
            the_subdir_dict['brotli'] = 'disabled'
            terminal_call(
                '',
                'Note: Turned off gzip, brotli and set_expire_static options as they are incompatible with the template generated nginx.conf. The config will not work if you turn on these options!'
            )

        subdir_apps_dict[thesubdir] = the_subdir_dict
        with open(profileyaml, 'w') as yaml_file:
            yaml.dump(yaml_parsed_profileyaml,
                      yaml_file,
                      default_flow_style=False)
        print_success('Sub-directory app settings saved!')

    else:
        print_error('Domain-data file I/O error!')
else:
    print_forbidden()

print_simple_footer()
コード例 #6
0
form = cgi.FieldStorage()

print_simple_header()

if form.getvalue('domain') and form.getvalue('thesubdir'):
    # Get the domain name from form data
    mydomain = form.getvalue('domain')
    thesubdir = form.getvalue('thesubdir')
    profileyaml = installation_path + "/domain-data/" + mydomain
    if os.path.isfile(profileyaml):
        # Get all config settings from the domains domain-data config file
        with open(profileyaml, 'r') as profileyaml_data_stream:
            yaml_parsed_profileyaml = yaml.safe_load(profileyaml_data_stream)
        subdir_apps_dict = yaml_parsed_profileyaml.get('subdir_apps')
        if thesubdir in subdir_apps_dict.keys():
            del subdir_apps_dict[thesubdir]
        else:
            commoninclude.print_error('The SubDir is not configured')
        yaml_parsed_profileyaml['subdir_apps'] = subdir_apps_dict
        with open(profileyaml, 'w') as yaml_file:
            yaml.dump(yaml_parsed_profileyaml,
                      yaml_file,
                      default_flow_style=False)
        commoninclude.print_success('Successfully removed sub-directory')
    else:
        commoninclude.print_error('domain-data file i/o error')
else:
    commoninclude.print_forbidden()

print_simple_footer()
コード例 #7
0
close_cpanel_liveapisock()
form = cgi.FieldStorage()

print_simple_header()


if form.getvalue('domain'):

    # Get the domain name from form data
    mydomain = form.getvalue('domain')
    profileyaml = installation_path + "/domain-data/" + mydomain
    if os.path.isfile(profileyaml):

        # Get all config settings from the domains domain-data config file
        with open(profileyaml, 'r') as profileyaml_data_stream:
            yaml_parsed_profileyaml = yaml.safe_load(profileyaml_data_stream)
        with open(profileyaml, 'w') as yaml_file:
            yaml.dump(yaml_parsed_profileyaml, yaml_file, default_flow_style=False)

        # Delay Ajax end so nginx reloads before we refresh otherwise we see invalid status
        time.sleep(2)
        print_success('Nginx configuration successfully reloaded!')
    else:
        print_error('Domain-data file I/O error!')

else:
    print_forbidden()

print_simple_footer()
コード例 #8
0
        yaml_parsed_profileyaml['apptemplate_code'] = myapptemplate

        # Lets deal with settings that are mutually exclusive
        if 'redis' in myapptemplate:
            yaml_parsed_profileyaml['pagespeed'] = 'disabled'
            yaml_parsed_profileyaml['mod_security'] = 'disabled'
            terminal_call('','Note: Turned off pagespeed and mod_security options as they are incompatible with Full Page cache. The cache will not work if you turn on these options!')
        if '5029' in myapptemplate or 'w3tc' in myapptemplate:
            yaml_parsed_profileyaml['set_expire_static'] = 'disabled'
            yaml_parsed_profileyaml['gzip'] = 'disabled'
            yaml_parsed_profileyaml['brotli'] = 'disabled'
            terminal_call('','Note: Turned off gzip, brotli and set_expire_static options as they are incompatible with Wordpress Total Cache generated nginx.conf. The config will not work if you turn on these options!')
        if 'noextra' in myapptemplate:
            yaml_parsed_profileyaml['set_expire_static'] = 'disabled'
            yaml_parsed_profileyaml['gzip'] = 'disabled'
            yaml_parsed_profileyaml['brotli'] = 'disabled'
            terminal_call('','Note: Turned off gzip, brotli and set_expire_static options as they are incompatible with the template generated nginx.conf. The config will not work if you turn on these options!')
        with open(profileyaml, 'w') as yaml_file:
            yaml.dump(yaml_parsed_profileyaml, yaml_file, default_flow_style=False)

        # Delay Ajax end so nginx reloads before we refresh otherwise we see invalid status
        time.sleep(2)       
        print_success('Upstream settings saved!')

    else:
        print_error('Domain-data file I/O error!')
else:
    print_forbidden()

print_simple_footer()