def fn_upload_api(self): home = os.path.expanduser("~") cum = functions.upload_file( settings.getParam("settings_path"), "/home/{}/.workspace.json".format(settings.getParam("user"))) cum = cum and functions.upload_file( home + "/.bucket", "/home/{}/.bucket".format( settings.getParam("user"))) cmd_api = 'echo ' + settings.getParam('id') + ':' + settings.getParam( 'key' ) + ' | sudo tee /etc/passwd-s3fs;sudo chmod 600 /etc/passwd-s3fs' cum = cum and functions.run_script(cmd_api) # cum = cum and functions.run_script('mkdir ~/.aws') # cum = cum and functions.upload_file(home + "/.aws/config", "/home/{}/.aws/config".format(settings.getParam("user"))) # cum = cum and functions.upload_file(home + "/.aws/credentials", "/home/{}/.aws/credentials".format(settings.getParam("user"))) cum = cum and functions.run_script( 'aws configure set aws_access_key_id ' + settings.getParam("id")) cum = cum and functions.run_script( 'aws configure set aws_secret_access_key ' + settings.getParam("key")) cum = cum and functions.run_script( 'aws configure set default.region ' + settings.getParam("region")) if cum: msgBox = QMessageBox() msgBox.setText("Executed Correctly") else: msgBox = QMessageBox() msgBox.setText("Failed") msgBox.exec_()
def fn_save(self): settings = SettingsManager.settingsManager() user = settings.getParam("user") cmd = 'echo "{}:{}" | sudo chpasswd'.format(user, self.pwd.text()) print(cmd) functions.run_script(cmd) self.close()
def fm_connect(self): ec2_id = settings.getParam('ec2_id') ec2 = self.session.resource("ec2", use_ssl=False) i = ec2.Instance(id=ec2_id) cmd_limpiar = 'cat /etc/fstab | sudo grep -v {} | sudo tee /etc/fstab.tmp'.format( self.combo_bucket.currentText()) cmd_move = 'sudo mv /etc/fstab.tmp /etc/fstab' cmd_fstab = 'echo s3fs#{bucket} /mnt/{bucket} fuse ' \ '_netdev,uid={user},allow_other,umask=002,endpoint={region} 0 0 ' \ '| sudo tee -a /etc/fstab;'.format(bucket = self.combo_bucket.currentText(), region = self.region, user = self.user) cmd_mount = 'sudo mkdir /mnt/{bucket};sudo mount /mnt/{bucket}'.format( bucket=self.combo_bucket.currentText()) result = functions.run_script(cmd_limpiar) result = result and functions.run_script(cmd_move) result = result and functions.run_script(cmd_fstab) result = result and functions.run_script(cmd_mount) msgBox = QMessageBox() if result: msgBox.setText("Executed Correctly") else: msgBox.setText("Failed") msgBox.exec_() self.close()
def fn_save(self): settings = SettingsManager.settingsManager() settings.setParam("user", self.user.text()) settings.writeParams() cmd = 'useradd {} -m -G wheel'.format(self.user.text()) print(cmd) functions.run_script(cmd) self.close()
def fm_connect(self): settings = SettingsManager.settingsManager() cmd_limpiar = 'cat /etc/fstab | grep -v {} > /etc/fstab.tmp;'.format( self.combo_bucket.currentText()) cmd_move = 'mv /etc/fstab.tmp /etc/fstab;' cmd_fstab = 'echo s3fs#{bucket} /home/{user}/{bucket} fuse ' \ '_netdev,uid={user},allow_other,umask=002,endpoint={region} 0 0 ' \ '>> /etc/fstab;'.format(bucket = self.combo_bucket.currentText(), region = self.region, user = self.user) cmd_api = 'echo '+self.api_access + ':' + self.api_secret+' > /etc/passwd-s3fs;' \ 'chmod 640 /etc/passwd-s3fs;' cmd_mount = 'mkdir /home/{user}/{bucket};mount /home/{user}/{bucket}'.format( bucket=self.combo_bucket.currentText(), user=self.user) cmd = cmd_limpiar + cmd_move + cmd_fstab + cmd_api + cmd_mount print(cmd) functions.run_script(cmd) self.close()
def fn_save(self): session = settings.getSession() ec2_id = settings.getParam('ec2_id') ec2 = session.resource("ec2", use_ssl=False) i = ec2.Instance(id=ec2_id) settings.setParam("ec2_passwd", self.pwd_old.text()) cmd = 'echo "{}:{}" | sudo chpasswd'.format(settings.getParam("user"), self.pwd_new.text()) print(cmd) result = functions.run_script(cmd) msgBox = QMessageBox() if result: settings.setParam("ec2_passwd", self.pwd_new.text()) settings.writeParams() msgBox.setText("Executed Correctly") else: msgBox.setText("Failed!") msgBox.exec_() self.close()
def fn_reset(self): functions.run_script(self.i, 'reboot')