def destroyVm(self, n): vmPath = getPath() + 'root' + str(n) if os.path.isdir(vmPath): # Umount and remove for d in settings.js["mount_dirs"].keys(): execute('sudo umount ' + vmPath + "/" + d) execute('sudo rm -R ' + vmPath)
async def restartServer(self): """ Updates with remote and restarts the server """ execute("git fetch && git pull") await self.close() os.execv(executable, [executable, __file__]) exit()
def getLastCommitInfo(self): """ Gets the last commit info """ execute( 'git log --pretty=format:"%h - %an, %ar : %s" | head -n 1 > .lastcommit' ) execute('git log --pretty=format:"%H" >> .lastcommit') r = readFile(".lastcommit") os.remove(".lastcommit") return r.split("\n")
def destroyAllScreens(self): execute("screen -ls | grep '" + settings.js["screen_prefix"] + "' | awk '{print $1}' | xargs -I % -t screen -X -S % quit")
def createVm(self, n): vmPath = getPath() + 'root' + str(n) self.destroyVm(n) execute('mkdir ' + vmPath) for d in self.mount_dirs.keys(): execute('mkdir ' + vmPath + "/" + d) execute("sudo mount --bind " + self.mount_dirs[d] + " " + vmPath + "/" + d) for d in self.other_dirs: execute('mkdir ' + vmPath + "/" + d) execute('sudo chown ' + settings.js["chroot_username"] + ' ' + vmPath + "/" + d) execute('sudo chmod ug=rwx ' + vmPath + "/" + d)
def execute(self, code): box.execute(code)