コード例 #1
0
    def install(self) -> bool:
        logger.info('Creating Linux Service...')
        lines = self.create_service()
        with open(self.service_file, "w") as file:
            file.writelines(lines)

        logger.info('Soft Un-linking Linux Service...')
        try:
            os.unlink(self.symlink_service_file)
        except FileNotFoundError as e:
            logger.info(str(e))

        logger.info('Soft Linking Linux Service...')
        os.symlink(self.service_file, self.symlink_service_file)

        logger.info('Hitting daemon-reload...')
        if not execute_command('systemctl daemon-reload'):
            return False

        logger.info('Enabling Linux Service...')
        if not execute_command('systemctl enable {}'.format(
                self.service_file_name)):
            return False
        """
        Some of the services takes time, coz we have sleep at starting
        So leave it on background
        """
        logger.info('Starting Linux Service...')
        gevent.spawn(execute_command,
                     'systemctl restart {}'.format(self.service_file_name))

        logger.info('Successfully started service')
        return True
コード例 #2
0
 def uninstall(self) -> bool:
     logger.info('Stopping OpenVPN Service...')
     if not execute_command('systemctl disable openvpn@client && systemctl stop openvpn@client'):
         return False
     logger.info('Removing OpenVPN service...')
     if not execute_command('apt-get remove openvpn -y'):
         return False
     logger.info('OpenVPN Service is deleted.')
     return True
コード例 #3
0
 def install(self) -> bool:
     logger.info('Hitting apt-get update...')
     execute_command('apt-get update --allow-releaseinfo-change')
     logger.info('Installing OpenVPN Service...')
     if not execute_command('apt-get install openvpn -y'):
         return False
     logger.info('Successfully installed OpenVPN service')
     if not execute_command('systemctl enable openvpn@client'):
         return False
     return True
コード例 #4
0
 def stop(self) -> bool:
     logger.info('Stopping Linux Service...')
     if not execute_command('systemctl stop {}'.format(
             self.service_file_name)):
         return False
     logger.info('Successfully stopped service.')
     return True
コード例 #5
0
    def uninstall(self) -> bool:
        logger.info('Stopping Linux Service...')
        if not execute_command('systemctl stop {}'.format(
                self.service_file_name)):
            return False

        logger.info('Un-linking Linux Service...')
        try:
            os.unlink(self.symlink_service_file)
        except FileNotFoundError as e:
            print(str(e))

        logger.info('Removing Linux Service...')
        delete_file(self.service_file)

        logger.info('Hitting daemon-reload...')
        if not execute_command('systemctl daemon-reload'):
            return False
        logger.info('Service is deleted.')
        return True
コード例 #6
0
 def uninstall(self) -> bool:
     uninstall_cmd: str = "bash script.bash delete"
     return execute_command(uninstall_cmd, self.get_cwd())
コード例 #7
0
 def install(self) -> bool:
     install_cmd: str = f"bash script.bash install -s={self.service_file_name} -u=root " \
                        f"--working-dir={self.get_wd()} -g={self.get_global_dir()} -d=data -c=config -p {self.port}"
     return execute_command(install_cmd, self.get_cwd())
コード例 #8
0
 def restart(self) -> bool:
     logger.info('Restarting Linux Service...')
     if not execute_command(f'systemctl restart {self.service_file_name}'):
         return False
     logger.info('Successfully restarted service.')
     return True