mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-05 18:42:55 +00:00
Merge branch 'master' into bug5774
This commit is contained in:
commit
b023ba9673
807 files changed
+34902
-8885
No files matched your search
@@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to deploy on an instance that has an ephemeral volume as /dev/nvme0n1 (adjust env var PARTITION if different)
|
||||
# Ensures the partition is xfs-formatted, any existing partition contents will be overwritten if formatted otherwise.
|
||||
# An existing xfs partition will be left alone.
|
||||
PARTITION=/dev/nvme0n1
|
||||
FSTYPE=$(blkid -p $PARTITION -s TYPE -o value)
|
||||
if [ "$FSTYPE" = "" ]; then
|
||||
echo FSTYPE was empty, creating swap partition
|
||||
mkswap $PARTITION
|
||||
swapon -a $PARTITION
|
||||
else
|
||||
echo FSTYPE was "$FSTYPE", not touching
|
||||
fi
|
||||
@@ -0,0 +1 @@
|
||||
../environments_scripts/repo/usr/local/bin/mountnvmeswap
|
||||
@@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=An unformatted /dev/nvme0n1 is turned into swap space
|
||||
Requires=-.mount
|
||||
After=-.mount
|
||||
|
||||
[Install]
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/usr/local/bin/mountnvmeswap
|
||||
@@ -0,0 +1 @@
|
||||
../environments_scripts/repo/etc/systemd/system/mountnvmeswap.service
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
imageType="$1"
|
||||
aws ec2 describe-images --filter Name=tag:image-type,Values=${imageType} | jq --raw-output '.Images | sort_by(.CreationDate) | .[].ImageId' | tail -n 1
|
||||
@@ -0,0 +1 @@
|
||||
../environments_scripts/repo/usr/local/bin/getLatestImageOfType.sh
|
||||
@@ -747,9 +747,10 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
|
||||
fi
|
||||
|
||||
extra="$extra -P with-not-android-relevant,!with-mobile"
|
||||
echo "Building and installing forked GWT version..."
|
||||
JAVA_HOME="${JAVA8_HOME}" `dirname $0`/install-gwt "${PROJECT_HOME}"
|
||||
|
||||
if [ $gwtcompile -eq 1 ]; then
|
||||
echo "Building and installing forked GWT version..."
|
||||
JAVA_HOME="${JAVA8_HOME}" `dirname $0`/install-gwt "${PROJECT_HOME}"
|
||||
fi
|
||||
echo "Using following command: mvn $extra -DargLine=\"$APP_PARAMETERS\" -fae -s $MAVEN_SETTINGS $clean install"
|
||||
echo "Maven version used: `mvn --version`"
|
||||
echo "JAVA_HOME used: $JAVA_HOME"
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#!/bin/bash
|
||||
RELATIVE_SERVER_DIR=$1
|
||||
if [ $# = 0 ]; then
|
||||
PWD=$( pwd )
|
||||
RELATIVE_SERVER_DIR=$( basename ${PWD} )
|
||||
else
|
||||
RELATIVE_SERVER_DIR=$1
|
||||
fi
|
||||
MAIL_PROPERTIES=mail.properties
|
||||
SECRETS=secrets
|
||||
ROOT_MAIL_PROPERTIES=/root/${MAIL_PROPERTIES}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_authorized_keys_for_landscape_managers_if_changed $( cat /root/ssh-key-reader.token ) https://security-service.sapsailing.com /root 2>&1 >>/var/log/sailing.err
|
||||
* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; switchoverArchive.sh /etc/httpd/conf.d/000-macros.conf 2 9
|
||||
# NOTICE: Please try to reference the customised crontabs at $GIT_HOME/configuration/crontabs or use
|
||||
# the build-crontab script. This file has been maintained for continuity, but is deprecated.
|
||||
@@ -0,0 +1,7 @@
|
||||
This is the crontab repo and it contains one line crontabs for all the different environments.
|
||||
These files are concatenated by the build_crontab script. Any time the crontab should contain
|
||||
a user's home directory, instead write PATH_OF_HOME_DIR_TO_REPLACE; if the crontab should
|
||||
contain the path to the git directory, instead write PATH_OF_GIT_HOME_DIR_TO_REPLACE.
|
||||
These are replaced by the build-crontab script.
|
||||
|
||||
Note: theses files are symbolically linked to, so beware of the ramifications of changes.
|
||||
@@ -0,0 +1 @@
|
||||
0 7 2 * * export PATH=/bin:/usr/bin:/usr/local/bin; docker exec -it registry-registry-1 registry garbage-collect /etc/docker/registry/config.yml
|
||||
@@ -0,0 +1 @@
|
||||
15 12 * * * PATH_OF_GIT_HOME_DIR_TO_REPLACE/configuration/downloadNewArchivedTracTracEvents.sh PATH_OF_HOME_DIR_TO_REPLACE/static/TracTracTracks "PATH_OF_GIT_HOME_DIR_TO_REPLACE">PATH_OF_HOME_DIR_TO_REPLACE/downloadNewArchivedTracTracEvents.out 2>PATH_OF_HOME_DIR_TO_REPLACE/downloadNewArchivedTracTracEvents.err
|
||||
@@ -0,0 +1 @@
|
||||
0 10 1 * * export PATH=/bin:/usr/bin:/usr/local/bin; mail-events-on-my >/dev/null 2>/dev/null
|
||||
@@ -0,0 +1,5 @@
|
||||
# If you'd like to receive e-mail notifications about new Manage2Sail results for an event,
|
||||
# adjust the following accordingly, making sure you also update the mailing list file
|
||||
# referenced by the notify... script. Adjust the Manage2Sail event ID in the script
|
||||
# to point to the event you'd like to observe.
|
||||
#* * * * * PATH_OF_HOME_DIR_TO_REPLACE/bin/notifyAbout49erEuros2023Updates 2>PATH_OF_HOME_DIR_TO_REPLACE/notifyAbout49erEuros2023Updates.err >PATH_OF_HOME_DIR_TO_REPLACE/notifyAbout49erEuros2023Updates.out
|
||||
@@ -0,0 +1 @@
|
||||
* * * * * PATH_OF_GIT_HOME_DIR_TO_REPLACE/configuration/notify-unhealthy-mongodb 2>PATH_OF_HOME_DIR_TO_REPLACE/notify-unhealthy-mongodb.err >PATH_OF_HOME_DIR_TO_REPLACE/notify-unhealthy-mongodb.out
|
||||
@@ -0,0 +1 @@
|
||||
* * * * * export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); switchoverArchive.sh /etc/httpd/conf.d/000-macros.conf 2 9
|
||||
@@ -0,0 +1 @@
|
||||
*/10 * * * * export PATH=/bin:/usr/bin:/usr/local/bin; syncgit PATH_OF_GIT_HOME_DIR_TO_REPLACE
|
||||
@@ -0,0 +1 @@
|
||||
* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_authorized_keys_for_landscape_managers_if_changed $( cat PATH_OF_HOME_DIR_TO_REPLACE/ssh-key-reader.token ) https://security-service.sapsailing.com PATH_OF_HOME_DIR_TO_REPLACE # 2>&1 >>/var/log/sailing.err
|
||||
@@ -0,0 +1 @@
|
||||
* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_authorized_keys_for_landscape_managers_if_changed $( cat PATH_OF_HOME_DIR_TO_REPLACE/ssh-key-reader.token ) https://security-service.sapsailing.com /home/ec2-user # 2>&1 >>/var/log/sailing.err
|
||||
@@ -0,0 +1 @@
|
||||
*/10 * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_landscape_managers_mailing_list.sh $(cat /root/ssh-key-reader.token) /var/cache
|
||||
@@ -0,0 +1 @@
|
||||
10 12 * * * PATH_OF_GIT_HOME_DIR_TO_REPLACE/configuration/update-tractrac-urls-to-archive.sh "PATH_OF_GIT_HOME_DIR_TO_REPLACE" >PATH_OF_HOME_DIR_TO_REPLACE/update-tractrac-urls-to-archive.out 2>PATH_OF_HOME_DIR_TO_REPLACE/update-tractrac-urls-to-archive.err
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
GIT_ROOT=/home/wiki/gitwiki
|
||||
# Downloads all TracTrac event data based on ${GIT_ROOT}/configuration/tractrac-json-urls
|
||||
# into the target directory (specified as $1) for those event URLs whose specific folder
|
||||
# does not yet exist in the target directory.
|
||||
TARGET_DIR="${1}"
|
||||
JSON_URLS_FILE="${GIT_ROOT}/configuration/tractrac-json-urls"
|
||||
for i in `cat "${JSON_URLS_FILE}"`; do
|
||||
EVENT_DB="$( basename $( dirname ${i} ) )"
|
||||
if [ -d "${TARGET_DIR}/${EVENT_DB}" ]; then
|
||||
echo "Directory for event ${EVENT_DB} already found. Not downloading again. Use"
|
||||
echo " ${GIT_ROOT}/configuration/downloadTracTracEvent ${i} ${TARGET_DIR}"
|
||||
echo "to force an update."
|
||||
else
|
||||
echo "Did not find directory for event ${EVENT_DB} yet in ${TARGET_DIR}. Downloading..."
|
||||
${GIT_ROOT}/configuration/downloadTracTracEvent "${i}" "${TARGET_DIR}"
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1 @@
|
||||
environments_scripts/central_reverse_proxy/files/usr/local/bin/downloadNewArchivedTracTracEvents.sh
|
||||
@@ -1,4 +1,4 @@
|
||||
MEMORY=400g
|
||||
MEMORY=500g
|
||||
SERVER_NAME=ARCHIVE
|
||||
REPLICATION_CHANNEL=sapsailinganalytics-archive
|
||||
MONGODB_URI="mongodb://dbserver.internal.sapsailing.com:10201/winddb?replicaSet=archive&retryWrites=true&readPreference=secondaryPreferred"
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
SERVER_NAME=DEV
|
||||
REPLICATION_HOST=rabbit.internal.sapsailing.com
|
||||
REPLICATION_CHANNEL=sapsailinganalytics-dev
|
||||
TELNET_PORT=14888
|
||||
SERVER_PORT=8888
|
||||
MONGODB_HOST=dbserver.internal.sapsailing.com
|
||||
MONGODB_PORT=10200
|
||||
EXPEDITION_PORT=2010
|
||||
REPLICATE_ON_START=False
|
||||
REPLICATE_MASTER_SERVLET_HOST=
|
||||
REPLICATE_MASTER_SERVLET_PORT=
|
||||
REPLICATE_MASTER_QUEUE_HOST=
|
||||
REPLICATE_MASTER_QUEUE_PORT=
|
||||
MONGODB_URI="mongodb://dbserver.internal.sapsailing.com:10202/dev?replicaSet=slow&retryWrites=true&readPreference=nearest"
|
||||
@@ -1,17 +1,3 @@
|
||||
TELNET_PORT=14888
|
||||
SERVER_PORT=8888
|
||||
MONGODB_HOST=dbserver.internal.sapsailing.com
|
||||
MONGODB_PORT=10202
|
||||
EXPEDITION_PORT=2010
|
||||
DEPLOY_TO=security_service
|
||||
REPLICATE_MASTER_SERVLET_PORT=8888
|
||||
REPLICATE_MASTER_QUEUE_HOST=rabbit.internal.sapsailing.com
|
||||
REPLICATE_MASTER_QUEUE_PORT=5672
|
||||
REPLICATION_HOST=rabbit.internal.sapsailing.com
|
||||
ADDITIONAL_JAVA_ARGS="$ADDITIONAL_JAVA_ARGS -Dorg.eclipse.jetty.LEVEL=OFF -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog -Drestore.tracked.races=true -Dpolardata.source.url=https://www.sapsailing.com -XX:ThreadPriorityPolicy=2"
|
||||
SERVER_STARTUP_NOTIFY=axel.uhl@sap.com
|
||||
BUILD_COMPLETE_NOTIFY=axel.uhl@sap.com
|
||||
|
||||
# To enable the use of the shared SecurityService and SharedSailingData from security-service.sapsailing.com:
|
||||
ADDITIONAL_JAVA_ARGS="$ADDITIONAL_JAVA_ARGS -Dsecurity.sharedAcrossSubdomainsOf=sapsailing.com -Dsecurity.baseUrlForCrossDomainStorage=https://security-service.sapsailing.com -Dgwt.acceptableCrossDomainStorageRequestOriginRegexp=https?://(.*\.)?sapsailing\.com(:[0-9]*)?$"
|
||||
# For the security-service master instance, don't activate replication from security-service
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
The environments_scripts directory contains more directories, which map to environment types, each holding scripts and files useful to that environment. Each environment type also contains a "users" folder, which contains subfolders for each user on the system.
|
||||
The build-crontab-and-cp-files script uses the contents of these subfolders to create and install a customised crontab for each user in the folder. It does this by concatenating one liner crontabs into an uber crontab.
|
||||
Any time the crontab should contain a user's home directory, instead write PATH_OF_HOME_DIR_TO_REPLACE; if the crontab should
|
||||
contain the path to the git directory, instead write PATH_OF_GIT_HOME_DIR_TO_REPLACE.
|
||||
These are replaced by the build-crontab-and-cp-files script with the correct paths
|
||||
|
||||
environment_scripts (directory)
|
||||
|
|
||||
|_environement_type (directory)
|
||||
|
|
||||
|_usefulScripts
|
||||
|_users (directory)
|
||||
|
|
||||
|_user1 (directory)
|
||||
|
|
||||
|_symbolicLinks (to configuration/crontabs)
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Purpose: The first parameter is an image type. This script iterates over the image types' USER folders, concatenating all the symbolic
|
||||
# links (referencing locations within configuration/crontabs) into one file for each user. It also takes the name of the user containing a copy of the git repo
|
||||
# as well as the name of the dir within that user to go to. The created files for each user go into that user's
|
||||
# home dir and are installed for that user too. Note: within these crontabs are certain regexes, which are replaced by the path to the git home dir and the matching
|
||||
# user's home.
|
||||
# Useful files are also copied across from the "files" dir within each image type.
|
||||
|
||||
if [[ $# -ne 3 && $# -ne 4 && $# -ne 5 ]]; then
|
||||
echo "$0 <ENVIRONMENT_TYPE> <USER_WITH_COPY_OF_REPO> <RELATIVE_PATH_OF_GIT_DIR_WITHIN_USER> "
|
||||
echo ""
|
||||
echo "Where USER_WITH_COPY_OF_REPO is a user that contains a checked out copy of the main git."
|
||||
echo "And where RELATIVE_PATH_OF_GIT_DIR_WITHIN_USER is the path to the git repo from the USER_WITH_COPY_OF_REPO's home directory."
|
||||
echo "Use the s(imple) flag to only do the crontab and not copy any files across. The n(o install) flag can be used to setup the crontabs but not install them."
|
||||
exit 2
|
||||
fi
|
||||
INSTALL_CRONTAB="true"
|
||||
options='sn'
|
||||
while getopts $options option
|
||||
do
|
||||
case $option in
|
||||
n) INSTALL_CRONTAB="false";;
|
||||
s) ONLY_CRONTAB="true";;
|
||||
\?) echo "Invalid option"
|
||||
exit 4;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1)) # shift the arguments along so -s is no longer $1
|
||||
ENV_TYPE="$1"
|
||||
GIT_USER="$2"
|
||||
RELATIVE_GIT_DIR_NAME="$3"
|
||||
cd "$(dirname "$0")/${ENV_TYPE}"
|
||||
if [[ -d "users" ]]; then
|
||||
cd "users"
|
||||
GIT_PATH="$(eval echo $(printf "~%q" "$GIT_USER"))/${RELATIVE_GIT_DIR_NAME}" # The path to the git repo that contains the files needed.
|
||||
for dir in $(ls -d */ ); do
|
||||
USERNAME=$(echo $dir | sed "s/\/$//") # Dirname is the username. The trailing slash is removed.
|
||||
HOME_DIR=$(eval echo $(printf "~%q" "$USERNAME")) # The path to the home dir of the user whose cronjob will be installed.
|
||||
> $HOME_DIR/crontab
|
||||
for crontab in $(ls ${USERNAME}/crontab*); do
|
||||
cat "${crontab}">> $HOME_DIR/crontab
|
||||
done
|
||||
sed -i "s|PATH_OF_GIT_HOME_DIR_TO_REPLACE|${GIT_PATH}|g" $HOME_DIR/crontab # Sets correct path to the git repo within the crontab.
|
||||
sed -i "s|PATH_OF_HOME_DIR_TO_REPLACE|${HOME_DIR}|g" $HOME_DIR/crontab # Sets the correct path to the home dir of the user whose crontab will be installed.
|
||||
echo "">>$HOME_DIR/crontab # Adds a newline
|
||||
if [[ "$INSTALL_CRONTAB" == "true" ]]; then
|
||||
crontab -u ${USERNAME} $HOME_DIR/crontab # Install the crontab in the given user's home dir.
|
||||
fi
|
||||
done
|
||||
cd .. # exits users folder, which is essential for the next commands
|
||||
fi
|
||||
if [[ "$ONLY_CRONTAB" != "true" && -d "files" ]]; then
|
||||
cd "files"
|
||||
\cp -rL * / # copies all files accross, realising any symbolic links. The backslash escapes the alias cp -i.
|
||||
fi
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl reenable $(find /etc/systemd/system/ -type f) # to recreate all the dependency links.
|
||||
@@ -0,0 +1,88 @@
|
||||
## Path: Development/Hudson
|
||||
## Description: Configuration for the Hudson continuous build server
|
||||
## Type: string
|
||||
## Default: "/var/lib/hudson"
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Directory where Hudson store its configuration and working
|
||||
# files (checkouts, build reports, artifacts, ...).
|
||||
#
|
||||
HUDSON_HOME="/home/hudson/repo"
|
||||
|
||||
## Type: string
|
||||
## Default: ""
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Java executable to run Hudson
|
||||
# When left empty, we'll try to find the suitable Java.
|
||||
#
|
||||
|
||||
HUDSON_JAVA_CMD="/opt/sapjvm_8/bin/java"
|
||||
|
||||
## Type: string
|
||||
## Default: "hudson"
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Unix user account that runs the Hudson daemon
|
||||
# Be careful when you change this, as you need to update
|
||||
# permissions of $HUDSON_HOME and /var/log/hudson.
|
||||
#
|
||||
HUDSON_USER="hudson"
|
||||
|
||||
## Type: string
|
||||
## Default: "-Djava.awt.headless=true"
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Options to pass to java when running Hudson.
|
||||
#
|
||||
HUDSON_JAVA_OPTIONS="-Djava.awt.headless=true -Xmx2G -Dhudson.slaves.ChannelPinger.pingInterval=60 -Dhudson.slaves.ChannelPinger.pingIntervalSeconds=60 -Dhudson.slaves.ChannelPinger.pingTimeoutSeconds=60"
|
||||
|
||||
## Type: integer(0:65535)
|
||||
## Default: 8080
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Port Hudson is listening on.
|
||||
#
|
||||
HUDSON_PORT="8080"
|
||||
|
||||
## Type: integer(1:9)
|
||||
## Default: 5
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Debug level for logs -- the higher the value, the more verbose.
|
||||
# 5 is INFO.
|
||||
#
|
||||
HUDSON_DEBUG_LEVEL="5"
|
||||
|
||||
## Type: yesno
|
||||
## Default: no
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Whether to enable access logging or not.
|
||||
#
|
||||
HUDSON_ENABLE_ACCESS_LOG="no"
|
||||
|
||||
## Type: integer
|
||||
## Default: 100
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Maximum number of HTTP worker threads.
|
||||
#
|
||||
HUDSON_HANDLER_MAX="100"
|
||||
|
||||
## Type: integer
|
||||
## Default: 20
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Maximum number of idle HTTP worker threads.
|
||||
#
|
||||
HUDSON_HANDLER_IDLE="20"
|
||||
|
||||
## Type: string
|
||||
## Default: ""
|
||||
## ServiceRestart: hudson
|
||||
#
|
||||
# Pass arbitrary arguments to Hudson.
|
||||
# Full option list: java -jar hudson.war --help
|
||||
#
|
||||
HUDSON_ARGS=""
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=The Hudson start-up / shut-down service
|
||||
Requires=-.mount
|
||||
After=-.mount
|
||||
|
||||
[Install]
|
||||
RequiredBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/etc/init.d/hudson start
|
||||
ExecStop=/etc/init.d/hudson stop
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/etc/systemd/system/mountnvmeswap.service
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/getLatestImageOfType.sh
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
#!/bin/sh
|
||||
# Check for missing binaries (stale symlinks should not happen)
|
||||
HUDSON_WAR="/usr/lib/hudson/hudson.war"
|
||||
test -r "$HUDSON_WAR" || { echo "$HUDSON_WAR not installed";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 5; fi; }
|
||||
|
||||
# Check for existence of needed config file and read it
|
||||
HUDSON_CONFIG=/etc/sysconfig/hudson
|
||||
test -e "$HUDSON_CONFIG" || { echo "$HUDSON_CONFIG not existing";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 6; fi; }
|
||||
test -r "$HUDSON_CONFIG" || { echo "$HUDSON_CONFIG not readable. Perhaps you forgot 'sudo'?";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 6; fi; }
|
||||
|
||||
HUDSON_PID_FILE="/var/run/hudson.pid"
|
||||
HUDSON_USER="hudson"
|
||||
HUDSON_GROUP="hudson"
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
# Read config
|
||||
[ -f "$HUDSON_CONFIG" ] && . "$HUDSON_CONFIG"
|
||||
|
||||
# Set up environment accordingly to the configuration settings
|
||||
[ -n "$HUDSON_HOME" ] || { echo "HUDSON_HOME not configured in $HUDSON_CONFIG";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 6; fi; }
|
||||
[ -d "$HUDSON_HOME" ] || { echo "HUDSON_HOME directory does not exist: $HUDSON_HOME";
|
||||
if [ "$1" = "stop" ]; then exit 0;
|
||||
else exit 1; fi; }
|
||||
export HUDSON_HOME
|
||||
|
||||
# Search usable Java. We do this because various reports indicated
|
||||
# that /usr/bin/java may not always point to Java 1.5
|
||||
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
|
||||
for candidate in /usr/lib/jvm/java-1.6.0/bin/java /usr/lib/jvm/jre-1.6.0/bin/java /usr/lib/jvm/java-1.5.0/bin/java /usr/lib/jvm/jre-1.5.0/bin/java /usr/bin/java
|
||||
do
|
||||
[ -x "$HUDSON_JAVA_CMD" ] && break
|
||||
HUDSON_JAVA_CMD="$candidate"
|
||||
done
|
||||
|
||||
JAVA_CMD="$HUDSON_JAVA_CMD $HUDSON_JAVA_OPTIONS -DHUDSON_HOME=$HUDSON_HOME -jar $HUDSON_WAR"
|
||||
PARAMS="--logfile=/var/log/hudson/hudson.log --daemon"
|
||||
[ -n "$HUDSON_PORT" ] && PARAMS="$PARAMS --httpPort=$HUDSON_PORT"
|
||||
[ -n "$HUDSON_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$HUDSON_DEBUG_LEVEL"
|
||||
[ -n "$HUDSON_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$HUDSON_HANDLER_STARTUP"
|
||||
[ -n "$HUDSON_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$HUDSON_HANDLER_MAX"
|
||||
[ -n "$HUDSON_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$HUDSON_HANDLER_IDLE"
|
||||
[ -n "$HUDSON_ARGS" ] && PARAMS="$PARAMS $HUDSON_ARGS"
|
||||
|
||||
if [ "$HUDSON_ENABLE_ACCESS_LOG" = "yes" ]; then
|
||||
PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/hudson/access_log"
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting Hudson "
|
||||
daemon --user "$HUDSON_USER" --pidfile "$HUDSON_PID_FILE" "$JAVA_CMD" "$PARAMS" &> /var/tmp/hudson.log &
|
||||
RETVAL=$?
|
||||
if [ $RETVAL = 0 ]; then
|
||||
success
|
||||
echo > "$HUDSON_PID_FILE" # just in case we fail to find it
|
||||
MY_SESSION_ID=`/bin/ps h -o sess -p $$`
|
||||
# get PID
|
||||
/bin/ps hww -u "$HUDSON_USER" -o sess,ppid,pid,cmd | \
|
||||
while read sess ppid pid cmd; do
|
||||
[ "$ppid" = 1 ] || continue
|
||||
# this test doesn't work because Hudson sets a new Session ID
|
||||
# [ "$sess" = "$MY_SESSION_ID" ] || continue
|
||||
echo "$cmd" | grep $HUDSON_WAR > /dev/null
|
||||
[ $? = 0 ] || continue
|
||||
# found a PID
|
||||
echo $pid > "$HUDSON_PID_FILE"
|
||||
done
|
||||
else
|
||||
failure
|
||||
fi
|
||||
echo
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down Hudson "
|
||||
killproc hudson
|
||||
RETVAL=$?
|
||||
echo
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
if test "$1" = "condrestart"; then
|
||||
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
|
||||
fi
|
||||
$0 status
|
||||
if test $? = 0; then
|
||||
$0 restart
|
||||
else
|
||||
: # Not running is not a failure.
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
force-reload)
|
||||
echo -n "Reload service Hudson "
|
||||
$0 try-restart
|
||||
;;
|
||||
reload)
|
||||
$0 restart
|
||||
;;
|
||||
status)
|
||||
status hudson
|
||||
RETVAL=$?
|
||||
;;
|
||||
probe)
|
||||
## Optional: Probe for the necessity of a reload, print out the
|
||||
## argument to this init script which is required for a reload.
|
||||
## Note: probe is not (yet) part of LSB (as of 1.9)
|
||||
|
||||
test "$HUDSON_CONFIG" -nt "$HUDSON_PID_FILE" && echo reload
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Enable sudo for user hudson for this script by adding the following to /etc/sudoers.d/hudsoncanlaunchec2instances:
|
||||
# hudson ALL = (root) NOPASSWD: /usr/local/bin/launchhudsonslave
|
||||
# hudson ALL = (root) NOPASSWD: /usr/local/bin/launchhudsonslave-java11
|
||||
# hudson ALL = (root) NOPASSWD: /usr/local/bin/getLatestImageOfType.sh
|
||||
AWS=/bin/aws
|
||||
REGION=eu-west-1
|
||||
HUDSON_SLAVE_AMI_ID=$( /usr/local/bin/getLatestImageOfType.sh hudson-slave )
|
||||
echo Launching instance from AMI ${HUDSON_SLAVE_AMI_ID} ...
|
||||
instanceid=`$AWS ec2 run-instances --image-id $HUDSON_SLAVE_AMI_ID --count 1 --instance-type c5d.4xlarge --key-name Axel --security-groups "Sailing Analytics App" --region $REGION --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=Hudson Build Instance}]' --instance-initiated-shutdown-behavior terminate | tee /tmp/slavelaunch.out | jq .Instances[0].InstanceId | sed -e 's/"//g'`
|
||||
if [ "$instanceid" = "" ]; then
|
||||
echo Error launching instance
|
||||
exit 1
|
||||
else
|
||||
echo Instance ID is $instanceid
|
||||
while [ "`$AWS ec2 describe-instances --region $REGION --instance-ids $instanceid | jq .Reservations[0].Instances[0].State.Name`" != "\"running\"" ]; do
|
||||
echo Instance $instanceid not running yet\; trying again...
|
||||
sleep 5
|
||||
done
|
||||
echo Instance $instanceid seems running now
|
||||
private_ip=`$AWS ec2 describe-instances --region $REGION --instance-ids $instanceid | jq .Reservations[0].Instances[0].PrivateIpAddress | sed -e 's/"//g'`
|
||||
echo Probing for SSH on private IP $private_ip
|
||||
# Note: it's important to redirect stdin/stdout from/to /dev/null to ensure the Hudon master can properly connect stdin/stdout to the slave later
|
||||
while ! su - hudson -c "ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no hudson@$private_ip mkdir -p /home/hudson/workspace/___test___\; rmdir /home/hudson/workspace/___test___ </dev/null >/dev/null 2>/dev/null"; do
|
||||
echo SSH daemon not reachable yet. Trying again in a few seconds...
|
||||
sleep 10
|
||||
done
|
||||
echo SSH daemon reached. State should be ready to connect to now.
|
||||
su - hudson -c "ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no hudson@$private_ip \"/opt/sapjvm_8/bin/java -jar slave.jar; sudo /sbin/shutdown -h now\""
|
||||
$AWS ec2 terminate-instances --instance-ids $instanceid
|
||||
fi
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Enable sudo for user hudson for this script by adding the following to /etc/sudoers.d/hudsoncanlaunchec2instances:
|
||||
# hudson ALL = (root) NOPASSWD: /usr/local/bin/launchhudsonslave
|
||||
# hudson ALL = (root) NOPASSWD: /usr/local/bin/launchhudsonslave-java11
|
||||
# hudson ALL = (root) NOPASSWD: /usr/local/bin/getLatestImageOfType.sh
|
||||
AWS=/usr/bin/aws
|
||||
REGION=eu-west-1
|
||||
HUDSON_SLAVE_AMI_ID=$( /usr/local/bin/getLatestImageOfType.sh hudson-slave-11 )
|
||||
echo Launching instance from AMI ${HUDSON_SLAVE_AMI_ID} ...
|
||||
instanceid=`$AWS ec2 run-instances --image-id $HUDSON_SLAVE_AMI_ID --count 1 --instance-type c5d.4xlarge --key-name Axel --security-groups "Sailing Analytics App" --region $REGION --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=Hudson Ubuntu Slave Java 11}]' --instance-initiated-shutdown-behavior terminate | tee /tmp/slavelaunch.out | jq .Instances[0].InstanceId | sed -e 's/"//g'`
|
||||
if [ "$instanceid" = "" ]; then
|
||||
echo Error launching instance
|
||||
exit 1
|
||||
else
|
||||
echo Instance ID is $instanceid
|
||||
while [ "`$AWS ec2 describe-instances --region $REGION --instance-ids $instanceid | jq .Reservations[0].Instances[0].State.Name`" != "\"running\"" ]; do
|
||||
echo Instance $instanceid not running yet\; trying again...
|
||||
sleep 5
|
||||
done
|
||||
echo Instance $instanceid seems running now
|
||||
private_ip=`$AWS ec2 describe-instances --region $REGION --instance-ids $instanceid | jq .Reservations[0].Instances[0].PrivateIpAddress | sed -e 's/"//g'`
|
||||
echo Probing for SSH on private IP $private_ip
|
||||
# Note: it's important to redirect stdin/stdout from/to /dev/null to ensure the Hudon master can properly connect stdin/stdout to the slave later
|
||||
while ! su - hudson -c "ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no hudson@$private_ip mkdir -p /home/hudson/workspace/___test___\; rmdir /home/hudson/workspace/___test___ </dev/null >/dev/null 2>/dev/null"; do
|
||||
echo SSH daemon not reachable yet. Trying again in a few seconds...
|
||||
sleep 10
|
||||
done
|
||||
echo SSH daemon reached. State should be ready to connect to now.
|
||||
su - hudson -c "ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no hudson@$private_ip \"/opt/sapjvm_8/bin/java -jar slave.jar; sudo /sbin/shutdown -h now\""
|
||||
$AWS ec2 terminate-instances --instance-ids $instanceid
|
||||
fi
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/mountnvmeswap
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers_if_changed
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-authorized-keys
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
# Enables the trac user, on all hosts, to execute commands as the root user. It can do this without a password but only to run the given command.
|
||||
trac ALL = (root) NOPASSWD: /usr/local/bin/push_hyperspace_to_github_tools_sap
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Enables the apache user, on all hosts, to execute commands as the wiki user. This can be done without a password for
|
||||
# running git, and all of its commands.
|
||||
apache ALL = (wiki) NOPASSWD: /usr/bin/git
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/etc/systemd/system/mountnvmeswap.service
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Purpose: Deployed in a file named "post-receive", in the hooks dir of a bare git repo. Upon push completion, this script runs and
|
||||
# triggers an update to instances in the region with a specified tag. A command is ran in the repo
|
||||
# after the merge completes. The user, in which the bare repo and hook are installed, must have aws credentials, that
|
||||
# don't need mfa. (These may need to be installed manually -- within the correct user -- if starting from a clean instance.)
|
||||
|
||||
TAG="ReverseProxy"
|
||||
DIR="/etc/httpd"
|
||||
COMMAND="sudo service httpd reload"
|
||||
MAIN_BRANCH_NAME="main"
|
||||
while read oldrev newrev refname; do # These vars are passed on stdin to this hook.
|
||||
# Check if the update is on a branch
|
||||
if [[ $refname == "refs/heads/"* ]]; then
|
||||
branch_name=$(echo $refname | sed "s|refs/heads/\(.*\)$|\1|")
|
||||
echo "Update on branch: $branch_name"
|
||||
if [[ "$branch_name" == "$MAIN_BRANCH_NAME" ]]; then
|
||||
# Gets all public ips for the instances with the chosen tag and iterates over the IPs.
|
||||
for IP in $(aws ec2 describe-instances --filters Name=tag-key,Values="${TAG}" | jq -r '.Reservations[].Instances[].PublicIpAddress'); do
|
||||
# strictHostKey... means no authenticity check. The sync-repo... script must be installed in the root user's home.
|
||||
echo "Connecting to $IP"
|
||||
ssh -o "StrictHostKeyChecking=no" root@${IP} "cd ~ && /usr/local/bin/sync-repo-and-execute-cmd.sh '${DIR}' '${COMMAND}' ";
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
MONGODBS="mongodb://dbserver.internal.sapsailing.com:10201/?replicaSet=archive mongodb://dbserver.internal.sapsailing.com:10202/?replicaSet=slow mongodb://dbserver.internal.sapsailing.com:10203/?replicaSet=live"
|
||||
#MAILINGLIST="/home/trac/mailinglists/unhealthy-mongo-list"
|
||||
MAILINGLIST=$(cat /var/cache/landscapeManagersMailingList)
|
||||
for db in $MONGODBS; do
|
||||
echo "rs.status()" | mongo --quiet "$db" | grep '\("set"\)\|\("name"\)\|\("health"\)\|\("stateStr"\)' | sed -e 's/^.* : "\?//' -e 's/"\?,$//' | (
|
||||
read replicaset
|
||||
while read server; do
|
||||
read health
|
||||
read state
|
||||
if [ "$health" != "1" ]; then
|
||||
echo "MongoDB replica set $replicaset unhealthy, node $server is in state $state\
|
||||
|
||||
Check status of $db urgently. To unsubscribe, change $MAILINGLIST on `hostname`." | mail -s "MongoDB Replica Set \"$replicaset\" Unhealthy" `cat "$MAILINGLIST"`
|
||||
fi
|
||||
done
|
||||
)
|
||||
done
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# set up some constants
|
||||
## Manage2Sail
|
||||
M2SURL="http://manage2sail.com"
|
||||
M2SEVENTID="fa9f5552-68a4-4712-b84b-ece0f36af8e8"
|
||||
M2SACCESSTOKEN="bDAv8CwsTM94ujZ"
|
||||
M2SSTRING=${M2SURL}"/api/public/links/event/"${M2SEVENTID}"?accesstoken="${M2SACCESSTOKEN}"&mediaType=json"
|
||||
## Local JSON
|
||||
LOCALJSON="/tmp/euros49er2023results.json"
|
||||
LOCALJSON_OLD=$LOCALJSON.old
|
||||
## Mails
|
||||
MAILINGLIST="/home/trac/mailinglists/euros49er2023"
|
||||
## Eventname
|
||||
EVENTNAME="49er Euros 2023"
|
||||
## Misc
|
||||
DOSENDMAIL=false
|
||||
|
||||
### ROUTINE ###
|
||||
# get current json from manage2sail
|
||||
wget -O "$LOCALJSON" "$M2SSTRING" >/dev/null 2>&1
|
||||
if [ -f "$LOCALJSON_OLD" ]; then
|
||||
# results previously downloaded; now compare
|
||||
# sort by manage2sail Regattas.Id
|
||||
echo Comparing $LOCALJSON and $LOCALJSON_OLD
|
||||
LOCALJSON_SORTED="${LOCALJSON}.sorted"
|
||||
LOCALJSON_OLD_SORTED="${LOCALJSON_OLD}.sorted"
|
||||
cat "$LOCALJSON" | jq -r '.Regattas|sort_by(.Name)' >"$LOCALJSON_SORTED"
|
||||
cat "$LOCALJSON_OLD" | jq -r '.Regattas|sort_by(.Name)' >"$LOCALJSON_OLD_SORTED"
|
||||
# filter only necessary values
|
||||
LOCALJSON_FORMATTED="${LOCALJSON}.formatted"
|
||||
LOCALJSON_OLD_FORMATTED="${LOCALJSON_OLD}.formatted"
|
||||
cat "$LOCALJSON_SORTED" | jq -r '.[]|{Final, LastPublishedRoundName, Published, Name, ClassName, Id}|select(.Published != null)' >"$LOCALJSON_FORMATTED"
|
||||
cat "$LOCALJSON_OLD_SORTED" | jq -r '.[]|{Final, LastPublishedRoundName, Published, Name, ClassName, Id}|select(.Published != null)' >"$LOCALJSON_OLD_FORMATTED"
|
||||
# diff sorted+formatted json
|
||||
diff --brief <(sort ${LOCALJSON_OLD_FORMATTED}) <(sort ${LOCALJSON_FORMATTED}) >/dev/null 2>&1
|
||||
comp_value=$?
|
||||
if [ $comp_value -eq 1 ]; then
|
||||
echo "Found diff between $LOCALJSON_OLD_FORMATTED and $LOCALJSON_FORMATTED
|
||||
|
||||
`diff -q "$LOCALJSON_OLD_FORMATTED" "$LOCALJSON_FORMATTED"`
|
||||
|
||||
Sending mail."
|
||||
DOSENDMAIL=true
|
||||
fi
|
||||
fi
|
||||
if [ "$DOSENDMAIL" = "true" ]; then
|
||||
echo "`date` Sending mail to `cat "$MAILINGLIST"`"
|
||||
echo "$LOCALJSON has changed. Consider re-importing results for $EVENTNAME. Differences:
|
||||
|
||||
------------------
|
||||
`diff -U 6 "$LOCALJSON_OLD_FORMATTED" "$LOCALJSON_FORMATTED"`
|
||||
------------------
|
||||
|
||||
To unsubscribe, change $MAILINGLIST on `hostname`." | mail -s "SAP result import update: $EVENTNAME" `cat "$MAILINGLIST" | grep -v "^#"`
|
||||
fi
|
||||
|
||||
# move to old
|
||||
mv "$LOCALJSON" "$LOCALJSON_OLD"
|
||||
# clean up temporary files
|
||||
#rm -rf "$LOCALJSON_SORTED" "$LOCALJSON_OLD_SORTED" "$LOCALJSON_FORMATTED" "$LOCALJSON_OLD_FORMATTED"
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# This hook executes once for the receive operation. It takes no arguments, but for each ref to be updated it receives on
|
||||
# standard input a line of the format:
|
||||
#
|
||||
# <old-value> SP <new-value> SP <ref-name> LF
|
||||
#
|
||||
REFS=$( cat )
|
||||
curl https://postreceive:ohfa7083.98@hudson.sapsailing.com/git/notifyCommit?url=ssh://trac@sapsailing.com/home/trac/git
|
||||
if echo "$REFS" | awk '{ print $3; }' | grep "\<hyperspace\>"; then
|
||||
sudo /usr/local/bin/push_hyperspace_to_github_tools_sap
|
||||
fi
|
||||
+1
@@ -0,0 +1 @@
|
||||
axel.uhl@sap.com
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Downloads all TracTrac event data based on ${GIT_ROOT}/configuration/tractrac-json-urls
|
||||
# into the target directory (specified as $1) for those event URLs whose specific folder
|
||||
# does not yet exist in the target directory.
|
||||
TARGET_DIR="${1}"
|
||||
if [[ $# -eq 1 ]]; then
|
||||
GIT_ROOT=/home/wiki/gitwiki
|
||||
else
|
||||
GIT_ROOT="${2}"
|
||||
fi
|
||||
JSON_URLS_FILE="${GIT_ROOT}/configuration/tractrac-json-urls"
|
||||
for i in `cat "${JSON_URLS_FILE}"`; do
|
||||
EVENT_DB="$( basename $( dirname ${i} ) )"
|
||||
if [ -d "${TARGET_DIR}/${EVENT_DB}" ]; then
|
||||
echo "Directory for event ${EVENT_DB} already found. Not downloading again. Use"
|
||||
echo " ${GIT_ROOT}/configuration/downloadTracTracEvent ${i} ${TARGET_DIR}"
|
||||
echo "to force an update."
|
||||
else
|
||||
echo "Did not find directory for event ${EVENT_DB} yet in ${TARGET_DIR}. Downloading..."
|
||||
${GIT_ROOT}/configuration/downloadTracTracEvent "${i}" "${TARGET_DIR}"
|
||||
fi
|
||||
done
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo Number of events on my.sapsailing.com: $( ssh ec2-user@dbserver.internal.sapsailing.com "echo 'db.EVENTS.find().count()' | mongo --quiet 'mongodb://127.0.0.1:10203/my?replicaSet=live&retryWrites=true&readPreference=nearest' 2>/dev/null | tail -n 1" ) | mail -s "Events on my.sapsailing.com" axel.uhl@sap.com marcus.baur@sapsailing.com
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/mountnvmeswap
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/notify-operators
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Pushes the git bare to the hyperspace branch used for mobile builds. Ran as root to access the private
|
||||
# access token but uses su to execute git commands as the trac user.
|
||||
PAT=$( cat /root/github_tools_sap.pat )
|
||||
su - trac -c "cd /home/trac/git; git push https://${PAT}@github.tools.sap/SAP-Sailing-Analytics/sapsailing hyperspace:hyperspace"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/switchoverArchive.sh
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/sync-repo-and-execute-cmd.sh
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/syncgit
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
GIT_ROOT=/home/wiki/gitwiki
|
||||
else
|
||||
GIT_ROOT=$1
|
||||
fi
|
||||
PATH_TO_TRAC_TRAC_URLS="configuration/tractrac-json-urls"
|
||||
urls=$(mongo --quiet "mongodb://dbserver.internal.sapsailing.com:10201/winddb?replicaSet=archive" --eval 'db.TRACTRAC_CONFIGURATIONS.find({}, {TT_CONFIG_JSON_URL : 1}).toArray()' | grep -v ObjectId | jq -r '.[].TT_CONFIG_JSON_URL' )
|
||||
if [[ $urls == "null" || $? -ne 0 ]]; then
|
||||
echo "Mongo db returns null for tractrac url discovery" | notify-operators "MongoDB/tractrac urls issue"
|
||||
exit 1
|
||||
else
|
||||
echo "${urls}" | sort -u >"${GIT_ROOT}/${PATH_TO_TRAC_TRAC_URLS}"
|
||||
cd "${GIT_ROOT}"
|
||||
git add "${GIT_ROOT}/${PATH_TO_TRAC_TRAC_URLS}"
|
||||
git commit -m "Updated tractrac-json-urls"
|
||||
git push
|
||||
fi
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers_if_changed
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_landscape_managers_mailing_list.sh
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
echo "
|
||||
"
|
||||
BODY=$( cat )
|
||||
echo "${BODY}" >/tmp/github-hook-body
|
||||
REF=$( echo "${BODY}" | jq -r '.ref' )
|
||||
PUSHER=$( echo "${BODY}" | jq -r '.pusher.email' )
|
||||
logger -t github-cgi "ref ia $REF, pusher was $PUSHER"
|
||||
# For testing:
|
||||
#if [ "${PUSHER}" = "axel.uhl@sap.com" -a "${REF}" = "refs/heads/translation" ]; then
|
||||
if [ "${PUSHER}" = "tmsatsls+github.tools.sap_service-tip-git@sap.com" -a "${REF}" = "refs/heads/translation" ]; then
|
||||
echo "Identified a push to refs/heads/translation by ${PUSHER}."
|
||||
echo "Fetching translation branch from github.tools.sap and pushing it to ssh://trac@sapsailing.com/home/trac/git"
|
||||
logger -t github-cgi "fetching translation branch from github.tools.sap and pushing it to ssh://trac@sapsailing.com/home/trac/git"
|
||||
cd /home/wiki/gitwiki
|
||||
sudo -u wiki git fetch sapsailing translation:translation 2>&1
|
||||
sudo -u wiki git push origin translation:translation 2>&1
|
||||
else
|
||||
echo "Either pusher was not tmsatsls+github.tools.sap_service-tip-git@sap.com or ref was not refs/heads/translation. Not triggering."
|
||||
fi
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-docker-registry-gc
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-mail-events-on-my
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-switchoverArchive
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-authorized-keys
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-landscape-managers-mailing-list
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-manage2sail-example
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-mongo-health-check
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-download-new-archived-trac-trac-events
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-syncgit
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-trac-trac-urls
|
||||
@@ -0,0 +1,5 @@
|
||||
Deploy the .mount and .service units to /etc/systemd/system.
|
||||
Deploy the imageupgrade script to /usr/local/bin,
|
||||
furthermore the ../imageupgrade_functions.sh has to go to /usr/local/bin, best as symbolic link to files in git.
|
||||
|
||||
See the script in wiki/howto/development/ci.md that shows how to set up such an instance from scratch.
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/etc/systemd/system/imageupgrade.service
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Mount Hudson Workspace
|
||||
After=ephemeral-data.mount
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/mounthudsonworkspace
|
||||
RemainAfterExit=true
|
||||
StandardOutput=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to deploy on an instance that has an ephemeral volume as /dev/nvme0n1 (adjust env var PARTITION if different)
|
||||
# Ensures the partition is xfs-formatted, any existing partition contents will be overwritten if formatted otherwise.
|
||||
# An existing xfs partition will be left alone.
|
||||
. imageupgrade_functions.sh
|
||||
|
||||
get_ec2_user_data() {
|
||||
/usr/bin/ec2metadata --user
|
||||
}
|
||||
|
||||
METADATA=$( get_ec2_user_data )
|
||||
echo "Metadata: ${METADATA}"
|
||||
if echo "${METADATA}" | grep -q "^image-upgrade$"; then
|
||||
echo "Image upgrade..."
|
||||
LOGON_USER_HOME=/home/ubuntu
|
||||
run_apt_update_upgrade
|
||||
download_and_install_latest_sap_jvm_8
|
||||
run_git_pull
|
||||
finalize
|
||||
fi
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# Expects an ephemeral volume to have been mounted at /ephemeral/data and
|
||||
# mounts that with a "bind" mount to /home/hudson/workspace.
|
||||
# The directory is then chown/chgrp'ed to hudson
|
||||
if [ -e /dev/nvme1n1 ]; then
|
||||
mkfs.ext4 /dev/nvme1n1
|
||||
mount /dev/nvme1n1 /home/hudson/workspace
|
||||
else
|
||||
mount -o bind /ephemeral/data /home/hudson/workspace
|
||||
fi
|
||||
chgrp hudson /home/hudson/workspace
|
||||
chown hudson /home/hudson/workspace
|
||||
@@ -0,0 +1,16 @@
|
||||
Deploy the .mount and .service units to /etc/systemd/system.
|
||||
Deploy the ephemeralvolume and the patch-mongo-replicaset-name-from-ec2-metadata script to /usr/local/bin,
|
||||
furthermore the ../imageupgrade_functions.sh has to go to /usr/local/bin.
|
||||
Deploy mongod.conf to /etc and make sure that /root has a+r and a+x permissions because
|
||||
otherwise the mongod user won't be able to read through the symbolic link
|
||||
Link mongodb to /etc/logrotate.d
|
||||
Link the crontab-mongo, in configuration/crontabs/environments, to /root/crontab and run "crontab crontab" as root.
|
||||
|
||||
Run with optional EC2 user detail, e.g., as follows:
|
||||
|
||||
REPLICA_SET_NAME=archive
|
||||
REPLICA_SET_PRIMARY=dbserver.internal.sapsailing.com:10201
|
||||
|
||||
This will automatically patch /etc/mongod.conf such that the replSetName property
|
||||
is set to the value of REPLICA_SET_NAME. Then, the instance will be added to
|
||||
the REPLICA_SET_PRIMARY's replica set.
|
||||
@@ -0,0 +1,9 @@
|
||||
compress
|
||||
/var/log/mongodb/mongod.log
|
||||
{
|
||||
rotate 5
|
||||
weekly
|
||||
postrotate
|
||||
/usr/bin/killall -SIGUSR1 mongod
|
||||
endscript
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
# mongod.conf
|
||||
|
||||
# for documentation of all options, see:
|
||||
# http://docs.mongodb.org/manual/reference/configuration-options/
|
||||
|
||||
# where to write logging data.
|
||||
systemLog:
|
||||
destination: file
|
||||
logAppend: true
|
||||
path: /var/log/mongodb/mongod.log
|
||||
|
||||
# Where and how to store data.
|
||||
storage:
|
||||
dbPath: /var/lib/mongo
|
||||
journal:
|
||||
enabled: true
|
||||
directoryPerDB: true
|
||||
# engine:
|
||||
# mmapv1:
|
||||
# wiredTiger:
|
||||
|
||||
# how the process runs
|
||||
processManagement:
|
||||
fork: true # fork and run in background
|
||||
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
|
||||
timeZoneInfo: /usr/share/zoneinfo
|
||||
|
||||
# network interfaces
|
||||
net:
|
||||
port: 27017
|
||||
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
|
||||
# bindIp: 172.31.33.146
|
||||
bindIp: 0.0.0.0
|
||||
|
||||
#security:
|
||||
|
||||
#operationProfiling:
|
||||
|
||||
replication:
|
||||
replSetName: "live"
|
||||
|
||||
#sharding:
|
||||
|
||||
## Enterprise-Only Options
|
||||
|
||||
#auditLog:
|
||||
|
||||
#snmp:
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Ensures all files under /var/lib/mongo are owned by mongod user/group
|
||||
Requires=ephemeralvolume.service
|
||||
After=ephemeralvolume.service
|
||||
Before=mongod.service
|
||||
|
||||
[Install]
|
||||
RequiredBy=mongod.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/bin/chown -R mongod /var/lib/mongo/
|
||||
ExecStart=/bin/chgrp -R mongod /var/lib/mongo/
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Ensures /dev/nvme0n1 or /dev/xvdb is XFS-formatted
|
||||
Requires=-.mount cloud-init.service network.service
|
||||
After=-.mount cloud-init.service network.service
|
||||
|
||||
[Install]
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/usr/local/bin/ephemeralvolume
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=If REPLICA_SET_NAME EC2 user data is provided, add this node to the replica set of REPLICA_SET_PRIMARY
|
||||
Requires=mongod.service
|
||||
After=mongod.service
|
||||
Requires=cloud-init.service
|
||||
After=cloud-init.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/usr/local/bin/add-as-replica
|
||||
ExecStop=/usr/local/bin/remove-as-replica
|
||||
TimeoutStopSec=120s
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Check EC2 metadata for MongoDB Replica Set Name and patch /etc/mongod.conf accordingly
|
||||
Requires=ephemeralvolume.service
|
||||
After=ephemeralvolume.service
|
||||
Requires=cloud-init.service
|
||||
After=cloud-init.service
|
||||
Before=mongod.service
|
||||
|
||||
[Install]
|
||||
RequiredBy=mongod.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/usr/local/bin/patch-mongo-replicaset-name-from-ec2-metadata
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
user_data=$( ec2-metadata -d | sed -e 's/^user-data: //' )
|
||||
if echo ${user_data} | grep -q "^image-upgrade$"; then
|
||||
echo "Image upgrade... didn't expect to get this far because ephemeralvolume should have triggered upgrade and shutdown. Not registering MongoDB replica"
|
||||
else
|
||||
eval ${user_data}
|
||||
if [ -z "$REPLICA_SET_NAME" ]; then
|
||||
REPLICA_SET_NAME=live
|
||||
fi
|
||||
if [ -z "$REPLICA_SET_PRIMARY" ]; then
|
||||
REPLICA_SET_PRIMARY=mongo0.internal.sapsailing.com:27017
|
||||
fi
|
||||
if [ -z "$REPLICA_SET_PRIORITY" ]; then
|
||||
REPLICA_SET_PRIORITY=1
|
||||
fi
|
||||
if [ -z "$REPLICA_SET_VOTES" ]; then
|
||||
REPLICA_SET_VOTES=0
|
||||
fi
|
||||
if [ \! -z "REPLICA_SET_PRIMARY" ]; then
|
||||
IP=$(ec2-metadata -o | sed -e 's/^local-ipv4: //')
|
||||
echo "rs.add({host: \"$IP:27017\", priority: $REPLICA_SET_PRIORITY, votes: $REPLICA_SET_VOTES})" | mongo "mongodb://$REPLICA_SET_PRIMARY/?replicaSet=$REPLICA_SET_NAME&retryWrites=true"
|
||||
else
|
||||
echo "rs.initiate()" | mongo
|
||||
fi
|
||||
fi
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to deploy on an instance that has an ephemeral volume as /dev/nvme0n1 (adjust env var PARTITION if different)
|
||||
# Ensures the partition is xfs-formatted, any existing partition contents will be overwritten if formatted otherwise.
|
||||
# An existing xfs partition will be left alone.
|
||||
|
||||
METADATA=$( /bin/ec2-metadata -d | sed -e 's/^user-data: //' )
|
||||
echo "Metadata: ${METADATA}"
|
||||
if echo "${METADATA}" | grep -q "^image-upgrade$"; then
|
||||
echo "Image upgrade; not trying to mount/format ephemeral volume; calling imageupgrade.sh instead..."
|
||||
imageupgrade.sh
|
||||
else
|
||||
echo "No image upgrade; looking for ephemeral volume and trying to format with xfs..."
|
||||
PARTITION=/dev/nvme0n1
|
||||
if [ \! -e $PARTITION ]; then
|
||||
PARTITION=/dev/xvdb
|
||||
fi
|
||||
if [ \! -e $PARTITION ]; then
|
||||
echo "Neither /dev/nvme0n1 nor /dev/xvdb partition found; not formatting/mounting ephemeral volume"
|
||||
elif cat /proc/mounts | awk '{print $1;}' | grep "${PARTITION}"; then
|
||||
echo "Partition ${PARTITION} already mounted; not formatting/mounting ephemeral volume"
|
||||
else
|
||||
FSTYPE=$(blkid -p $PARTITION -s TYPE -o value)
|
||||
if [ "$FSTYPE" != "xfs" ]; then
|
||||
echo FSTYPE was "$FSTYPE" but should have been xfs. Formatting $PARTITION...
|
||||
mkfs.xfs -f $PARTITION
|
||||
else
|
||||
echo FSTYPE was "$FSTYPE" which is just right :-\)
|
||||
fi
|
||||
# mount the thing to /var/lib/mongo
|
||||
mount $PARTITION /var/lib/mongo
|
||||
fi
|
||||
fi
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Upgrades the AWS EC2 MongoDB instance that this script is assumed to be executed on.
|
||||
# The steps are as follows:
|
||||
|
||||
. imageupgrade_functions.sh
|
||||
|
||||
run_git_pull_root() {
|
||||
echo "Pulling git to /root/code" >>/var/log/sailing.err
|
||||
cd /root/code
|
||||
git pull
|
||||
}
|
||||
|
||||
clean_mongo_pid() {
|
||||
rm -f /var/run/mongodb/mongod.pid
|
||||
}
|
||||
|
||||
LOGON_USER_HOME=/home/ec2-user
|
||||
|
||||
run_yum_update
|
||||
run_git_pull_root
|
||||
clean_startup_logs
|
||||
update_root_crontab
|
||||
clean_mongo_pid
|
||||
finalize
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/imageupgrade_functions.sh
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
REPLICA_SET_NAME=$(ec2-metadata | grep REPLICA_SET_NAME | sed -e 's/^user-data: //' | sed -e 's/^REPLICA_SET_NAME=//')
|
||||
echo Replica set name: $REPLICA_SET_NAME
|
||||
if [ \! -z "$REPLICA_SET_NAME" ]; then
|
||||
echo "Not empty. Patching /etc/mongod.conf..."
|
||||
sed -i -e "s/replSetName: .*$/replSetName: $REPLICA_SET_NAME/" /etc/mongod.conf
|
||||
echo "Done"
|
||||
fi
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
eval $( ec2-metadata -d | sed -e 's/^user-data: //' )
|
||||
if [ \! -z "REPLICA_SET_PRIMARY" ]; then
|
||||
IP=$(ec2-metadata -o | sed -e 's/^local-ipv4: //')
|
||||
echo "rs.remove(\"$IP:27017\")" | mongo "mongodb://$REPLICA_SET_PRIMARY/?replicaSet=$REPLICA_SET_NAME&retryWrites=true"
|
||||
fi
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers_if_changed
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-authorized-keys
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-authorized-keys-ec2-user
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers_if_changed
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-authorized-keys
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../../repo/usr/local/bin/update_authorized_keys_for_landscape_managers_if_changed
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../crontabs/crontab-update-authorized-keys
|
||||
@@ -0,0 +1 @@
|
||||
rc.d/init.d
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# mountnvmeswap Formats and mounts a yet unpartitioned NVMe volume as swap
|
||||
#
|
||||
# chkconfig: 2345 95 10
|
||||
# description: Formats and mounts a yet unpartitioned NVMe volume as swap
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mountnvmeswap
|
||||
# Required-Start: $local_fs $network
|
||||
# Should-Start:
|
||||
# Required-Stop:
|
||||
# Should-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Formats and mounts a yet unpartitioned NVMe volume as swap
|
||||
# Description: Formats and mounts a yet unpartitioned NVMe volume as swap
|
||||
### END INIT INFO
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
/usr/local/bin/mountnvmeswap
|
||||
;;
|
||||
stop)
|
||||
;;
|
||||
status)
|
||||
swapon -s | grep /dev/nvme0n1
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|status|stop}"
|
||||
RETVAL=3
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
Loaded 100 of 807 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user