133 lines
3.5 KiB
Python
Executable File
133 lines
3.5 KiB
Python
Executable File
#!/usr/bin/python
|
|
import sys, time
|
|
sys.path.insert(0,'/usr/lib/entropy/libraries')
|
|
sys.path.insert(0,'/usr/lib/entropy/client')
|
|
sys.path.insert(0,'../libraries')
|
|
sys.path.insert(0,'../client')
|
|
# disable pid management
|
|
sys.argv.append("--no-pid-handling")
|
|
do_ssl = False
|
|
do_stdout_logging = True
|
|
if "--ssl" in sys.argv:
|
|
do_ssl = True
|
|
if "--nostdout" in sys.argv:
|
|
do_stdout_logging = False
|
|
|
|
from entropy.output import print_menu, nocolor
|
|
from entropy.tools import get_year
|
|
from entropy.misc import ParallelTask
|
|
from entropy.core import SystemSettings
|
|
SysSettings = SystemSettings()
|
|
|
|
myopts = [
|
|
None,
|
|
(0," ~ "+SysSettings['system']['name']+" ~ "+sys.argv[0]+" ~ ",1,'Repository Services daemon - (C) %s' % (get_year(),) ),
|
|
None,
|
|
(0,_('Basic Options'),0,None),
|
|
None,
|
|
(1,'--help',2,_('this output')),
|
|
(1,'--nocolor',1,_('disable colorized output')),
|
|
None,
|
|
(0,_('Application Options'),0,None),
|
|
None,
|
|
(1,'--ssl',2,_('enable SSL service too')),
|
|
(1,'--nostdout',1,_('disable output to stdout, redirect to log file')),
|
|
None,
|
|
]
|
|
|
|
if "--nocolor" in sys.argv:
|
|
nocolor()
|
|
|
|
if "--help" in sys.argv:
|
|
print_menu(myopts)
|
|
raise SystemExit(1)
|
|
|
|
|
|
from entropy.services.repository.interfaces import Server
|
|
from entropy.services.auth_interfaces import phpBB3Auth as phpBB3AuthInterface
|
|
from entropy.services.authenticators import phpBB3
|
|
from entropy.services.commands import phpBB3 as phpBB3Commands
|
|
from entropy.services.ugc.commands import UGC
|
|
|
|
connection_data = {
|
|
'hostname': 'localhost',
|
|
'port': 3306,
|
|
'username': 'phpbb_user',
|
|
'password': 'mypassword',
|
|
'dbname': 'phpbb_db'
|
|
}
|
|
ugc_connection_data = {
|
|
'hostname': 'localhost',
|
|
'username': 'entropy',
|
|
'password': 'password',
|
|
'dbname': 'entropy',
|
|
'google_email': 'your@gmail.com', # valid google account
|
|
'google_password': 'yourgmailpassword', # valid google e-mail
|
|
'google_developer_key': 'xxxxx', # valid google developer key
|
|
'google_client_id': 'xxxx', # valid google client id connected to the developer key
|
|
}
|
|
ugc_store_path = "/path/to/your/ugc/store"
|
|
ugc_store_url = "http://www.yoursite.com"
|
|
ugc_args = [ugc_connection_data,ugc_store_path,ugc_store_url]
|
|
|
|
# configure my repositories
|
|
repositories = {
|
|
('sabayonlinux.org','amd64','standard','4',): {
|
|
'dbpath': '/home/fabio/new.sabayonlinux.org/standard/amd64/4',
|
|
'cmethod': 'bz2',
|
|
},
|
|
}
|
|
|
|
def run_srv(s):
|
|
try:
|
|
s.go()
|
|
except (KeyboardInterrupt, SystemExit,):
|
|
s.killall()
|
|
|
|
sock_auth = (phpBB3,[],connection_data)
|
|
srv_ssl = None
|
|
srv = Server(
|
|
do_ssl = False,
|
|
repositories = repositories,
|
|
stdout_logging = do_stdout_logging,
|
|
sock_auth = sock_auth,
|
|
external_cmd_classes = [phpBB3Commands,(UGC,ugc_args,)]
|
|
)
|
|
if do_ssl:
|
|
srv_ssl = Server(
|
|
do_ssl = True,
|
|
repositories = repositories,
|
|
stdout_logging = do_stdout_logging,
|
|
sock_auth = sock_auth,
|
|
external_cmd_classes = [phpBB3Commands,(UGC,ugc_args,)]
|
|
)
|
|
|
|
task = ParallelTask(run_srv, srv)
|
|
task.setName('repodaemon')
|
|
task.start()
|
|
task2 = None
|
|
if srv_ssl != None:
|
|
task2 = ParallelTask(run_srv, srv_ssl)
|
|
task2.setName('repodaemon_ssl')
|
|
task2.start()
|
|
|
|
run_map = {
|
|
"repodaemon": srv,
|
|
"repodaemon_ssl": srv_ssl,
|
|
}
|
|
t_map = {
|
|
"repodaemon": task,
|
|
"repodaemon_ssl": task2,
|
|
}
|
|
|
|
while 1:
|
|
try:
|
|
time.sleep(1)
|
|
except (KeyboardInterrupt, SystemExit,):
|
|
for obj in run_map.values():
|
|
obj.killall()
|
|
for t in t_map.values():
|
|
t.join()
|
|
break
|
|
raise SystemExit(0)
|