-
Notifications
You must be signed in to change notification settings - Fork 12
/
config-sample.py
68 lines (59 loc) · 2.9 KB
/
config-sample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# This is a sample configuration for sshfsexec.
# This part of the configuration is processed before any of the arguments are
# translated. The variable `sshlogin` will not yet be determined (read: set to
# `None`) if the command was not executed within an SSHFS mount, and the
# transargs variable will not yet be defined.
if pre_process_config:
translate_all_arguments = True
coerce_remote_execution = True
# This part of the configuration file is processed after translating the
# arguments to remote paths as needed.
else:
# Parse out the username and host from sshlogin.
if sshlogin and '@' in sshlogin:
user, server = sshlogin.split('@')
else:
user = None
server = sshlogin
# Ensure daemon / service control commands are run as root
if command == 'service':
sshlogin = 'root@%s' % server
# If stdin is a pipe, then force grep and sed to run locally since running
# them remotely with piped data would only slow things down.
elif command in ('grep', 'egrep', 'fgrep', 'sed') and stdin_is_pipe:
sshlogin = None
# ls(1) and grep(1) use isatty on stdout to determine whether or not to
# display colors. To make `ls --color=auto` and `grep --color` display
# colors at the end of a pipe series, preserve_isatty must be set since
# sshfsexec would otherwise only allocate a TTY if both stdin and stdout
# where TTY's.
elif command == 'ls':
preserve_isatty = True
# The server with the hostname "build-slave" should be used by make to do
# everything remotely except for installation; the finished product gets
# installed locally, but compilation takes place remotely.
elif command == 'make' and server == 'build-slave':
if 'install' in originalargs:
# Set sshlogin to None to execute "make install" locally.
sshlogin = None
# CentOS 5 does not have a terminfo file for screen-256color, so set the
# TERM environment variable to "screen" for the servers running CentOS 5.
centos5 = ('example.com', 'server.tld', 'router.lan')
if environment.get('TERM') == 'screen-256color' and server in centos5:
environment['TERM'] = 'screen'
# Depending on which directory or repo I'm in, the git config may not have
# my information on work servers.
workservers = ('work.company.tld', 'boxen.company.tld')
if command == 'git' and server in workservers:
envpassthrough = {
'GIT_AUTHOR_EMAIL': '[email protected]',
'GIT_AUTHOR_NAME': 'Eric Pruitt',
'GIT_COMMITTER_EMAIL': '[email protected]',
'GIT_COMMITTER_NAME': 'Eric Pruitt',
}
# If I specify something like GIT_AUTHOR_NAME locally, I want it to take
# precedence over the default envpassthrough value above.
for key in envpassthrough:
if key in os.environ:
envpassthrough[key] = os.environ[key]