Index: trunk/scripts/attach-add.py =================================================================== --- trunk/scripts/attach-add.py (revision 8) +++ trunk/scripts/attach-add.py (revision 8) @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +import os +import sys +import getopt + +usage = """Usage: add [-vfrpwbq] [-P $athena_path] [-a attachflags] [lockername ...] + add [-dfrb] [-P $athena_path] pathname ... +""" + +if '-a' in sys.argv[1:]: + (add_options, attach_options) = sys.argv[1:].split('-a') +else: + add_options = sys.argv[1:] + attach_options = [] + +try: + optlist, args = getopt.getopt(add_options, 'frwpP:abqh'); +except getopt.GetoptError: + sys.stderr.write(usage) + sys.exit(1) + +front = False +remove_locker = False +shell = 'csh' +for o, a in optlist: + if o == '-f': front = True + if o == '-r': remove_locker = True + if o == '-b': shell = 'bash' + +if os.environ.has_key('PATH'): + path = os.environ['PATH'].split(':') +else: path = [] + +if os.environ.has_key('MANPATH'): + manpath = os.environ['MANPATH'].split(':') +else: manpath = [] + +if os.environ.has_key('INFOPATH'): + infopath = os.environ['INFOPATH'].split(':') +else: infopath = [] + +for arg in args: + if '/' == arg[0] or '.' == arg[0]: + if remove_locker: path.remove(arg) + elif front: path = [arg] + path + else: path.append(arg) + else: + locker = '/mit/%s' % arg + + bin_pipe = os.popen('/usr/local/bin/athdir %s bin' % locker) + new_bin = bin_pipe.read().strip() + if bin_pipe.close() != None: + if not os.access(locker, os.F_OK): + sys.stderr.write("%s: Locker unknown\n" % arg) + continue + if new_bin in path: + path.remove(new_bin) + if front: path.insert(0, new_bin) + elif not remove_locker: path.append(new_bin) + + man_pipe = os.popen('/usr/local/bin/athdir %s man' % locker) + new_man = man_pipe.read().strip() + if man_pipe.close() == None: + if new_man in manpath: + manpath.remove(new_man) + if front: manpath.insert(0, new_man) + elif not remove_locker: manpath.append(new_man) + + info_pipe = os.popen('/usr/local/bin/athdir %s info' % locker) + new_info = info_pipe.read().strip() + if info_pipe.close() == None: + if new_info in infopath: + infopath.remove(new_info) + if front: infopath.insert(0, new_info) + elif not remove_locker: infopath.append(new_info) + +if shell == 'bash': + print 'PATH="%s"; export PATH; MANPATH="%s"; export MANPATH; INFOPATH="%s"; export INFOPATH' % (':'.join(path), ':'.join(manpath), ':'.join(infopath)) +elif shell == 'csh': + print 'setenv PATH "%s"; setenv MANPATH "%s"; setenv INFOPATH "%s"' % (':'.join(path), ':'.join(manpath), ':'.join(infopath)) Index: trunk/scripts/attach =================================================================== --- trunk/scripts/attach (revision 8) +++ trunk/scripts/attach (revision 8) @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +import sys +import os +import getopt +import hesiod + +usage = """Usage: attach [options] filesystem ... [options] filesystem ... + attach -l filesystem + attach -H host + attach +""" + +if len(sys.argv) > 1 and sys.argv[1] == '-Padd': + os.execv('/usr/local/bin/attach-add.py', sys.argv[2:]) + +try: + optlist, args = getopt.getopt(sys.argv[1:], 'vqplvngazhrwm:Mxet:o:NSOLH', ['verbose', 'quiet', 'printpath', 'lookup', 'map', 'nomap', 'remap', 'noremap', 'zephyr', 'nozephyr', 'readonly', 'write', 'mountpoint=', 'master', 'noexplicit', 'explicit', 'type', 'mountoptions', 'nosetuid', 'nosuid', 'setuid', 'suid', 'override', 'lock', 'host=']); +except getopt.GetoptError: + sys.stderr.write(usage) + sys.exit(1) + +print_usage = False +noise_level = 'verbose' +for o, a in optlist: + if o == '-l' or o == '--lookup': + noise_level = 'lookup' + if o == '-v' or o == '--verbose': + noise_level = 'verbose' + if o == '-q' or o == '--quiet': + noise_level = 'quiet' + if o == '-p' or o == '--printpath': + noise_level = 'path' + if o == '-m' or o == '--mountpoint': + if a[0:5] == '/mit/': + sys.stderr.write('Sorry. The MacAthena attach program does not support alternate mount points within /mit\n') + sys.exit(1) + elif len(args) != 1: + print_usage = True + else: + filsys = hesiod.FilsysLookup(args[0]) + if filsys: + os.symlink(filsys.getFilsys()[0]['location'], a) + sys.exit(0) + else: + sys.stderr.write('%s: Locker unknown' % args[0]) + sys.exit(2) + if o == '-H' or o == '--host': + sys.stderr.write('Sorry. The MacAthena attach program does not keep an attachtab\n') + sys.exit(1) + +exit_code = 0 + +for arg in args: + try: + os.stat('/mit/%s' % arg) + os.system('/usr/bin/aklog /mit/%s' % arg) + except OSError: + sys.stderr.write('%s: Locker unknown\n' % arg) + exit_code = 2 + if noise_level == 'verbose': + filsys = hesiod.FilsysLookup(args[0]) + print 'attach: %s attached to /mit/%s for filesystem %s' % (filsys.getFilsys()[0]['location'], arg, arg) + elif noise_level == 'path': + print '/mit/%s' % arg + elif noise_level == 'lookup': + print '%s resolves to:' % arg + os.system('hesinfo %s filsys' % arg) + +sys.exit(exit_code) Index: trunk/scripts/machtype =================================================================== --- trunk/scripts/machtype (revision 8) +++ trunk/scripts/machtype (revision 8) @@ -0,0 +1,88 @@ +#!/usr/bin/env python + +from commands import getoutput +import os +import sys +import getopt + +usage = """Usage: machtype [-cdrvACELMNPS] +""" + +try: + optlist, args = getopt.getopt(sys.argv[1:], 'cdkmrvACELMNPS') +except getopt.GetoptError: + sys.stderr.write(usage) + sys.exit(1) + +optdict = dict(optlist) + +verbose = False +printed = False + +darwin_version = int(getoutput('uname -r').split('.')[0]) * 10 + +if optdict.has_key('-v'): + # -v : more verbose -- about memory mainly + verbose = True + +# -A : print Athena Release +if optdict.has_key('-A'): + if verbose: + print 'Machtype version: ', + print '9.4' + printed = True + +# -P : print out Athena System packs (from /srvd/.rvdinfo) +if optdict.has_key('-P'): + sys.stderr.write('MacAthena does not use system packs.\n') + printed = True + +# -L : version of athena from /etc/athena/version +if optdict.has_key('-L'): + version = file('/etc/athena/version').readlines()[-1].strip() + if verbose: + print version + else: + print version.split(' ')[4] + printed = True + +# -N : print out the name of the base OS +if optdict.has_key('-N'): + if verbose: + print getoutput('uname -sr') + else: + print getoutput('uname -s') + printed = True + +# -E : print out the version of the Base OS +if optdict.has_key('-E'): + print getoutput('uname -r') + printed = True + +# -S : Print out the Athena System name +#if optdict.has_key('-S'): + +# -C : print out compatible Athena System names +#if optdict.has_key('-C'): + +# -c : Processor type +if optdict.has_key('-c'): + if verbose: + print '%s on %s' % (getoutput('uname -sr'), getoutput('uname -m')) + else: + print getoutput('uname -m') + printed = True + +# -d : display type +if optdict.has_key('-d'): + print getoutput('system_profiler SPDisplaysDataType').split('\n')[2].strip(" :") + printed = True + +# -r : disk drive type +#if optdict.has_key('-r'): + +# -M : physical memory +#if optdict.has_key('-M'): + +if not printed: + print "darwin"