Commit 3b1d88b6 authored by Alejandro Suarez Costa's avatar Alejandro Suarez Costa
Browse files

Initial commit

parents
required_packages_el7:
FastX3: acc-external-do
cern-get-certificate:
libXinerama.i686:
libXinerama-devel.i686:
mesa-libGL.i686:
nginx:
xterm:
xfce4-genmon-plugin:
cluster_name: ''
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Categories=X-Xfce-Toplevel
#Categories=Applications;Accelerator
Terminal=false
Exec=/acc/local/share/abt/bin/ccm-btexpert
Name=ABT CCM
Comment=Starts CCM for TE/ABT experts
Icon=/usr/share/icons/gnome/48x48/apps/help-browser.png
\ No newline at end of file
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
[ -f /afs/cern.ch/user/${USER::1}/${USER}/.bashrc ] && source /afs/cern.ch/user/${USER::1}/${USER}/.bashrc
\ No newline at end of file
Hello
\ No newline at end of file
/* Custom CSS */
.bookmark-container.border.p-1>div {
width: 100%;
flex-direction: row;
}
.bookmark-container.border.p-1 fx-session-bookmark-element.bookmark {
width: 100%;
}
.bookmark-container.border.p-1 img {
height: 50px;
padding: 0;
margin: 0;
object-fit: contain;
padding-left:20px
}
.card-img-top.position-relative {
width: 50px;
flex: 0;
}
.bookmark-container .mx-auto.name.pop {
margin: auto;
margin: auto auto auto 0!important;
width: auto;
}
.bookmark-container .card-img-top.position-relative {
width: 110px;
}
.bookmark-container .card {
flex-direction: row;
}
const sshHandle = require('../../util/ssh/handle');
const Util = require('../../util/message');
const LinkExec = require('../../util/exec')
const LINKCOMMAND = _require('process/util/link/linkcommand');
const saveHistory = require('./save-history');
const Cluster = _require('system').cluster;
const connectThen = require('../connect-then');
const User = _require('user');
const path = require('path');
module.exports = {
ready: ready,
sshOnly: sshOnly
}
async function sshOnly(data, msg, ssh) {
let myExec = data.action == 'schedule' ? (data.args.command || '') : [path.resolve(global.FXROOTDIR, 'scripts', 'start'),
"--json='" + JSON.stringify(data.args)
.replace(/'/g,'"')
+ "'"
].join(' ');
ssh.exec(myExec,async (err, stream) => {
try {
if(err) {
throw err;
}
if(data.action == 'schedule') {
let o = await schedule(stream);
o.stage = 'schedule';
Util.response(msg, {
result: o
});
return;
}
let d = await sshHandle(null, err, stream);
ssh.end();
if(!d.result)
return Util.response(msg, d);
d.result.stage = 'success';
await saveHistory(msg, d);
Util.response(msg,await connectThen(d));
return;
} catch(e) {
Util.fail(msg, e);
ssh.end();
}
});
}
async function ready(data, msg, ssh) {
try {
let myLink = await doLinkCommand();
ssh.exec(myLink,(err, stream) => {
sshHandle(null, err, stream)
.then(async d => {
//add the new login then try link again
if(d.result) {
msg.body.token = d.result.token;
await User.addLink(d.result.token);
await User.addLogin(d.result.token);
}
msg.body.data = data.args;
delete msg.body.data.auth;
LinkExec(msg,(data.action === 'schedule') ? 'exec' : 'start' ,async (d) => {
ssh.end();
if(!d.result) return Util.response(msg, d);
switch(data.action) {
case 'start':
d.result.stage = 'success';
break;
case 'schedule':
d.result.stage = 'schedule';
default:
return Util.response(msg, {
error: {
message: 'data.action not defined',
name: 'InternalError'
}
});
}
try {
await saveHistory(msg, d);
return Util.response(msg, await connectThen(d));
} catch(e) {
return Util.fail(msg, d);
}
});
})
.catch(e => {
ssh.end();
Util.fail(msg, e);
})
});
} catch(e) {
Util.fail(msg, e);
}
}
async function doLinkCommand() {
let linkCommand = await LINKCOMMAND;
let c = ['env'];
let myFx = Object.keys(process.env).filter(i => i.startsWith('FX_'));
myFx.forEach(i => {
c.push(i + '=' + '\"' +process.env[i] + '\"');
});
myFx.push('FX_AUTHORIZED_KEYS_DIR=' + global.AUTHORIZEDKEYSDIR);
c.push(linkCommand);
return c.join(' ');
}
function schedule(stream) {
return new Promise((resolve, reject) => {
let output = [];
let stdoutLine = '';
let stderrLine = '';
stream.stdout.on('data', chunk => {
stdoutLine += chunk.toString();
let n = stdoutLine.split('\n');
for(let i = 0; i< n.length -1; i++) {
output.push({
line: n[i],
type: 'stdout'
});
}
stdoutLine = n[n.length -1];
});
stream.stderr.on('data', chunk => {
stdoutLine += chunk.toString();
let n = stdoutLine.split('\n');
for(let i = 0; i< n.length -1; i++) {
output.push({
line: n[i],
type: 'stderr'
});
}
stdoutLine = n[n.length -1];
});
stream.on('exit', (code, signalName, didCoreDump, description) => {
if(stdoutLine.length) {
output.push({
line: stdoutLine,
type:"stdout"
});
}
if(stderrLine.length) {
output.push({
line: stderrLine,
type:"stderr"
});
}
if(description) {
output.push({
type: 'system',
eof: true,
line: description
});
}
resolve({
code: code,
output: output
});
});
});
}
#!/bin/sh
# Install the FastX cluster manager
# Last updated with version 3.2.28
MICROSERVICES_URL=https://www.starnet.com/files/private/FastX3/microservices.tgz
cmd=$(basename "$0")
dir=$(cd "$(dirname "$0")" > /dev/null && pwd)
NOTLS=
NOFXMICRO=
OFFLINE=
while getopts ":oum" opt; do
case ${opt} in
o )
OFFLINE=1
;;
u )
NOTLS=1
;;
m )
NOFXMICRO=1
;;
\? )
echo "Usage: $cmd [-o] [-u] [-m]" >&2
echo " -o: Offline mode" >&2
echo " -u: Use un-encrypted redis connection (for secure LAN/VPN)" >&2
echo " -m: Force download of FastX microservices" >&2
exit 1;
;;
esac
done
OS_VERSION=$(sed -e 's/^VERSION_ID=.*\([0-9]\{1,\}\).*/\1/;t;d' /etc/os-release)
# Step 1: Do we have FastX installed here?
if [ "$FASTX" -a ! -d "$FASTX" ]; then
echo "Warning: Ignoring FASTX=$FASTX because it is not a directory." 1>&2
unset FASTX
fi
if [ "$FASTX" -a ! -f "$FASTX/version" ]; then
echo "Warning: Ignoring FASTX=$FASTX because it doesn't seem to be a FastX installation." 1>&2
unset FASTX
fi
if [ -n "$FASTX" ]; then echo "Using FASTX directory $FASTX." >&2; fi
if [ -z "$FASTX" -a -f "$dir/../version" -a -d "$dir/../microservices" ]; then
FASTX=$dir
fi
if [ -z "$FASTX" -a -f /usr/lib/fastx/3/version ]; then
FASTX=/usr/lib/fastx/3
fi
FASTX_VERSION=
while read line; do
line="${line%%#*}"
line="${line%% *}"
case "$line" in
"")
;;
VERSION=*)
FASTX_VERSION="${line#*=}"
;;
*=*)
;;
*)
FASTX_VERSION="${line}"
;;
esac
done < "$FASTX/version"
if [ "$FASTX_VERSION" ]; then
echo "FastX version $FASTX_VERSION is installed." 2>&1
if [ -z "$NOFXMICRO" ] && ! [ -d "$FASTX/microservices" ]; then
echo "This version does not include the FastX microservices.
If there is a FastX of version 3.2 or greater (with microservices),
stop this script and set the FASTX environment variable to that version." >&2
fi
else
echo "Assuming FastX is not installed on this machine.
If FastX is installed, stop this script and run it again with the FASTX environment
variable set to the location of the FastX installation (the directory with a "version" file)." >&2
fi
if [ -z "$FX_CONFIG_DIR" ]; then
if [ -n "$FASTX" ]; then
TOP=$(cd "$FASTX/.." && pwd) || exit $?
FX_CONFIG_DIR="$TOP/var/config";
else
FX_CONFIG_DIR=/opt/FastX
fi
fi
BROKERPASS=
if [ -f "$FX_CONFIG_DIR/broker.json" ]; then
while read line; do
case "$line" in
*"password"*)
BROKERPASS=$(echo $line | sed -n 's/\s*"password"\s*:\s*"\(.*\)".*/\1/p')
;;
esac
done < "$FX_CONFIG_DIR/broker.json"
fi
# Node is required.
NODE=
if [ -x "$FASTX/nodejs/bin/node" ]; then NODE="$FASTX/nodejs/bin/node"; fi
if [ -z "$NODE" ]; then NODE=$(which node 2> /dev/null); fi
if [ -n "$NODE" ]; then
NODE_VERSION=$("$NODE" -v | sed 's/^v//' 2>/dev/null) || NODE_VERSION=
if [ -z "$NODE_VERSION" ]; then
NODE_VERSION=$(rpm -q nodejs)
RPM_CODE=$?
if [ "$RPM_CODE" -eq 127 ]; then exit $?; fi
if [ "$RPM_CODE" -ne 0 ]; then NODE_VERSION= ; fi
NODE_VERSION=$(echo $NODE_VERSION | sed 's/^[^-]*-\([0-9\.]\+\)-.*/\1/')
fi
if [ -z "$NODE_VERSION" ]; then
echo "Unexpected error. Can't determine version of node in $NODE" >&2
exit 1;
fi
if [ "${NODE_VERSION/.*/}" -lt 10 ]; then
echo "Node version $NODE_VERSION is too old for the FastX cluster manager." >&2
if [ -z "$OFFLINE" ]; then
echo "Uninstall this version of nodejs and run this script again." >&2
fi
exit 1;
fi
echo "Using nodejs version $NODE_VERSION, which is already installed." >&2
elif [ -n "$OFFLINE" ]; then
echo "Node (version 10 or later) is required for FastX Cluster." >&2
exit 1;
else
echo "Installing node version 14..." >&2
if ! which curl >/dev/null 2>&1; then yum install -y curl || exit $?; fi
curl -sL https://rpm.nodesource.com/setup_14.x | bash - || exit $?
echo yum install -y nodejs >&2
yum install -y nodejs || exit $?
NODE=$(which node) || exit $?
fi
# Redis
# Is redis already installed?
REDIS_VERSION=($(redis-cli --version 2>/dev/null))
REDIS_VERSION="${REDIS_VERSION[1]}"
if [ -z "$REDIS_VERSION" ]; then
REDIS_VERSION=$(rpm -q redis)
RPM_CODE=$?
if [ "$RPM_CODE" -eq 127 ]; then exit $?; fi
if [ "$RPM_CODE" -ne 0 ]; then REDIS_VERSION= ; fi
REDIS_VERSION=$(echo $REDIS_VERSION | sed 's/^[^-]*-\([0-9\.]\+\)-.*/\1/')
fi
if [ "$REDIS_VERSION" ] && [ "${REDIS_VERSION/.*/}" -lt 6 ] && [ -n "$OFFLINE" ]; then
NOTLS=1
fi
if [ "$REDIS_VERSION" ] && [ "${REDIS_VERSION/.*/}" -lt 6 ] && [ -z "$NOTLS" ]; then
echo "Redis version $REDIS_VERSION is old.
This version probably does not include TLS, which makes it insecure for network operation.
If you are using this on a secure LAN, and want to use it without encryption,
run this script with the '-u' option.
Or uninstall the redis package, and run this script again, which will install the latest version.
If you want to upgrade it manually, follow these instructions:
https://computingforgeeks.com/how-to-install-latest-redis-on-centos-7/." >&2
exit 1;
fi
if [ "$REDIS_VERSION" ]; then
echo "Using redis version $REDIS_VERSION, which is already installed." >&2
else
if [ -z "$OFFLINE" ] && ! rpm -q epel-release > /dev/null 2>&1; then
echo "Installing EPEL..." >&2
echo yum install -y epel-release >&2
yum install -y epel-release || exit $?
fi
if [ -z "$OFFLINE" ] && ! rpm -q remi-release > /dev/null 2>&1; then
if [ -z "$OS_VERSION" ]; then
echo "To install redis, this script requires RedHat/CentOS 7 or later." >&2
exit 1;
fi
echo "Installing Remi repo..." >&2
echo yum install -y "https://rpms.remirepo.net/enterprise/remi-release-$OS_VERSION.rpm" >&2
yum install -y "https://rpms.remirepo.net/enterprise/remi-release-$OS_VERSION.rpm" || exit $?
fi
if [ -z "$OFFLINE" ]; then
YUM_OPTS="--enablerepo=remi"
fi
echo "Installing redis..." >&2
echo yum install -y $YUM_OPTS redis >&2
yum install -y $YUM_OPTS redis || exit $?
fi
#Configure redis for network
PASS=
needpass=
PORT=
needport=
TLSPORT=
KEYFILE=
CERTFILE=
CAFILE=
AUTHCLIENTS=
needtls=
BIND=
needbind=
while read -a line; do
case "${line[0]}" in
requirepass)
PASS="${line[1]}"
;;
port)
PORT="${line[1]}"
;;
bind)
BIND="${line[1]}"
;;
tls-port)
TLSPORT="${line[1]}"
;;
tls-cert-file)
CERTFILE="${line[1]}"
;;
tls-key-file)
KEYFILE="${line[1]}"
;;
tls-ca-cert-file)
CAFILE="${line[1]}"
;;
tls-auth-clients)
AUTHCLIENTS="${line[1]}"
;;
esac
done < /etc/redis.conf
if [ -z "$PASS" -a -n "$BROKERPASS" ]; then
PASS="$BROKERPASS"
needpass=1
fi
if [ -z "$PASS" ]; then
echo "Generating secure password ..." >&2
PASS=$(dd ibs=1 count=50 if=/dev/random 2>/dev/null | base64 | head -c 64) || exit $?
if [ -z "$PASS" ]; then echo "Failed."; exit 1; fi
needpass=1
fi
if [ -z "$NOTLS" -a "$PORT" != 0 ]; then
needport=1
fi
if [[ "$BIND" == "127.0.0.1" ]]; then
needbind=1
BIND="0.0.0.0"
fi
if [ -z "$NOTLS" -a -z "$TLSPORT" ]; then
TLSPORT=6379
needtls=1
fi
if [[ -z "$NOTLS" && ( -z "$CERTFILE" || -z "$KEYFILE" ) ]]; then
needtls=1
KEYFILE=/etc/pki/tls/private/`hostname`-self-key.txt
CERTFILE=/etc/pki/tls/certs/`hostname`-self.crt
CAFILE="${CAFILE:-/etc/pki/tls/certs/ca-bundle.crt}"
if ! [ -f "$CERTFILE" -a -f "$KEYFILE" ]; then
openssl req -new -x509 -nodes -newkey rsa:4096 -keyout $KEYFILE -out $CERTFILE -days 1500 -batch -subj "/commonName=`hostname`"
chmod 600 $KEYFILE
chown redis $CERTFILE $KEYFILE
fi
AUTHCLIENTS="${AUTHCLIENTS:-no}"
fi
if [ -n "$needpass" -o -n "$needport" -o -n "$needtls" -o -n "$needbind" ]; then
ORIG=/etc/redis.conf.orig
if [ -f "$ORIG" ]; then ORIG=/etc/redis.conf.orig.$$; fi
cp --preserve=all /etc/redis.conf "$ORIG" || exit $?
(
echo "# FastX Cluster additions on $(date):"
if [ -n "$needpass" ]; then
echo "requirepass $PASS"
fi
if [ -n "$needport" ]; then
echo "port 0"
fi
if [ -n "$needbind" ]; then
echo "bind $BIND"
fi
if [ -n "$needtls" ]; then
echo "tls-port $TLSPORT"
echo "tls-cert-file $CERTFILE"
echo "tls-key-file $KEYFILE"
echo "tls-ca-cert-file $CAFILE"
echo "tls-auth-clients $AUTHCLIENTS"
fi
) >>/etc/redis.conf
systemctl enable redis
echo "Starting redis service..." >&2
systemctl restart redis
fi
# MongoDB
MONGO_VERSION=($(mongod --version 2>/dev/null))
MONGO_VERSION="${MONGO_VERSION[2]}"
if [ -z "$MONGO_VERSION" ]; then
MONGO_VERSION=$(rpm -q mongodb-org)
RPM_CODE=$?
if [ "$RPM_CODE" -eq 127 ]; then exit $?; fi
if [ "$RPM_CODE" -ne 0 ]; then MONGO_VERSION= ; fi
MONGO_VERSION=$(echo $MONGO_VERSION | sed 's/^[^-]*-\([0-9\.]\+\)-.*/\1/')
fi
if [ "$MONGO_VERSION" ]; then
echo "MongoDB version $MONGO_VERSION is already installed." >&2
else
if ! [ -f /etc/yum.repos.d/mongodb-org*.repo ]; then
echo "Creating mongodb-org repository..." >&2
#cat > /etc/yum.repos.d/mongodb-org-4.4.repo <<'END' || exit $?
#[mongodb-org-4.4]
#name=MongoDB Repository
#baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
#gpgcheck=1
#enabled=1
#gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
#END
fi
echo "Installing MongoDB..." >&2
echo yum install -y --enablerepo=mongodb-org mongodb-org-4.4 >&2
#yum install centos-release-sc
#yum install rh-mongodb36 || exit $?
fi
systemctl enable rh-mongodb36-mongod
echo "Starting mongod service..." >&2
systemctl start rh-mongodb36-mongod
# FastX store microservice
FASTX_USER=${FASTX_USER:-fastx}
id "$FASTX_USER" > /dev/null 2>&1 || useradd -r -s /sbin/nologin -d / "$FASTX_USER" || exit $?
if ! [ -d "$FX_CONFIG_DIR" ]; then
mkdir -p "$FX_CONFIG_DIR" || exit $?
chown "$FASTX_USER" "$FX_CONFIG_DIR" 2>/dev/null
fi
if ! [ -f "$FX_CONFIG_DIR/broker.json" ]; then
cat > "$FX_CONFIG_DIR/broker.json" <<END || exit $?
{
"transporterType": "redis",
"password": "$PASS",
"host": "`hostname`",
"port": 6379,
END
if [ -z "$NOTLS" ]; then echo ' "rejectUnauthorized": false,' >> "$FX_CONFIG_DIR/broker.json"; fi
cat >> "$FX_CONFIG_DIR/broker.json" <<END || exit $?
"namespace": "fastx-cluster"
}