def _set_directory_permissions(username): do_or_die('chown -R %s:%s \'%s\'' % (username, username, _LogPath)) _logger.info( 'recursively changed owner of [%s] to %s:%s' % (_LogPath, username, username) ) do_or_die('chmod -R 744 \'%s\'' % _LogPath) _logger.info('recursively set mod to 744 on [%s]' % _LogPath)
def _add_user(self): olduid = self._read_old_uid() do_or_die( "useradd %s -d '/home/%s' -mp '%s' -K PASS_MAX_DAYS=-1 -K UMASK=0133 %s" % ( '' if None is olduid else ('-u %d' % olduid), self.username, _gen_phrase(), self.username ) ) self.uid = pwd.getpwnam(self.username).pw_uid self._write_old_uid(self.uid) _logger.info('created user [%s] ([%d])' % (self.username, self.uid))
def update_rlink(self, path, name): path = path.strip().strip('/') rlinkpath, rlinkmetafile = self._get_valid_rlink_for_update(path, name) with _RepoLock(rlinkpath): # should not fail at this point if rlinkmetafile.target == path: raise ArgumentError('existing and specified targets are the same') releasepath = os.path.join(self.path, path) rlinkbin = os.path.join(rlinkpath,'bin') do_or_die( 'rm %s && ln -s %s %s' % (rlinkbin, os.path.join(releasepath,'bin'), rlinkbin) ) # TODO: this should be an option at the command line do_or_die('find %s/ | egrep -v \'^%s/$\' | xargs touch' % (rlinkbin, rlinkbin)) rlinkmetafile.update(path) rlinkmetafile.save(rlinkpath)
def _delete_user(self): do_or_die('userdel %s' % self.username) _logger.info('deleted user [%s] ([%d])' % (self.username, self.uid)) del self.uid self.initialized = False
def install(self, path, artifactpath): path = path.strip().strip('/') artifactpath = artifactpath.strip().strip('/') target, src = self._get_valid_paths_for_install(path, artifactpath) do_or_die('rsync -r --delete --force %s/ %s' % (src, target))
def _claim_repo(path): # TODO: move evolve user and group to a constant somewhere # (or get name from os.geteuid()) do_or_die('sudo chown evolve:evolve ' + path)
path = path.strip().strip('/') parent, metafile = self._get_valid_project_parent_path(path) fullpath = os.path.join(self.path, path) projects = fullpath.replace(parent + '/', '').split('/') try: with _RepoLock(parent): self._create_project(parent, projects) metafile.projects.append(projects[0]) metafile.save(parent) except _RepoLock.LockError, ex: raise RepoError('parent at [%s] is locked' % parent) except BaseException, ex: firstproject = os.path.join(parent, projects[0]) if os.path.exists(firstproject): do_or_die('rm -rf ' + firstproject) raise self.logger.info('created project [%s]' % path) def create_release(self, path): path = path.strip().strip('/') project, metafile, release = self._get_valid_project_and_release(path) try: with _RepoLock(project): self._create_release(project, release) metafile.releases.append(release) metafile.save(project) except _RepoLock.LockError, ex: raise RepoError('project at [%s] is locked' % project)