Import systemd files from public repo

Signed-off-by: Brandon Myers <bmyers@mozilla.com>
This commit is contained in:
Brandon Myers 2016-11-29 12:28:20 -06:00
Родитель a46e4401b0
Коммит b12cd5583e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8AA79AD83045BBC7
21 изменённых файлов: 217 добавлений и 1216 удалений

Просмотреть файл

@ -1,98 +0,0 @@
#! /bin/bash
### BEGIN INIT INFO
# Provides: elasticsearch
# Required-Start: $all
# Required-Stop: $all
# Default-Start:
# Default-Stop: 0 1 6
# Short-Description: Starts elasticsearch
# chkconfig: - 80 15
# Description: Elasticsearch
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Pull in sysconfig settings
[ -f /etc/sysconfig/elasticsearch ] && . /etc/sysconfig/elasticsearch
ES_HOME=/home/mozdef/es/current
ES_USER=mozdef
ES_MIN_MEM=4g
ES_MAX_MEM=4g
DAEMON=${ES_HOME}/bin/elasticsearch
NAME=elasticsearch
PID_FILE=${PIDFILE:-/var/run/${NAME}/${NAME}.pid}
LOCK_FILE=${LOCKFILE:-/var/lock/subsys/${NAME}}
NFILES=${NFILES:-32768}
ES_PATH_LOG=${ES_PATH_LOG:-/home/mozdef/envs/mozdef/logs/}
ES_PATH_DATA=${ES_PATH_DATA:-/data/es/}
ES_PATH_WORK=${ES_PATH_WORK:-/data/tmp/}
ES_PATH_CONF=${ES_PATH_CONF:-${ES_HOME}/config/}
ES_PATH_PLUGINS=${ES_PATH_PLUGINS:-${ES_HOME}/plugins}
ES_CONFIG=${ES_CONFIG:-${ES_PATH_CONF}/elasticsearch.yml}
DAEMON_OPTS="-p ${PID_FILE} \
-Des.config=${ES_CONFIG} \
-Des.path.conf=${ES_PATH_CONF} \
-Des.path.home=${ES_HOME} \
-Des.path.logs=${ES_PATH_LOG} \
-Des.path.data=${ES_PATH_DATA} \
-Des.path.work=${ES_PATH_WORK} \
-Des.path.plugins=${ES_PATH_PLUGINS}"
# These environment variables are passed over.
ES_MIN_MEM=${ES_MIN_MEM:-1g}
ES_MAX_MEM=${ES_MAX_MEM:-1g}
ES_INCLUDE=${ES_INCLUDE:-${ES_HOME}/bin/elasticsearch.in.sh}
start() {
echo -n $"Starting ${NAME}: "
mkdir -p $ES_PATH_WORK
ulimit -n $NFILES
daemon --pidfile=${PID_FILE} --user $ES_USER \
ES_HOME=$ES_HOME \
ES_INCLUDE=$ES_INCLUDE \
ES_MIN_MEM=$ES_MIN_MEM \
ES_MAX_MEM=$ES_MAX_MEM \
$DAEMON $DAEMON_OPTS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}
stop() {
echo -n $"Stopping ${NAME}: "
killproc -p ${PID_FILE} -d 10 $DAEMON
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCK_FILE} ${PID_FILE}
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${PID_FILE} $DAEMON
RETVAL=$?
;;
restart|force-reload)
stop
start
;;
*)
N=/etc/init.d/${NAME}
echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
RETVAL=2
;;
esac
exit $RETVAL

Просмотреть файл

