Example #1
0
    def add_rest(self, rows):
        text = ''
        for row in rows:
            line1 = ' -s /ipmi/console/%s:nobody:nogroup:/:\\"ipmitool -I lanplus -U %s -H %s -P %s sol activate\\"' % (
                row[0].replace('.', '/'), row[1], row[0], row[2])
            line2 = ' -s /ipmi/deactivate/%s:nobody:nogroup:/:\\"ipmitool -I lanplus -U %s -H %s -P %s sol deactivate\\"' % (
                row[0].replace('.', '/'), row[1], row[0], row[2])
            line3 = ' -s /ipmi/shell/%s:nobody:nogroup:/:\\"ipmitool -I lanplus -U %s -H %s -P %s shell\\"' % (
                row[0].replace('.', '/'), row[1], row[0], row[2])
            line = line1 + line2 + line3
            text += line
        Writer(filename).write(
            'SHELLINABOX_ARGS="--no-beep --localhost-only --disable-ssl')
        Writer(filename).write(text)
        Writer(filename).write('"\n')

    def run(self):
        bmc_cmd = 'select bmc_ip,userid,password from server_info where sol = 1;'
        rc, rows = mysql('xxxx', 'xxxxxx', 'server_info').get_response(bmc_cmd)
        if rc:
            self.pre_action()
            self.add_head()
            self.add_rest(rows)


if __name__ == '__main__':
    filename = '/etc/default/shellinabox'
    logger = mylogger("/opt/log/shellinabox_mc.log").initlog()
    shellinabox().run()
Example #2
0
        print '# We disable beeps, as there have been reports of the VLC plugin crashing'
        print '# Firefox on Linux/x86_64.'
        sys.stdout = stdout_pre

    def add_rest(self,rows):
        text = ''
        for row in rows:
            line1 = ' -s /ipmi/console/%s:nobody:nogroup:/:\\"ipmitool -I lanplus -U %s -H %s -P %s sol activate\\"' %(row[0].replace('.','/'),row[1],row[0],row[2])
            line2 = ' -s /ipmi/deactivate/%s:nobody:nogroup:/:\\"ipmitool -I lanplus -U %s -H %s -P %s sol deactivate\\"' %(row[0].replace('.','/'),row[1],row[0],row[2])
            line3 = ' -s /ipmi/shell/%s:nobody:nogroup:/:\\"ipmitool -I lanplus -U %s -H %s -P %s shell\\"' %(row[0].replace('.','/'),row[1],row[0],row[2])
            line = line1 + line2 + line3
            text += line
        Writer(filename).write('SHELLINABOX_ARGS="--no-beep --localhost-only --disable-ssl')
        Writer(filename).write(text)
        Writer(filename).write('"\n')

    def run(self):
        bmc_cmd = 'select bmc_ip,userid,password from server_info where sol = 1;'
        rc,rows = mysql('xxxx','xxxxxx','server_info').get_response(bmc_cmd)
        if rc:
            self.pre_action()
            self.add_head()
            self.add_rest(rows)
            

if __name__ == '__main__':
    filename = '/etc/default/shellinabox'
    logger = mylogger("/opt/log/shellinabox_mc.log").initlog()
    shellinabox().run()

Example #3
0
            if (proc_name == proc_names[1]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/etc/init.d/nginx start')
            if (proc_name == proc_names[2]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/etc/init.d/dhcpd start')
            if (proc_name == proc_names[3]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/etc/init.d/xinetd start')
            if (proc_name == proc_names[4]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/etc/init.d/php-fpm start')
            if (proc_name == proc_names[5]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/usr/bin/python /opt/app/server/server.py &')
            if (proc_name == proc_names[6]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/usr/bin/python /opt/app/server/bmc_check.py &')
            if (proc_name == proc_names[7]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/etc/init.d/shellinabox start')
            if (proc_name == proc_names[8]):
                logger.debug('Can not find proc: %s, start it!' % proc_name)
                os.system('/etc/init.d/vncserver start')


if __name__ == '__main__':
    proc_names = 'mysql', 'nginx', 'dhcp', 'xinetd', 'php', 'server.py', 'bmc_check.py', 'shellinaboxd', 'vnc'
    logger = mylogger("/opt/log/process.log").initlog()
    check_proc()
Example #4
0
                os.system('/etc/init.d/mysql start')
            if (proc_name == proc_names[1]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/etc/init.d/nginx start')
            if (proc_name == proc_names[2]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/etc/init.d/dhcpd start')
            if (proc_name == proc_names[3]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/etc/init.d/xinetd start')
            if (proc_name == proc_names[4]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/etc/init.d/php-fpm start')
            if (proc_name == proc_names[5]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/usr/bin/python /opt/app/server/server.py &')
            if (proc_name == proc_names[6]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/usr/bin/python /opt/app/server/bmc_check.py &')
            if (proc_name == proc_names[7]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/etc/init.d/shellinabox start')
            if (proc_name == proc_names[8]):
                logger.debug('Can not find proc: %s, start it!' %proc_name)
                os.system('/etc/init.d/vncserver start')

if __name__=='__main__':
    proc_names = 'mysql','nginx','dhcp','xinetd','php','server.py','bmc_check.py','shellinaboxd','vnc'
    logger = mylogger("/opt/log/process.log").initlog()
    check_proc()