def main(): logger = create_logger(PurePath(__file__).stem) logger.info('Starting rpcbind.') Popen(['rpcbind', '-w']).pid logger.info(run(['rpcinfo'], capture_output=True).stdout) Popen(['rpc.idmapd']).pid Popen(['rpc.gssd', '-v']).pid Popen(['rpc.statd']).pid logger.info('Starting rpc.nfsd.') Popen([ 'rpc.nfsd', ' --debug', '8', '--no-udp', '--no-nfs-version', '2', '--no-nfs-version', '3' ]).pid logger.info('Starting exportfs.') Popen(['exportfs', '-rv']).pid logger.info(run(['exportfs'], capture_output=True).stdout) logger.info('Starting rpc.mountd.') run([ 'rpc.mountd', '--foreground', '--no-nfs-version', '3', '--no-nfs-version', '2', '--debug', 'all', '--no-udp' ])
def main(): logger = create_logger(PurePath(__file__).stem) logger.setLevel(INFO) distutils.log = logger base_backup_name = getenv('BACKUP_NAME', 'minecraft-vanillaplusplus-backup') date_stamp = datetime.now().strftime("%G-W%V-%u-%H-%M-%S") backup_name = f'{base_backup_name}-{date_stamp}.tar.xz' create_backup_path = f'/mnt/{backup_name}' backup_path = '/mnt/source/' final_backup_destination = f'/mnt/backups/{backup_name}' temp_path = '/mnt/tmp/' try: remove_tree(temp_path) except FileNotFoundError: pass copy_tree(backup_path, temp_path) logger.info('Creating Backup') with tar_open(create_backup_path, 'w:xz') as tar: tar.add(f'{temp_path}.', arcname='') logger.info('Moving Backup') move(create_backup_path, final_backup_destination) logger.info('Successfully executed cron job')
def main(): logger = create_logger(PurePath(__file__).stem) timezone = getenv('TIMEZONE', None) if not timezone: try: ip_address = urlopen('https://canhazip.com/').read().decode( 'utf-8') web_text = urlopen( f'http://ip-api.com/json/{ip_address}').read().decode('utf-8') timezone = json_load(web_text).get('timezone', 'Etc/UTC') except: logger.debug( 'Unable to automatically divine timezone leaving set to UTC') sys_exit() if timezone: timezone_path = f'/usr/share/zoneinfo/{timezone}' if not path_exists(timezone_path): logger.debug( 'Timezone {timezone} does not seem to be installed on this system.' ) sys_exit() local_time_path = '/etc/localtime' if path_exists(local_time_path): delete_file(local_time_path) symlink(timezone_path, local_time_path) logger.info(f'Timezone {timezone} has been set sucessfully.')
def stop_container(_signal_number, _stack_frame): logger = create_logger(PurePath(__file__).stem) logger.info('Stopping Container.') system('exportfs -uav') system('rpc.nfsd 0') sleep(1) sys_exit(0)
def main(): logger = create_logger(Path(__file__).stem) if Path('/mnt/config/var_lib_samba').exists(): logger.info(f'Linking Samba Config to Mounted Config.') system('rm -rf /var/lib/samba') system('cp -rf /mnt/config/var_lib_samba /var/lib/samba ') else: logger.info(f'Copying Samba Config to Mounted Config.') system('cp -rf /var/lib/samba /mnt/config/var_lib_samba')
def main(): logger = create_logger(PurePath(__file__).stem) if not getenv('SPIGOT_SKIP_BACKUP', 'False').lower() in ['true', 't', 'y', 'yes', '1']: logger.info('Creating Backup') date_stamp = datetime.now().strftime("%G-W%V-%u-%H-%M-%S") with tar_open(f'/mnt/minecraft/spigot-backup-{date_stamp}.tar.lzma', 'w:xz') as tar: tar.add('/mnt/minecraft/.')
def main(): logger = create_logger(PurePath(__file__).stem) config.load_incluster_config() configuration = Configuration() configuration.verify_ssl = False configuration.assert_hostname = False urllib3.disable_warnings() Configuration.set_default(configuration) api = core_v1_api.CoreV1Api() label_selector = getenv('LABEL_SELECTOR', 'role=greyhole') namespace = getenv('NAMESPACE', 'storage') command_switch = getenv('COMMAND_SWITCH', '') k8s_response = api.list_namespaced_pod(namespace=namespace, label_selector=label_selector) logger.info(f'ENV Commands {label_selector} {namespace} {command_switch}') logger.debug(f'{k8s_response}') for pod in k8s_response.items: name = pod.metadata.name k8s_response = api.read_namespaced_pod(name=name, namespace=namespace) exec_command = ['/bin/sh', '-c'] if command_switch.lower() == 'monthly': exec_command.append('greyhole --fsck --checksums') elif command_switch.lower() == 'weekly': exec_command.append( 'greyhole --fsck --dont-walk-metadata-store --disk-usage-report' ) elif command_switch.lower() == 'daily': exec_command.append( 'greyhole --fsck --if-conf-changed --dont-walk-metadata-store') else: exec_command.append('greyhole --process-spool --keepalive') k8s_response = stream(api.connect_get_namespaced_pod_exec, name, namespace, command=exec_command, stderr=True, stdin=False, stdout=True, tty=False) logger.info(f'Cleanup {name}: {k8s_response}') logger.info(f'Successfully executed cron job')
def main(): logger = create_logger(Path(__file__).stem) if not getenv('SPIGOT_SKIP_BUILD', 'False').lower() in ['true', 't', 'y', 'yes', '1']: logger.info('Downloading BuildTools') url = 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar' urlretrieve(url, '/minecraft/BuildTools.jar') spigot_version = getenv('SPIGOT_VERSION', None) logger.info(f'Running Build Tools for version {spigot_version}') system(f'cd /minecraft && java -jar BuildTools.jar --rev {spigot_version}') system('rm -f /mnt/minecraft/spigot-server.jar') system('mv /minecraft/spigot*.jar /mnt/minecraft/spigot-server.jar') system('rm -rf /minecraft/*') if not Path("/mnt/minecraft/start_spigot.sh").is_file(): system('mv /scripts/start_spigot.sh /mnt/minecraft/start_spigot.sh')