@ -1,80 +0,0 @@
#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation
#
# supervisord This scripts turns supervisord on in order to manage the mozdef alerts/celery process
#
# Author: Jeff Bryner < jbryner@mozilla.com> based off Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
#
# chkconfig: - 95 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
# processname: supervisord
#
#
# source function library
. /etc/rc.d/init.d/functions
RETVAL=0
NAME=supervisord
PROCNAME=mozdefalerts
DAEMON_PATH="/home/mozdef/envs/mozdef/bin/supervisord"
source /home/mozdef/envs/mozdef/bin/activate
#DAEMON_OPTS="-c /home/mozdef/envs/mozdef/initscripts/supervisord.alerts.conf $DAEMON_OPTS"
DAEMON_OPTS="-c /home/mozdef/envs/mozdef/alerts/supervisord.alerts.conf ${DAEMON_OPTS}"
PIDFILE="/home/mozdef/envs/mozdef/alerts/plugins/${NAME}.pid"
LOCK_FILE="/var/lock/subsys/mozdefalerts"
start() {
echo -n $"Starting ${PROCNAME}: "
daemon ${DAEMON_PATH} ${DAEMON_OPTS}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${LOCK_FILE}
return $RETVAL
}
stop() {
echo -n $"Stopping ${PROCNAME}: "
echo
echo -n $"Stopping supervisord child process: "
killproc -p ${PIDFILE}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f ${LOCK_FILE}
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/supervisord ] && restart
;;
status)
status supervisord
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
exit $RETVAL

Просмотреть файл

@ -1,214 +0,0 @@
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation
#
# Contributors:
# Jeff Bryner jbryner@mozilla.com
# uwsgi - This script starts and stops uwsgi to manage the mozdef bot
#
# chkconfig: - 85 15
# description: uWSGI is a program to run applications adhering to the
# Web Server Gateway Interface.
# processname: uwsgi
# config: /etc/sysconfig/uwsgi
# Source function library.
. /etc/rc.d/init.d/functions
# Source the virtual python environment with uwsgi
source /home/mozdef/envs/mozdef/bin/activate
# all args are in the .ini file, restarts/quit/reload, etc via the fifo instead signalling the PID
uwsgi="/home/mozdef/envs/mozdef/bin/uwsgi"
prog=$(basename "$uwsgi")
UWSGI_CONF_DIR="/home/mozdef/envs/mozdef/bot/"
each_action() {
action=$1
configs=$(find "$UWSGI_CONF_DIR" \
-maxdepth 1 \
-type f \
-regextype posix-extended \
-iregex '.*\.(ini)$')
code=0
if [ -n "$configs" ]; then
for f in $configs; do
case "$action" in
force-reload|restart)
stop "$f"
start "$f"
;;
reload)
reload "$f"
;;
chain-reload)
chain-reload "$f"
;;
worker-reload)
worker-reload "$f"
;;
stats)
stats "$f"
;;
start)
start "$f"
;;
status)
rh_status "$f"
;;
status_q)
rh_status "$f" >/dev/null 2>&1
;;
stop)
stop "$f"
;;
esac
retval=$?
done
if [ $retval -gt $code ]; then
code=$retval
fi
fi
return $code
}
args_for() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args=""
case "$1" in
*.ini) args="$args --ini $f";;
esac
echo "$args"
}
instance_for() {
config_file="$1"
instance=$(basename "$config_file")
instance=${instance%.*}
echo "$instance"
}
pidfile_for() {
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.pid"
}
fifo_for(){
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.fifo"
}
reload() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Reloading uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog" -HUP
retval=$?
echo
return $retval
}
chain-reload(){
#use the special uwsgi method to 'chain reload' workers
#allowing them to finish their jobs and restart one by one,only after one is ready
#trigger by echo c>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Chain reloading uWSGI for ${instance}... "
echo c > "$fifofile"
retval=$?
echo
return $retval
}
worker-reload(){
#use the special uwsgi method to 'gracefully reload' workers
#allowing them to finish their jobs and restart one by one, ready or not
#trigger by echo w>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Worker reloading uWSGI for ${instance}... "
echo w > "$fifofile"
retval=$?
echo
return $retval
}
stats(){
#use the special uwsgi method to request stats to the logs
#trigger by echo s>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Requesting stats (to logs) from uWSGI for ${instance}... "
echo s > "$fifofile"
retval=$?
echo
return $retval
}
start() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args="$(args_for "$config_file")"
echo -n "Starting uWSGI for ${instance}... "
daemon --pidfile="$pidfile" $uwsgi $args
retval=$?
echo
return $retval
}
rh_status() {
config_file="$1"
status -p "$(pidfile_for "$config_file")" "$prog"
}
stop() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
echo -n "Stopping uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog"
retval=$?
echo
return $retval
}
case $1 in
worker-reload|stats|chain-reload|force_reload|reload|restart|start|status|status_q|stop)
each_action "$1"
;;
*)
echo "Usage: $0 {worker-reload|chain-reload|reload|stats|restart|start|status|stop}"
echo "Restart options in order of niceness: chain-reload,worker-reload,reload,restart"
exit 2
;;
esac
exit $?

