예제 #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
    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)
                terminal_call('','','If the install failed, run the following command in your shell to proceed with manual installation: <kbd>export PATH="/usr/local/nvm/versions/node/'+mybackendversion+'/bin:$PATH";cd '+mydocroot+';npm install --production</kbd>')
                print_success('NodeJS project dependencies install complete!')
예제 #3
0
    # Get the domain name from form data
    mydomain = form.getvalue('domain')
    mybackend = form.getvalue('backend')
    mybackendversion = form.getvalue('backendversion')
    myapptemplate = form.getvalue('apptemplate')
    thesubdir = form.getvalue('thesubdir')
    profileyaml = installation_path + "/domain-data/" + mydomain

    # Get data about the backends available
    if os.path.isfile(backend_config_file):
        with open(backend_config_file, 'r') as backend_data_yaml:
            backend_data_yaml_parsed = yaml.safe_load(backend_data_yaml)
        mybackend_dict = backend_data_yaml_parsed.get(mybackend)
        mybackendpath = mybackend_dict.get(mybackendversion)
    else:
        print_error('Backend data file I/O error!')
        sys.exit(0)
    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():
            the_subdir_dict = subdir_apps_dict.get(thesubdir)
        else:
            the_subdir_dict = {}

        # Ok lets save everything to the domain-data file
        the_subdir_dict['backend_category'] = mybackend
        the_subdir_dict['backend_path'] = mybackendpath
예제 #4
0

cgitb.enable()

commoninclude.close_cpanel_liveapisock()
form = cgi.FieldStorage()


print_simple_header()


# Get the domain name
if 'domain' in form.keys():
    mydomain = form.getvalue('domain')
else:
    commoninclude.print_error('Error: Forbidden::domain')
    sys.exit(0)
# Getting the current domain data
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)
    try:
        current_dev_mode = yaml_parsed_profileyaml.get('dev_mode')
    except KeyError:
        current_dev_mode = 'disabled'
else:
    commoninclude.print_error('Error: Domain data file i/o error')
    sys.exit(0)
if form.getvalue('thesubdir'):
예제 #5
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()