def _install_server_rc(self): """Install a server init script. The Transarc-style distributions provide a single init script which optionally starts the bosserver. This is an historical relic left over from the pre-namei fileserver days. Instead, install a simple, separate init script to start and stop the bosserver. Does not configure the system to run the init script automatically on reboot. """ text = afsutil.resources['openafs-server.init'] dst = "/etc/init.d/openafs-server" if os.path.exists(dst) and not self.force: raise AssertionError("Refusing to overwrite '%s'.", dst) with open(dst, 'w') as f: f.write(text) os.chmod(dst, 0755) mkdirp("/var/lock/subsys/") # needed by the init script # Set the bosserver command line options. dst = path_join(SYSCONFIG, "openafs-server") logger.info("Writing bosserver startup options to file '%s'." % (dst)) mkdirp(os.path.dirname(dst)) with open(dst, 'w') as f: f.write('BOSSERVER_OPTIONS="%s"\n' % (self.options.get('bosserver', '')))
def install_afsd(self, afsd): """Install the afsd file.""" # Common for linux an solaris. src = afsd dst = AFS_KERNEL_DIR logger.info("Installing afsd from '%s' to '%s'.", src, dst) mkdirp(dst) shutil.copy2(src, dst) os.chmod(dst, 0755)
def _install_openafs_ko(self, kmod): """Install the openafs.ko file and run depmod.""" release = os.uname()[2] src = kmod dst = path_join("/lib/modules", release, "extra/openafs/openafs.ko") logger.info("Installing kernel module from '%s' to '%s'.", src, dst) mkdirp(os.path.dirname(dst)) shutil.copy2(src, dst) sh('/sbin/depmod', '-a')
def write(self, path): logger.debug("Writing keytab %s", path) mkdirp(os.path.dirname(path)) with open(path, 'w') as f: self._write(f, '!h', self._KRB_KEYTAB_MAGIC) for k in self.entries: self._write_entry(f, k) self.filename = path return self
def _create_tarball(tarball=None, program=None): sysname = _detect_sysname() if sysname is None: raise AssertionError("Cannot find sysname.") if tarball is None: tardir = 'packages' if not os.path.isdir(tardir): mkdirp(tardir) tarball = os.path.join(tardir, "openafs-%s.tar.gz" % (sysname)) tar(tarball, sysname, tar=program) logger.info("Created tar file %s", tarball)
def _install_client(self): """Install client binaries.""" logger.info("Installing client binaries") src = path_join(self.dest, "root.client", AFS_KERNEL_DIR) copy_files(src, AFS_KERNEL_DIR, force=self.force) # also installs libafs.ko self._install_workstation_binaries() # including libs, unless already installed self.client_setup.install_driver(self.dest) self.client_setup.install_init_script(self.dest, self.options.get('afsd', '')) mkdirp(AFS_MOUNT_DIR) mkdirp(AFS_CACHE_DIR) self.installed['client'] = True logger.info("Client installed.")
def _set_cell_config(self, path, cell, hosts, ext=""): """Write a default CellServDB and ThisCell file.""" # The bosserver creates symlinks for the client side configuration. Be # sure to remove the symlinks so we do not clobber the server # configuration. mkdirp(path) os.chmod(path, 0755) # Make the bosserver happy. cellservdb = os.path.join(path, "CellServDB%s" % (ext)) thiscell = os.path.join(path, "ThisCell") if os.path.islink(cellservdb): os.remove(cellservdb) if os.path.islink(thiscell): os.remove(thiscell) with open(cellservdb, 'w') as f: f.write(">%s #Cell name\n" % (cell)) for addr,name in hosts: f.write("%s #%s\n" % (addr,name)) with open(thiscell, 'w') as f: f.write(cell)
def install_init_script(self, dest, afsd_options): """Install a client init script on linux. Does not configure the system to run the init script automatically on reboot. """ # Install the init script. mkdirp("/var/lock/subsys/") text = afsutil.resources['openafs-client-linux.init'] dst = "/etc/init.d/openafs-client" logger.info("Installing client init script from to '%s'.", dst) with open(dst, 'w') as f: f.write(text) os.chmod(dst, 0755) # Set afsd options. dst = path_join(SYSCONFIG, "openafs-client") logger.info("Writing afsd startup options to file '%s'." % (dst)) mkdirp(os.path.dirname(dst)) with open(dst, 'w') as f: f.write('AFSD_OPTIONS="%s"\n' % (afsd_options))
def install_init_script(self, dest, afsd_options): """Install a client init script on solaris. Does not configure the system to run the init script automatically on reboot. Changes the init script to avoid starting the bosserver by default.""" osrel = os.uname()[2] text = afsutil.resources['openafs-client-solaris-%s.init' % (osrel)] dst = "/etc/init.d/openafs-client" logger.info("Installing client init script to '%s'.", dst) with open(dst, 'w') as f: f.write(text) os.chmod(dst, 0755) # Set afsd options. config = '/usr/vice/etc/config' dst = path_join(config, 'afsd.options') logger.info("Writing afsd startup options to file '%s'." % (dst)) mkdirp(os.path.dirname(dst)) with open(dst, 'w') as f: f.write(afsd_options) # Not sourced.