Просмотреть файл

@ -1,91 +0,0 @@
#! /bin/bash
### BEGIN INIT INFO
# Provides: mozdefdb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts mozdef meteor db interface.
# Description: mozdef mongo db interface provided by meteor
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
APP_NAME=mozdefdb
# Pull in sysconfig settings
[ -f /etc/sysconfig/${APP_NAME} ] && . /etc/sysconfig/${APP_NAME}
PID_FILE=${PIDFILE:-/var/run/${APP_NAME}.pid}
LOCK_FILE=${LOCKFILE:-/var/lock/subsys/${APP_NAME}}
#METEOR_WAREHOUSE_DIR="/home/jbryner/.meteor"
#we start a script that eventually runs
#mongod --bind_ip 127.0.0.1 --smallfiles --nohttpinterface --port 3002 --dbpath /home/jbryner/envs/meteor/mozdef/.meteor/local/db --oplogSize 8 --replSet meteor
APP_USER='jbryner'
APP_DIR="/home/jbryner/envs/meteor/mozdef/"
DAEMON_RUN="/home/jbryner/envs/meteor/bin/mongod"
DAEMON_TARGET="--bind_ip 127.0.0.1 --smallfiles --nohttpinterface --port 3002 --dbpath /home/jbryner/envs/meteor/mozdef/.meteor/local/db --oplogSize 8 --replSet meteor"
LOG_FILE="/home/jbryner/envs/meteor/mongo.log"
export HOME="/home/jbryner"
#export MONGO_URL=mongodb://localhost:3002/meteor
#export ROOT_URL=http://mozdefqa1.private.scl3.mozilla.com/
#export PORT=3000
start() {
echo -n $"Starting ${APP_NAME}: "
echo $"Starting process and waiting for PID"
cd ${APP_DIR}
#nohup runuser -l ${APP_USER} -m -c '${DAEMON_RUN} ${DAEMON_TARGET} >${LOG_FILE} 2>&1 &'
#echo $"runuser -l ${APP_USER} -c '${DAEMON_RUN} ${DAEMON_TARGET} >${LOG_FILE} 2>&1 '"
nohup ${DAEMON_RUN} ${DAEMON_TARGET} >${LOG_FILE} 2>&1 &
RETVAL=$?
sleep 5
PID=`pgrep -f ${DAEMON_RUN} | head -n1` || PID=0
[ $PID -gt 0 ] && echo $"PID: $PID started"
[ $PID -gt 0 ] && echo $PID > ${PID_FILE}
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
[ -x /sbin/restorecon ] && /sbin/restorecon $LOCK_FILE
echo $"$APP_NAME started"
return $RETVAL
}
stop() {
echo -n $"Stopping ${APP_NAME}: "
#killproc -p ${PID_FILE} -d 10 $DAEMON
#many processes started that must be individually killed.
pgrep -f ${DAEMON_RUN}| while read i;do kill $i;done
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCK_FILE} ${PID_FILE} ; echo "Stopped"
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${PID_FILE} ${APP_NAME}
RETVAL=$?
;;
restart|force-reload)
stop
start
;;
*)
N=/etc/init.d/${APP_NAME}
echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
RETVAL=2
;;
esac
exit $RETVAL

Просмотреть файл

