Server IP : 103.119.228.120 / Your IP : 3.149.24.143 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/bin/ |
Upload File : |
#!/usr/bin/python # -*- Mode: Python; python-indent: 8; indent-tabs-mode: t -*- import sys, os, argparse, errno def find_service(service, runlevel): priority = -1 for l in os.listdir("/etc/rc%i.d" % runlevel): if len(l) < 4: continue if l[0] != 'S' or l[3:] != service: continue p = int(l[1:3]) if p >= 0 and p <= 99 and p >= priority: priority = p; return priority def lookup_database(services): try: database = open("/var/lib/systemd/sysv-convert/database", "r") except IOError, e: if e.errno != errno.ENOENT: raise e return {} found = {} k = 0 for line in database: service, r, p = line.strip().split("\t", 3) k += 1 try: runlevel = int(r) priority = int(p) except ValueError, e: sys.stderr.write("Failed to parse database line %i. Ignoring." % k) continue if runlevel not in (2, 3, 4, 5): sys.stderr.write("Runlevel out of bounds in database line %i. Ignoring." % k) continue if priority < 0 or priority > 99: sys.stderr.write("Priority out of bounds in database line %i. Ignoring." % k) continue if service not in services: continue if service not in found: found[service] = {} if runlevel not in found[service] or found[service][runlevel] < priority: found[service][runlevel] = priority return found def mkdir_p(path): try: os.makedirs(path, 0755) except OSError, e: if e.errno != errno.EEXIST: raise e if os.geteuid() != 0: sys.stderr.write("Need to be root.\n") sys.exit(1) parser = argparse.ArgumentParser(description='Save and Restore SysV Service Runlevel Information') parser.add_argument('services', metavar='SERVICE', type=str, nargs='+', help='Service names') parser.add_argument('--save', dest='save', action='store_const', const=True, default=False, help='Save SysV runlevel information for one or more services') parser.add_argument('--show', dest='show', action='store_const', const=True, default=False, help='Show saved SysV runlevel information for one or more services') parser.add_argument('--apply', dest='apply', action='store_const', const=True, default=False, help='Apply saved SysV runlevel information for one or more services to systemd counterparts') a = parser.parse_args() if a.save: for service in a.services: if not os.access("/etc/rc.d/init.d/%s" % service, os.F_OK): sys.stderr.write("SysV service %s does not exist.\n" % service) sys.exit(1) mkdir_p("/var/lib/systemd/sysv-convert") database = open("/var/lib/systemd/sysv-convert/database", "a") for runlevel in (2, 3, 4, 5): priority = find_service(service, runlevel) if priority >= 0: database.write("%s\t%s\t%s\n" % (service, runlevel, priority)) elif a.show: found = lookup_database(a.services) if len(found) <= 0: sys.stderr.write("No information about passed services found.\n") sys.exit(1) for service, data in found.iteritems(): for runlevel, priority in data.iteritems(): sys.stdout.write("SysV service %s enabled in runlevel %s at priority %s\n" % (service, runlevel, priority)) elif a.apply: for service in a.services: if not os.access("/lib/systemd/system/%s.service" % service, os.F_OK): sys.stderr.write("systemd service %s.service does not exist.\n" % service) sys.exit(1) found = lookup_database(a.services) if len(found) <= 0: sys.stderr.write("No information about passed services found.\n") sys.exit(1) for service, data in found.iteritems(): for runlevel in data.iterkeys(): sys.stderr.write("ln -sf /lib/systemd/system/%s.service /etc/systemd/system/runlevel%i.target.wants/%s.service\n" % (service, runlevel, service)) mkdir_p("/etc/systemd/system/runlevel%i.target.wants" % runlevel) try: os.symlink("/lib/systemd/system/%s.service" % service, "/etc/systemd/system/runlevel%i.target.wants/%s.service" % (runlevel, service)) except OSError, e: if e.errno != errno.EEXIST: raise e else: parser.print_help()