~ubuntu-branches/ubuntu/raring/lsb/raring-proposed

« back to all changes in this revision

Viewing changes to lsbinstall

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-03-10 18:48:17 UTC
  • Revision ID: james.westby@ubuntu.com-20080310184817-7kxrgtuzhy8nnvjr
Tags: 3.2-4ubuntu1
* Merge with Debian; remaining changes:
  - Depend on postfix rather than exim4 as preferred mail-transport-agent
    alternative.
  - Depend on libgl1-mesa-glx rather than libgl1-mesa as preferred libgl1
    alternative.
  - Add Ubuntu logging functions.
  - lsb: Drop the optional lsb-qt4 module to a suggests.
  - Maintainer field set to Ubuntu.
* init-functions: Make functions safe to use with sh -e.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import os
5
5
import shutil
6
6
import socket
 
7
import commands
7
8
from tempfile import NamedTemporaryFile
8
9
from initdutils import load_lsbinstall_info, save_lsbinstall_info
9
10
 
12
13
    #'init',
13
14
    'profile',
14
15
    'service',
15
 
    #'inet', # XXX - reenable when implemented
 
16
    'inet', # XXX - reenable when implemented
16
17
    #'crontab',
17
18
    #'man'
18
19
    )
170
171
        sname, pproto, ' '.join(saliases), pkg)
171
172
    fp.close()
172
173
 
173
 
def handle_inet(options, args):
174
 
    # call update-inetd
 
174
def handle_inet(options, args, parser):
 
175
    cmd = 'update-inetd --group LSB '
 
176
 
 
177
    alist = list(args[0].split(':'))
 
178
    if len(alist) < 2:
 
179
        parser.error("The operand must include a service and protocol.")
 
180
        return
 
181
    
 
182
    if not alist[1]:
 
183
        alist[1] = 'tcp'
 
184
    
 
185
    if options.remove:
 
186
        parts = r'%s\s+.*\s+%s\s+.*' % (re.escape(alist[0], alist[1]))
 
187
        cmd += '--remove '+commands.mkarg(parts)
 
188
    elif options.check:
 
189
        return
 
190
    else:
 
191
        if len(alist) != 6:
 
192
            parser.error('The operand must have six colon-separated arguments.')
 
193
            return
 
194
        newalist = [alist[0], alist[2], alist[1]] + alist[3:]
 
195
        cmd += '--add '+commands.mkarg('\t'.join(newalist))
 
196
 
 
197
    os.system(cmd)
175
198
    pass
176
199
 
177
200
def handle_man(options, args):
231
254
            parser.error('You must specify one argument when removing or checking a service entry.')
232
255
        handle_service(options, args)
233
256
    elif options.type == 'inet':
234
 
        handle_inet(options, args)
 
257
        handle_inet(options, args, parser)
235
258
    elif options.type == 'crontab':
236
259
        if len(args) > 1:
237
260
            parser.error('Only one argument supported for %s' % options.type)