@ -1,214 +0,0 @@
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation
#
# Contributors:
# Jeff Bryner jbryner@mozilla.com
# uwsgi - This script starts and stops uwsgi apps interfacing with nginx and sending to message queues
#
# chkconfig: - 85 15
# description: uWSGI is a program to run applications adhering to the
# Web Server Gateway Interface.
# processname: uwsgi
# config: /etc/sysconfig/uwsgi
# Source function library.
. /etc/rc.d/init.d/functions
# Source the virtual python environment with uwsgi
source /home/mozdef/envs/mozdef/bin/activate
# all args are in the .ini file, restarts/quit/reload, etc via the fifo instead signalling the PID
uwsgi="/home/mozdef/envs/mozdef/bin/uwsgi"
prog=$(basename "$uwsgi")
UWSGI_CONF_DIR="/home/mozdef/envs/mozdef/loginput/"
each_action() {
action=$1
configs=$(find "$UWSGI_CONF_DIR" \
-maxdepth 1 \
-type f \
-regextype posix-extended \
-iregex '.*\.(ini)$')
code=0
if [ -n "$configs" ]; then
for f in $configs; do
case "$action" in
force-reload|restart)
stop "$f"
start "$f"
;;
reload)
reload "$f"
;;
chain-reload)
chain-reload "$f"
;;
worker-reload)
worker-reload "$f"
;;
stats)
stats "$f"
;;
start)
start "$f"
;;
status)
rh_status "$f"
;;
status_q)
rh_status "$f" >/dev/null 2>&1
;;
stop)
stop "$f"
;;
esac
retval=$?
done
if [ $retval -gt $code ]; then
code=$retval
fi
fi
return $code
}
args_for() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args=""
case "$1" in
*.ini) args="$args --ini $f";;
esac
echo "$args"
}
instance_for() {
config_file="$1"
instance=$(basename "$config_file")
instance=${instance%.*}
echo "$instance"
}
pidfile_for() {
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.pid"
}
fifo_for(){
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.fifo"
}
reload() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Reloading uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog" -HUP
retval=$?
echo
return $retval
}
chain-reload(){
#use the special uwsgi method to 'chain reload' workers
#allowing them to finish their jobs and restart one by one,only after one is ready
#trigger by echo c>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Chain reloading uWSGI for ${instance}... "
echo c > "$fifofile"
retval=$?
echo
return $retval
}
worker-reload(){
#use the special uwsgi method to 'gracefully reload' workers
#allowing them to finish their jobs and restart one by one, ready or not
#trigger by echo w>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Worker reloading uWSGI for ${instance}... "
echo w > "$fifofile"
retval=$?
echo
return $retval
}
stats(){
#use the special uwsgi method to request stats to the logs
#trigger by echo s>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Requesting stats (to logs) from uWSGI for ${instance}... "
echo s > "$fifofile"
retval=$?
echo
return $retval
}
start() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args="$(args_for "$config_file")"
echo -n "Starting uWSGI for ${instance}... "
daemon --pidfile="$pidfile" $uwsgi $args
retval=$?
echo
return $retval
}
rh_status() {
config_file="$1"
status -p "$(pidfile_for "$config_file")" "$prog"
}
stop() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
echo -n "Stopping uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog"
retval=$?
echo
return $retval
}
case $1 in
worker-reload|stats|chain-reload|force_reload|reload|restart|start|status|status_q|stop)
each_action "$1"
;;
*)
echo "Usage: $0 {worker-reload|chain-reload|reload|stats|restart|start|status|stop}"
echo "Restart options in order of niceness: chain-reload,worker-reload,reload,restart"
exit 2
;;
esac
exit $?

Просмотреть файл

