├── rhel ├── 7 │ ├── mesos.postrm │ └── mesos.postinst ├── mesos.postinst └── mesos.postrm ├── centos ├── 6 │ ├── mesos.postrm │ └── mesos.postinst ├── 7 │ ├── mesos.postrm │ └── mesos.postinst ├── mesos.postinst └── mesos.postrm ├── redhat ├── 7 │ ├── mesos.postrm │ └── mesos.postinst ├── mesos.postinst └── mesos.postrm ├── default ├── mesos-slave ├── mesos └── mesos-master ├── fedora ├── mesos.postrm └── mesos.postinst ├── debian ├── 8 │ ├── mesos.postrm │ └── mesos.postinst ├── 9 │ ├── mesos.postrm │ └── mesos.postinst ├── mesos.postrm └── mesos.postinst ├── ubuntu ├── 15.04 │ ├── mesos.postrm │ └── mesos.postinst ├── mesos.postrm ├── 12.04 │ ├── mesos.postrm │ └── mesos.postinst └── mesos.postinst ├── .gitignore ├── Makefile ├── systemd ├── master.systemd └── slave.systemd ├── conf ├── upstart ├── slave.upstart └── master.upstart ├── init ├── master.init └── slave.init ├── copyright ├── README.md └── mesos-init-wrapper /rhel/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | 3 | -------------------------------------------------------------------------------- /centos/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | 3 | -------------------------------------------------------------------------------- /redhat/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | 3 | -------------------------------------------------------------------------------- /default/mesos-slave: -------------------------------------------------------------------------------- 1 | MASTER=`cat /etc/mesos/zk` 2 | -------------------------------------------------------------------------------- /centos/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /default/mesos: -------------------------------------------------------------------------------- 1 | LOGS=/var/log/mesos 2 | ULIMIT="-n 8192" 3 | 4 | -------------------------------------------------------------------------------- /fedora/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /redhat/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /rhel/7/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /rhel/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /centos/6/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /centos/7/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /debian/8/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /debian/9/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /default/mesos-master: -------------------------------------------------------------------------------- 1 | PORT=5050 2 | ZK=`cat /etc/mesos/zk` 3 | 4 | -------------------------------------------------------------------------------- /redhat/7/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /ubuntu/15.04/mesos.postrm: -------------------------------------------------------------------------------- 1 | #rm -rf /var/log/mesos /etc/mesos 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | mesos*.deb 3 | dist.tgz 4 | *.rpm 5 | *.egg 6 | mesos-repo 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: dist.tgz 2 | 3 | dist.tgz: 4 | git ls-files | xargs tar czf dist.tgz 5 | 6 | -------------------------------------------------------------------------------- /centos/7/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /debian/8/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /debian/9/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /fedora/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /redhat/7/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /rhel/7/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /ubuntu/15.04/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | systemctl enable mesos-master 3 | systemctl enable mesos-slave 4 | -------------------------------------------------------------------------------- /systemd/master.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Mesos Master 3 | After=network.target 4 | Wants=network.target 5 | 6 | [Service] 7 | ExecStart=/usr/bin/mesos-init-wrapper master 8 | Restart=always 9 | RestartSec=20 10 | LimitNOFILE=16384 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | -------------------------------------------------------------------------------- /centos/6/mesos.postinst: -------------------------------------------------------------------------------- 1 | ldconfig 2 | 3 | # Enable POSIX launcher if Mesos verion is strictly greater than 0.24 4 | _VERSION=$(mesos-slave --version|awk '{print $2}') 5 | IFS='.' read -a VERSION <<< "$_VERSION" 6 | if [ ${VERSION[0]} -gt 0 ] || [ ${VERSION[1]} -gt 24 ]; then 7 | echo posix > /etc/mesos-slave/launcher 8 | fi 9 | -------------------------------------------------------------------------------- /systemd/slave.systemd: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Mesos Slave 3 | After=network.target 4 | Wants=network.target 5 | 6 | [Service] 7 | ExecStart=/usr/bin/mesos-init-wrapper slave 8 | KillMode=process 9 | Restart=always 10 | RestartSec=20 11 | LimitNOFILE=16384 12 | CPUAccounting=true 13 | MemoryAccounting=true 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /conf: -------------------------------------------------------------------------------- 1 | # /etc/mesos/mesos.conf 2 | # 3 | # This file is used to set configuration options for the Mesos master and slave, 4 | # one per line, in the form of key = value pairs. For a list of available 5 | # options, please refer to the Mesos documentation, or run mesos-master and # mesos-slave with --help. 6 | 7 | -------------------------------------------------------------------------------- /ubuntu/mesos.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | purge) 7 | rm -rf /var/log/mesos /etc/mesos 8 | ;; 9 | 10 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 11 | ;; 12 | 13 | *) 14 | echo "postrm called with unknown argument \`$1'" >&2 15 | exit 1 16 | esac 17 | 18 | #DEBHELPER# 19 | 20 | exit 0 21 | 22 | -------------------------------------------------------------------------------- /ubuntu/12.04/mesos.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | case "$1" in 6 | purge) 7 | rm -rf /var/log/mesos /etc/mesos 8 | ;; 9 | 10 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 11 | ;; 12 | 13 | *) 14 | echo "postrm called with unknown argument \`$1'" >&2 15 | exit 1 16 | esac 17 | 18 | #DEBHELPER# 19 | 20 | exit 0 21 | 22 | -------------------------------------------------------------------------------- /upstart/slave.upstart: -------------------------------------------------------------------------------- 1 | description "mesos slave" 2 | 3 | # Start just after the System-V jobs (rc) to ensure networking and zookeeper 4 | # are started. This is as simple as possible to ensure compatibility with 5 | # Ubuntu, Debian, CentOS, and RHEL distros. See: 6 | # http://upstart.ubuntu.com/cookbook/#standard-idioms 7 | start on stopped rc RUNLEVEL=[2345] 8 | respawn 9 | 10 | exec /usr/bin/mesos-init-wrapper slave 11 | 12 | -------------------------------------------------------------------------------- /upstart/master.upstart: -------------------------------------------------------------------------------- 1 | description "mesos master" 2 | 3 | # Start just after the System-V jobs (rc) to ensure networking and zookeeper 4 | # are started. This is as simple as possible to ensure compatibility with 5 | # Ubuntu, Debian, CentOS, and RHEL distros. See: 6 | # http://upstart.ubuntu.com/cookbook/#standard-idioms 7 | start on stopped rc RUNLEVEL=[2345] 8 | respawn 9 | 10 | exec /usr/bin/mesos-init-wrapper master 11 | 12 | -------------------------------------------------------------------------------- /ubuntu/mesos.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | case "$1" in 5 | 6 | configure|abort-upgrade|abort-remove|abort-deconfigure) 7 | ;; 8 | 9 | *) 10 | echo "postinst called with unknown argument \`$1'" >&2 11 | exit 1 12 | ;; 13 | esac 14 | 15 | # TODO we should restart mesos-slave or master 16 | 17 | #run ldconfig in order to have available libmesos.so 18 | 19 | ldconfig 20 | 21 | 22 | #DEBHELPER# 23 | 24 | exit 0 25 | 26 | -------------------------------------------------------------------------------- /debian/mesos.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | purge) 7 | rm -rf /var/log/mesos /etc/mesos 8 | update-rc.d mesos-master remove 9 | update-rc.d mesos-slave remove 10 | ;; 11 | 12 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 13 | ;; 14 | 15 | *) 16 | echo "postrm called with unknown argument \`$1'" >&2 17 | exit 1 18 | esac 19 | 20 | #DEBHELPER# 21 | 22 | exit 0 23 | 24 | -------------------------------------------------------------------------------- /debian/mesos.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | case "$1" in 5 | 6 | configure) 7 | update-rc.d mesos-master defaults 8 | update-rc.d mesos-slave defaults 9 | ;; 10 | 11 | configure|abort-upgrade|abort-remove|abort-deconfigure) 12 | ;; 13 | 14 | *) 15 | echo "postinst called with unknown argument \`$1'" >&2 16 | exit 1 17 | ;; 18 | esac 19 | 20 | # TODO we should restart mesos-slave or master 21 | 22 | #run ldconfig in order to have available libmesos.so 23 | 24 | ldconfig 25 | 26 | 27 | #DEBHELPER# 28 | 29 | exit 0 30 | 31 | -------------------------------------------------------------------------------- /ubuntu/12.04/mesos.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | case "$1" in 5 | 6 | configure|abort-upgrade|abort-remove|abort-deconfigure) 7 | ;; 8 | 9 | *) 10 | echo "postinst called with unknown argument \`$1'" >&2 11 | exit 1 12 | ;; 13 | esac 14 | 15 | # TODO we should restart mesos-slave or master 16 | 17 | #run ldconfig in order to have available libmesos.so 18 | 19 | ldconfig 20 | 21 | # Enable POSIX launcher if Mesos verion is strictly greater than 0.24 22 | _VERSION=$(mesos-slave --version|awk '{print $2}') 23 | IFS='.' read -a VERSION <<< "$_VERSION" 24 | if [ ${VERSION[0]} -gt 0 ] || [ ${VERSION[1]} -gt 24 ]; then 25 | echo posix > /etc/mesos-slave/launcher 26 | fi 27 | 28 | #DEBHELPER# 29 | 30 | exit 0 31 | 32 | -------------------------------------------------------------------------------- /init/master.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: mesos-master 4 | # Required-Start: $local_fs $remote_fs $network $syslog 5 | # Required-Stop: $local_fs $remote_fs $network $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: starts the mesos master 9 | # Description: The Mesos master distributes computing tasks to slaves 10 | ### END INIT INFO 11 | set -ue 12 | 13 | NAME="mesos-master" 14 | DESC="mesos master" 15 | 16 | . /lib/lsb/init-functions 17 | 18 | PID=/var/run/mesos-master.pid 19 | 20 | start() { 21 | start-stop-daemon --start --background --quiet \ 22 | --pidfile "$PID" --make-pidfile \ 23 | --startas /usr/bin/mesos-init-wrapper -- master 24 | } 25 | 26 | stop() { 27 | start-stop-daemon --stop --quiet --pidfile "$PID" 28 | } 29 | 30 | case "$1" in 31 | start) 32 | echo -n "Starting $DESC: " 33 | start 34 | echo "$NAME." 35 | ;; 36 | stop) 37 | echo -n "Stopping $DESC: " 38 | stop 39 | echo "$NAME." 40 | ;; 41 | restart) 42 | echo -n "Restarting $DESC: " 43 | stop 44 | sleep 1 45 | start 46 | echo "$NAME." 47 | ;; 48 | status) 49 | status_of_proc -p "$PID" "$NAME" "$NAME" 50 | ;; 51 | *) 52 | echo "Usage: $0 {start|stop|restart|status}" >&2 53 | exit 1 54 | ;; 55 | esac 56 | 57 | -------------------------------------------------------------------------------- /init/slave.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: mesos-slave 4 | # Required-Start: $local_fs $remote_fs $network $syslog 5 | # Required-Stop: $local_fs $remote_fs $network $syslog 6 | # Should-Start: docker 7 | # Should-Stop: docker 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: starts the mesos slave 11 | # Description: The Mesos master slave performs computing tasks 12 | ### END INIT INFO 13 | set -ue 14 | 15 | NAME="mesos-slave" 16 | DESC="mesos slave" 17 | 18 | . /lib/lsb/init-functions 19 | 20 | PID=/var/run/mesos-slave.pid 21 | 22 | start() { 23 | start-stop-daemon --start --background --quiet \ 24 | --pidfile "$PID" --make-pidfile \ 25 | --startas /usr/bin/mesos-init-wrapper -- slave 26 | } 27 | 28 | stop() { 29 | start-stop-daemon --stop --quiet --pidfile "$PID" 30 | } 31 | 32 | case "$1" in 33 | start) 34 | echo -n "Starting $DESC: " 35 | start 36 | echo "$NAME." 37 | ;; 38 | stop) 39 | echo -n "Stopping $DESC: " 40 | stop 41 | echo "$NAME." 42 | ;; 43 | restart) 44 | echo -n "Restarting $DESC: " 45 | stop 46 | sleep 1 47 | start 48 | echo "$NAME." 49 | ;; 50 | status) 51 | status_of_proc -p "$PID" "$NAME" "$NAME" 52 | ;; 53 | *) 54 | echo "Usage: $0 {start|stop|restart|status}" >&2 55 | exit 1 56 | ;; 57 | esac 58 | 59 | -------------------------------------------------------------------------------- /copyright: -------------------------------------------------------------------------------- 1 | Format: http://dep.debian.net/deps/dep5 2 | Upstream-Name: mesos 3 | Source: 4 | 5 | Files: * 6 | Copyright: 2012 The Apache Foundation 7 | License: Apache-2.0 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | . 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | . 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | . 20 | On Debian systems, the complete text of the Apache version 2.0 license 21 | can be found in "/usr/share/common-licenses/Apache-2.0". 22 | 23 | Files: third_party/boost*, third_party/libprocess/third_party/boost* 24 | License: Boost 25 | 26 | Files: third_party/glog*, third_party/gmock*, third_party/protobuf* 27 | Copyright: 2008 Google Inc. 28 | License: BSD-2-Clause 29 | 30 | Files: third_party/leveldb* 31 | Copyright: 2011 The LevelDB Authors. 32 | License: BSD-2-Clause 33 | 34 | Files: third_party/libprocess/third_party/libev* 35 | Copyright: 2007-2009 Marc Alexander Lehmann 36 | License: Expat 37 | 38 | Files: third_party/libprocess/third_party/ry-http* 39 | Copyright: 2009-2010 Ryan Dahl; Joyent, Inc.; and other Node contributors 40 | License: BSD-2-Clause 41 | 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apache Mesos Packaging 2 | 3 | Build scripts to create Apache Mesos packages with [FPM](https://github.com/jordansissel/fpm) for simple installation in a cluster. 4 | 5 | Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications, or frameworks. It can run Hadoop, MPI, Hypertable, Spark (a new framework for low-latency interactive and iterative jobs), and other applications. Currently is in the Apache Incubator and going through rapid development, though stable enough for a production usage. See [Mesos website](http://incubator.apache.org/mesos/) for more details. 6 | 7 | ## Packaging Requirements 8 | 9 | ```bash 10 | sudo apt-get install ruby ruby-dev python-dev autoconf automake git make libssl-dev libcurl3 libtool 11 | sudo gem install fpm 12 | ``` 13 | 14 | ## Mesos Requirements 15 | 16 | Mesos has its own OS-level build requirements that need to be installed as well before building. 17 | 18 | See [getting-started](https://mesos.apache.org/getting-started/) for more information. 19 | 20 | 21 | ## Setting the Maintainer 22 | 23 | define in e.g. `~/.bash_profile` a `MAINTAINER` variable 24 | 25 | ```bash 26 | export MAINTAINER="email@example.com" 27 | ``` 28 | 29 | ## Setting `make` Options (optional) 30 | 31 | ```bash 32 | export MAKEFLAGS=-j8 33 | ``` 34 | 35 | ## Building deb or rpm Package 36 | 37 | ```bash 38 | ./build_mesos 39 | ``` 40 | 41 | ## TODO 42 | 43 | * automatic restart of master/slave when upgrading 44 | * logrotate support 45 | * service autostart 46 | 47 | ## Authors 48 | 49 | * Tomas Barton 50 | * Srdjan Grubor 51 | -------------------------------------------------------------------------------- /mesos-init-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit -o nounset -o pipefail 3 | function -h { 4 | cat < /etc/mesos-slave/port 34 | 35 | To set the switch user flag: 36 | 37 | touch /etc/mesos-slave/?switch_user 38 | 39 | To explicitly disable it: 40 | 41 | touch /etc/mesos-slave/?no-switch_user 42 | 43 | Adding attributes and resources to the slaves is slightly more granular. 44 | Although you can pass them all at once with files called 'attributes' and 45 | 'resources', you can also set them by creating files under directories 46 | labeled 'attributes' or 'resources': 47 | 48 | echo north-west > /etc/mesos-slave/attributes/rack 49 | 50 | This is intended to allow easy addition and removal of attributes and 51 | resources from the slave configuration. 52 | 53 | USAGE 54 | }; function --help { -h ;} # A nice way to handle -h and --help 55 | export LC_ALL=en_US.UTF-8 # A locale that works consistently 56 | 57 | function main { 58 | err "Please use \`master' or \`slave'." 59 | } 60 | 61 | function slave { 62 | local etc_slave=/etc/mesos-slave 63 | local args=() 64 | local attributes=() 65 | local resources=() 66 | # Call mesosphere-dnsconfig if present on the system to generate config files. 67 | [ -x /usr/bin/mesosphere-dnsconfig ] && mesosphere-dnsconfig -write -service=mesos-slave 68 | set -o allexport 69 | [[ ! -f /etc/default/mesos ]] || . /etc/default/mesos 70 | [[ ! -f /etc/default/mesos-slave ]] || . /etc/default/mesos-slave 71 | set +o allexport 72 | [[ ! ${ULIMIT:-} ]] || ulimit $ULIMIT 73 | [[ ! ${MASTER:-} ]] || args+=( --master="$MASTER" ) 74 | [[ ! ${IP:-} ]] || args+=( --ip="$IP" ) 75 | [[ ! ${LOGS:-} ]] || args+=( --log_dir="$LOGS" ) 76 | [[ ! ${ISOLATION:-} ]] || args+=( --isolation="$ISOLATION" ) 77 | for f in "$etc_slave"/* # attributes ip resources isolation &al. 78 | do 79 | if [[ -f $f ]] 80 | then 81 | local name="$(basename "$f")" 82 | if [[ $name == '?'* ]] # Recognize flags (options without values) 83 | then args+=( --"${name#'?'}" ) 84 | else args+=( --"$name"="$(cat "$f")" ) 85 | fi 86 | fi 87 | done 88 | # We allow the great multitude of attributes and resources to be specified 89 | # in directories, where the filename is the key and the contents its value. 90 | for f in "$etc_slave"/attributes/* 91 | do [[ ! -s $f ]] || attributes+=( "$(basename "$f")":"$(cat "$f")" ) 92 | done 93 | if [[ ${#attributes[@]} -gt 0 ]] 94 | then 95 | local formatted="$(printf ';%s' "${attributes[@]}")" 96 | args+=( --attributes="${formatted:1}" ) # NB: Leading ';' is clipped 97 | fi 98 | for f in "$etc_slave"/resources/* 99 | do [[ ! -s $f ]] || resources+=( "$(basename "$f")":"$(cat "$f")" ) 100 | done 101 | if [[ ${#resources[@]} -gt 0 ]] 102 | then 103 | local formatted="$(printf ';%s' "${resources[@]}")" 104 | args+=( --resources="${formatted:1}" ) # NB: Leading ';' is clipped 105 | fi 106 | 107 | if [[ "${args[@]:-}" == *'--no-logger'* ]] 108 | then 109 | local clean_args=() 110 | for i in "${args[@]}"; do 111 | if [[ "${i}" != "--no-logger" ]]; then 112 | clean_args+=( "${i}" ) 113 | fi 114 | done 115 | exec /usr/sbin/mesos-slave "${clean_args[@]}" 116 | else 117 | logged /usr/sbin/mesos-slave "${args[@]:-}" 118 | fi 119 | } 120 | 121 | function master { 122 | local etc_master=/etc/mesos-master 123 | local args=() 124 | # Call mesosphere-dnsconfig if present on the system to generate config files. 125 | [ -x /usr/bin/mesosphere-dnsconfig ] && mesosphere-dnsconfig -write -service=mesos-master 126 | set -o allexport 127 | [[ ! -f /etc/default/mesos ]] || . /etc/default/mesos 128 | [[ ! -f /etc/default/mesos-master ]] || . /etc/default/mesos-master 129 | set +o allexport 130 | [[ ! ${ULIMIT:-} ]] || ulimit $ULIMIT 131 | [[ ! ${ZK:-} ]] || args+=( --zk="$ZK" ) 132 | [[ ! ${IP:-} ]] || args+=( --ip="$IP" ) 133 | [[ ! ${PORT:-} ]] || args+=( --port="$PORT" ) 134 | [[ ! ${CLUSTER:-} ]] || args+=( --cluster="$CLUSTER" ) 135 | [[ ! ${LOGS:-} ]] || args+=( --log_dir="$LOGS" ) 136 | for f in "$etc_master"/* # cluster log_dir port &al. 137 | do 138 | if [[ -f $f ]] 139 | then 140 | local name="$(basename "$f")" 141 | if [[ $name == '?'* ]] # Recognize flags (options without values) 142 | then args+=( --"${name#'?'}" ) 143 | else args+=( --"$name"="$(cat "$f")" ) 144 | fi 145 | fi 146 | done 147 | 148 | if [[ "${args[@]:-}" == *'--no-logger'* ]] 149 | then 150 | local clean_args=() 151 | for i in "${args[@]}"; do 152 | if [[ "${i}" != "--no-logger" ]]; then 153 | clean_args+=( "${i}" ) 154 | fi 155 | done 156 | exec /usr/sbin/mesos-master "${clean_args[@]}" 157 | else 158 | logged /usr/sbin/mesos-master "${args[@]:-}" 159 | fi 160 | } 161 | 162 | # Send all output to syslog and tag with PID and executable basename. 163 | function logged { 164 | local tag="${1##*/}[$$]" 165 | exec 1> >(exec logger -p user.info -t "$tag") 166 | exec 2> >(exec logger -p user.err -t "$tag") 167 | exec "$@" 168 | } 169 | 170 | function msg { out "$*" >&2 ;} 171 | function err { local x=$? ; msg "$*" ; return $(( $x == 0 ? 1 : $x )) ;} 172 | function out { printf '%s\n' "$*" ;} 173 | 174 | if [[ ${1:-} ]] && declare -F | cut -d' ' -f3 | fgrep -qx -- "${1:-}" 175 | then "$@" 176 | else main "$@" 177 | fi 178 | 179 | --------------------------------------------------------------------------------