def save(self, dir_path): """ create a excutabel file. """ path = dir_path+self.id osapi.create_excuteablefile(path, self.data) for subscript in self.get_subscripts(): subscript.save(dir_path)
def checkout_scripts(self, scripts): """ storage the content of the scripts to temp dir, and write the script fiel path down to startup file will excute. @param scripts Script """ self._init_tmpdir() self._copy_env_files () excute_entries = [ '#!/bin/bash\n' 'set -x\n' 'cd '+self.tmp_dirname+'\n' 'apt-get update\n\n' 'source global-env.sh\n' 'source user-env.sh\n' ] for script in scripts: excute_entries.append("%s/%s\n" % (self.tmp_dirname, script.id)) script.save(self.tmp_dirname+'/') excute_entries.append("chown -R $REAL_USER: $REAL_HOME\n") startup_file = osapi.create_excuteablefile(path=self.startup_path) startup_file.writelines(excute_entries)
def checkout_scripts(self, scripts): """ storage the content of the scripts to temp dir, and write the script fiel path down to startup file will excute. @param scripts Script """ self._init_tmpdir() excute_entries = [ '#!/bin/bash\n' 'cd '+self.tmp_dirname+'\n' + syscmds.refresh_cmd + '\n' ] for script in scripts: excute_entries.append("%s/%s\n" % (self.tmp_dirname, script.id)) script.save(self.tmp_dirname+'/') excute_entries.append("chown -R ${REAL_USER}:${REAL_HOME} &> /dev/null\n") startup_file = osapi.create_excuteablefile(self.startup_path) startup_file.writelines(excute_entries)