@ -1,214 +0,0 @@
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation
#
# Contributors:
# Jeff Bryner jbryner@mozilla.com
# uwsgi - This script starts and stops uwsgi apps consuming the mozdef message queues
#
# chkconfig: - 85 15
# description: uWSGI is a program to run applications adhering to the
# Web Server Gateway Interface.
# processname: uwsgi
# config: /etc/sysconfig/uwsgi
# Source function library.
. /etc/rc.d/init.d/functions
# Source the virtual python environment with uwsgi
source /home/mozdef/envs/mozdef/bin/activate
# all args are in the .ini file, restarts/quit/reload, etc via the fifo instead signalling the PID
uwsgi="/home/mozdef/envs/mozdef/bin/uwsgi"
prog=$(basename "$uwsgi")
UWSGI_CONF_DIR="/home/mozdef/envs/mozdef/mq/"
each_action() {
action=$1
configs=$(find "$UWSGI_CONF_DIR" \
-maxdepth 1 \
-type f \
-regextype posix-extended \
-iregex '.*\.(ini)$')
code=0
if [ -n "$configs" ]; then
for f in $configs; do
case "$action" in
force-reload|restart)
stop "$f"
start "$f"
;;
reload)
reload "$f"
;;
chain-reload)
chain-reload "$f"
;;
worker-reload)
worker-reload "$f"
;;
stats)
stats "$f"
;;
start)
start "$f"
;;
status)
rh_status "$f"
;;
status_q)
rh_status "$f" >/dev/null 2>&1
;;
stop)
stop "$f"
;;
esac
retval=$?
done
if [ $retval -gt $code ]; then
code=$retval
fi
fi
return $code
}
args_for() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args=""
case "$1" in
*.ini) args="$args --ini $f";;
esac
echo "$args"
}
instance_for() {
config_file="$1"
instance=$(basename "$config_file")
instance=${instance%.*}
echo "$instance"
}
pidfile_for() {
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.pid"
}
fifo_for(){
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.fifo"
}
reload() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Reloading uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog" -HUP
retval=$?
echo
return $retval
}
chain-reload(){
#use the special uwsgi method to 'chain reload' workers
#allowing them to finish their jobs and restart one by one,only after one is ready
#trigger by echo c>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Chain reloading uWSGI for ${instance}... "
echo c > "$fifofile"
retval=$?
echo
return $retval
}
worker-reload(){
#use the special uwsgi method to 'gracefully reload' workers
#allowing them to finish their jobs and restart one by one, ready or not
#trigger by echo w>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Worker reloading uWSGI for ${instance}... "
echo w > "$fifofile"
retval=$?
echo
return $retval
}
stats(){
#use the special uwsgi method to request stats to the logs
#trigger by echo s>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Requesting stats (to logs) from uWSGI for ${instance}... "
echo s > "$fifofile"
retval=$?
echo
return $retval
}
start() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args="$(args_for "$config_file")"
echo -n "Starting uWSGI for ${instance}... "
daemon --pidfile="$pidfile" $uwsgi $args
retval=$?
echo
return $retval
}
rh_status() {
config_file="$1"
status -p "$(pidfile_for "$config_file")" "$prog"
}
stop() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
echo -n "Stopping uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog"
retval=$?
echo
return $retval
}
case $1 in
worker-reload|stats|chain-reload|force_reload|reload|restart|start|status|status_q|stop)
each_action "$1"
;;
*)
echo "Usage: $0 {worker-reload|chain-reload|reload|stats|restart|start|status|stop}"
echo "Restart options in order of niceness: chain-reload,worker-reload,reload,restart"
exit 2
;;
esac
exit $?

Просмотреть файл

