import time import click from runutils import runbash, ensure_user, get_user_ids USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('trac', 9876) @click.group() def run(): ensure_user(USER_NAME, USER_ID, GROUP_NAME, GROUP_ID) @run.command() @click.argument('user', default=USER_NAME) def bash(user): runbash(user) @run.command() def start(): while True: time.sleep(1) if __name__ == '__main__': run()
import subprocess import time import os import sys import click from runutils import ensure_user, get_user_ids, runbash, getvar, setuser USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('lexer-tester', 1000) @click.group() def run(): ensure_user(USER_NAME, USER_ID, GROUP_NAME, GROUP_ID) # PIP_COMMAND = getvar('PIP_COMMAND') # subprocess.call([PIP_COMMAND, 'install', '/pygments-lexer-babylon']) os.chdir('/pygments-lexer-babylon') @run.command() @click.argument('user', default=USER_NAME) def shell(user): runbash(user) @run.command() def generate(): PIP_COMMAND = getvar('PIP_COMMAND') subprocess.call([PIP_COMMAND, 'install', '/pygments-lexer-babylon']) PYTHON_COMMAND = getvar('PYTHON_COMMAND')
import subprocess import click from runutils import runbash, ensure_user, get_user_ids, setuser USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('dev', 1000) @click.group() def run(): ensure_user(USER_NAME, USER_ID, GROUP_NAME, GROUP_ID) @run.command() @click.argument('user', default=USER_NAME) def bash(user): runbash(user) @run.command() def start(): cwd = '/var/lib/data' texfile = 'input/test.tex' output_directory = 'output' cmd = ['lualatex', '--output-directory=%s' % output_directory, texfile] preexec_fn = setuser(USER_NAME) subprocess.call(cmd, preexec_fn=preexec_fn, cwd=cwd)
import click from runutils import runbash, ensure_user, get_user_ids USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('nodejs', 8080) DEFAULT_USERNAME = USER_NAME or 'root' @click.group() def run(): ensure_user(USER_NAME, USER_ID, GROUP_NAME, GROUP_ID) @run.command() @click.argument('user', default=DEFAULT_USERNAME) def shell(user): runbash(user) @run.command() def start(): pass if __name__ == '__main__': run()
import subprocess import signal import hashlib from contextlib import contextmanager import re import time import click import psycopg2 from runutils import (runbash, ensure_user, get_user_ids, getvar, ensure_dir, call, copyfile, substitute, run_daemon, setuser, run_cmd, Stopper) USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('postgres', 5432) PGDATA = getvar('PGDATA') PGDATA_PARENT = os.path.split(PGDATA)[0] SOCKET_DIR = getvar('SOCKET_DIR') PG_MAJOR = getvar('PG_MAJOR') MAIN_USER_PWD = getvar('MAIN_USER_PWD') CONF_BASE = '/usr/share/postgresql/%s/%%s' % PG_MAJOR CONF_FILE = CONF_BASE % 'postgresql.conf' HBA_FILE = CONF_BASE % 'pg_hba.conf' START_POSTGRES = ['postgres', '-c', 'config_file=%s' % CONF_FILE] SEMAPHORE = getvar('SEMAPHORE', required=False) BACKUP_DIR = getvar('BACKUP_DIR') if SEMAPHORE: SEMAPHORE_PARENT = os.path.split(SEMAPHORE)[0] else:
import click from runutils import (getvar, runbash, get_user_ids, ensure_user, copyfile, substitute, run_daemon, ensure_dir, Stopper) USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('nginx', 8080) NGINX_CONF = getvar('NGINX_CONF') MIME_TYPES = getvar('MIME_TYPES', default='nginx_mime.types') STATIC_DIR = getvar('STATIC_DIR') # make sure STATIC_DIR ends with '/' STATIC_DIR = ('%s/' % STATIC_DIR).replace('//', '/') DJANGO_UPSTREAM = getvar('DJANGO_UPSTREAM', default='django:8000') UWSGI_PARAMS = getvar('UWSGI_PARAMS', required=False) SOCKET_DIR = getvar('SOCKET_DIR', default='') def _init(stopper): ensure_dir(STATIC_DIR, owner='root', group='root', permission_str='777') ensure_dir( SOCKET_DIR, owner='root', group='root', permission_str='777') # copy config files copyfile(NGINX_CONF, '/nginx.conf', owner=USER_NAME, group=GROUP_NAME, permission_str='400') copyfile(MIME_TYPES, '/nginx_mime.types', owner=USER_NAME, group=GROUP_NAME, permission_str='400') if UWSGI_PARAMS: copyfile(UWSGI_PARAMS, '/uwsgi_params', owner=USER_NAME, group=GROUP_NAME, permission_str='400')