@ -1,214 +0,0 @@
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation
#
# Contributors:
# Jeff Bryner jbryner@mozilla.com
# uwsgi - This script starts and stops uwsgi apps interfacing with nginx and serving rest requests
#
# chkconfig: - 85 15
# description: uWSGI is a program to run applications adhering to the
# Web Server Gateway Interface.
# processname: uwsgi
# config: /etc/sysconfig/uwsgi
# Source function library.
. /etc/rc.d/init.d/functions
# Source the virtual python environment with uwsgi
source /home/mozdef/envs/mozdef/bin/activate
# all args are in the .ini file, restarts/quit/reload, etc via the fifo instead signalling the PID
uwsgi="/home/mozdef/envs/mozdef/bin/uwsgi"
prog=$(basename "$uwsgi")
UWSGI_CONF_DIR="/home/mozdef/envs/mozdef/rest/"
each_action() {
action=$1
configs=$(find "$UWSGI_CONF_DIR" \
-maxdepth 1 \
-type f \
-regextype posix-extended \
-iregex '.*\.(ini)$')
code=0
if [ -n "$configs" ]; then
for f in $configs; do
case "$action" in
force-reload|restart)
stop "$f"
start "$f"
;;
reload)
reload "$f"
;;
chain-reload)
chain-reload "$f"
;;
worker-reload)
worker-reload "$f"
;;
stats)
stats "$f"
;;
start)
start "$f"
;;
status)
rh_status "$f"
;;
status_q)
rh_status "$f" >/dev/null 2>&1
;;
stop)
stop "$f"
;;
esac
retval=$?
done
if [ $retval -gt $code ]; then
code=$retval
fi
fi
return $code
}
args_for() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args=""
case "$1" in
*.ini) args="$args --ini $f";;
esac
echo "$args"
}
instance_for() {
config_file="$1"
instance=$(basename "$config_file")
instance=${instance%.*}
echo "$instance"
}
pidfile_for() {
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.pid"
}
fifo_for(){
instance=$(instance_for "$1")
echo "${UWSGI_CONF_DIR}/${instance}.fifo"
}
reload() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Reloading uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog" -HUP
retval=$?
echo
return $retval
}
chain-reload(){
#use the special uwsgi method to 'chain reload' workers
#allowing them to finish their jobs and restart one by one,only after one is ready
#trigger by echo c>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Chain reloading uWSGI for ${instance}... "
echo c > "$fifofile"
retval=$?
echo
return $retval
}
worker-reload(){
#use the special uwsgi method to 'gracefully reload' workers
#allowing them to finish their jobs and restart one by one, ready or not
#trigger by echo w>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Worker reloading uWSGI for ${instance}... "
echo w > "$fifofile"
retval=$?
echo
return $retval
}
stats(){
#use the special uwsgi method to request stats to the logs
#trigger by echo s>fifo
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
fifofile=$(fifo_for "$config_file")
echo -n "Requesting stats (to logs) from uWSGI for ${instance}... "
echo s > "$fifofile"
retval=$?
echo
return $retval
}
start() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
args="$(args_for "$config_file")"
echo -n "Starting uWSGI for ${instance}... "
daemon --pidfile="$pidfile" $uwsgi $args
retval=$?
echo
return $retval
}
rh_status() {
config_file="$1"
status -p "$(pidfile_for "$config_file")" "$prog"
}
stop() {
config_file="$1"
instance=$(instance_for "$config_file")
pidfile=$(pidfile_for "$config_file")
echo -n "Stopping uWSGI for ${instance}... "
killproc -p "$pidfile" "$prog"
retval=$?
echo
return $retval
}
case $1 in
worker-reload|stats|chain-reload|force_reload|reload|restart|start|status|status_q|stop)
each_action "$1"
;;
*)
echo "Usage: $0 {worker-reload|chain-reload|reload|stats|restart|start|status|stop}"
echo "Restart options in order of niceness: chain-reload,worker-reload,reload,restart"
exit 2
;;
esac
exit $?

Просмотреть файл

@ -1,91 +0,0 @@
#! /bin/bash
### BEGIN INIT INFO
# Provides: mozdefweb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts mozdef meteor web interface.
# Description: mozdef web interface provided by meteor
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
APP_NAME=mozdefweb
# Pull in sysconfig settings
[ -f /etc/sysconfig/${APP_NAME} ] && . /etc/sysconfig/${APP_NAME}
PID_FILE=${PIDFILE:-/var/run/${APP_NAME}.pid}
LOCK_FILE=${LOCKFILE:-/var/lock/subsys/${APP_NAME}}
#METEOR_WAREHOUSE_DIR="/home/jbryner/.meteor"
#we start a script that eventually runs node aka:
#/home/jbryner/envs/meteor/bin/node /home/jbryner/envs/meteor/mozdef/.meteor/local/build/main.js
APP_USER='jbryner'
APP_DIR="/home/jbryner/envs/meteor/mozdef/"
DAEMON_RUN="/home/jbryner/envs/meteor/bin/node"
DAEMON_TARGET="/home/jbryner/envs/meteor/mozdef/.meteor/local/build/main.js"
LOG_FILE="/home/jbryner/envs/meteor/meteor.log"
export HOME="/home/jbryner"
export MONGO_URL=mongodb://localhost:3002/meteor
export ROOT_URL=http://mozdefqa1.private.scl3.mozilla.com/
export PORT=3000
start() {
echo -n $"Starting ${APP_NAME}: "
echo $"Starting process and waiting for PID"
cd ${APP_DIR}
#nohup runuser -l ${APP_USER} -m -c '${DAEMON_RUN} ${DAEMON_TARGET} >${LOG_FILE} 2>&1 &'
#echo $"runuser -l ${APP_USER} -c '${DAEMON_RUN} ${DAEMON_TARGET} >${LOG_FILE} 2>&1 '"
nohup ${DAEMON_RUN} ${DAEMON_TARGET} >${LOG_FILE} 2>&1 &
RETVAL=$?
sleep 5
PID=`pgrep -f ${DAEMON_RUN} | head -n1` || PID=0
[ $PID -gt 0 ] && echo $"PID: $PID started"
[ $PID -gt 0 ] && echo $PID > ${PID_FILE}
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
[ -x /sbin/restorecon ] && /sbin/restorecon $LOCK_FILE
echo $"$APP_NAME started"
return $RETVAL
}
stop() {
echo -n $"Stopping ${APP_NAME}: "
#killproc -p ${PID_FILE} -d 10 $DAEMON
#many processes started that must be individually killed.
pgrep -f ${DAEMON_RUN}| while read i;do kill $i;done
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCK_FILE} ${PID_FILE} ; echo "Stopped"
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${PID_FILE} ${APP_NAME}
RETVAL=$?
;;
restart|force-reload)
stop
start
;;
*)
N=/etc/init.d/${APP_NAME}
echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
RETVAL=2
;;
esac
exit $RETVAL

Двоичные данные
initscripts/supervisord.alerts.conf

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,16 @@
[Unit]
Description=Kibana
Requires=elasticsearch.service
[Service]
ExecStart=/opt/mozdef/envs/kibana/bin/kibana
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=kibana4
User=mozdef
Group=mozdef
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target

Просмотреть файл

@ -0,0 +1,21 @@
[Unit]
Description=MongoDB Database Service
After=network.target
[Service]
Type=forking
PIDFile=/var/run/mozdefdb/mozdefdb.pid
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
<<<<<<< HEAD
Restart=always
=======
#Restart=always
>>>>>>> 8d519538b9afa92609f5afa587256e02a25a554e
User=mozdef
Group=mozdef
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef Alert Plugins
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/alerts; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini alertPlugins.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=alertPlugins

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdefloginput
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/loginput; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini loginput.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=loginput

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef mqwAutoland
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwAutoland.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwautoloand

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef mqwBroStage
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwBroStage.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwbrostage

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef mqwFXA Stage
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwFxaStage.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwfxastage

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef mqwInfosecSQSNonProd
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwInfosecSQSNonProd.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwinfosecsqsnonprod

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef mqwNubisNonProd
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwNubisNonProd.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwnubisnonprod

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef mqwRelengPapertrail
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwRelengPapertrail.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwrelengpapertrail

Просмотреть файл

@ -0,0 +1,18 @@
Unit]
Description=uWSGI mozdef mqwSyslog
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/mq; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini mqwSyslog.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=mqwsyslog

Просмотреть файл

@ -0,0 +1,18 @@
[Unit]
Description=uWSGI mozdef restapi
After=syslog.target
[Service]
# Requires systemd version 211 or newer
User=mozdef
Group=mozdef
ExecStart=/bin/bash -c 'cd /opt/mozdef/envs/mozdef/rest; source /opt/mozdef/envs/mozdef/bin/activate; uwsgi --ini restapi.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=restapi