-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into production
- Loading branch information
Showing
14 changed files
with
124 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use File::Basename; | ||
use perunDataGenerator; | ||
|
||
local $::SERVICE_NAME = basename($0); | ||
local $::PROTOCOL_VERSION = "3.0.0"; | ||
local $::SKIP_NON_VALID_MEMBERS = 1; | ||
|
||
perunDataGenerator::generateUsersDataInJSON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
export SERVICE_NAME="dhus" | ||
|
||
python3 generic_sender.py "$1" "$2" "$3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,33 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env python3 | ||
|
||
SERVICE_NAME="tinia" | ||
import send_lib | ||
import sys | ||
import re | ||
|
||
FACILITY_NAME=$1 | ||
DESTINATION=$2 | ||
DESTINATION_TYPE=$3 | ||
service_name = "tinia" | ||
|
||
if [ -z "$DESTINATION" ]; then | ||
echo "Missing Destination argument (DB NAME there)" >&2 | ||
exit 231 | ||
fi | ||
send_lib.check_input_fields(sys.argv, destination_type_required=True) | ||
|
||
if [ -z "$FACILITY_NAME" ]; then | ||
echo "Missing FacilityName argument" >&2 | ||
exit 232 | ||
fi | ||
facility = sys.argv[1] | ||
destination = sys.argv[2] | ||
destination_type = sys.argv[3] | ||
|
||
if [ -z "$DESTINATION_TYPE" ]; then | ||
echo "Destination type of this service can't be empty" >&2 | ||
exit 233; | ||
else | ||
TYPE="service-specific" | ||
if [ "$DESTINATION_TYPE" != "$TYPE" ]; then | ||
echo "Destination type of this service need to be $TYPE" >&2 | ||
exit 234; | ||
fi | ||
fi | ||
send_lib.check_destination_type_allowed(destination_type, "service-specific") | ||
send_lib.check_destination_format(destination, destination_type, send_lib.SIMPLE_PATTERN) | ||
|
||
#Destination is name of database on oracle in localhost tnsnames file | ||
DBNAME=$DESTINATION | ||
|
||
SERVICE_FILES_BASE_DIR="`pwd`/../gen/spool" | ||
SERVICE_FILES_DIR="$SERVICE_FILES_BASE_DIR/$FACILITY_NAME/$SERVICE_NAME" | ||
|
||
#Just safety check. This should not happen. | ||
if [ ! -d "$SERVICE_FILES_DIR" ]; then echo '$SERVICE_FILES_DIR: '$SERVICE_FILES_DIR' is not a directory' >&2 ; exit 1; fi | ||
|
||
#Create lock (same like in slave) | ||
LOCK_DIR=${LOCK_DIR:=/var/lock} | ||
LOCK_FILE="${LOCK_DIR}/perunv3-${SERVICE_NAME}-$DBNAME.lock" | ||
LOCK_PIDFILE="$LOCK_FILE/pid" | ||
|
||
function create_lock { | ||
if mkdir "${LOCK_FILE}"; then | ||
trap 'rm -r -f "${LOCK_FILE}"' EXIT | ||
echo $$ > "$LOCK_PIDFILE"; | ||
if [ $? -ne 0 ]; then | ||
echo "Can't create lock file." >&2 | ||
exit 250 | ||
fi | ||
else | ||
# lock file exists, check for existence of concurrent process | ||
if ps ax | grep "$SERVICE_NAME" | sed 's/^\([0-9]\+\).*/\1/' | grep "\(^\| \)`cat $LOCK_PIDFILE`\( \|$\)"; then | ||
# concurrent process is running - this skript must terminate | ||
echo "Concuret process tinia_process is running" >&2 | ||
exit 249 | ||
else | ||
# lock is not valid; it should be deleted | ||
rm -r "$LOCK_FILE" | ||
if [ $? -ne 0 ]; then | ||
echo "Can't remove not valid lock file." >&2 | ||
exit 248 | ||
fi | ||
echo "Invalid lock file found and deleted: $LOCK_FILE" >&2 | ||
mkdir "${LOCK_FILE}" | ||
if [ $? -ne 0 ]; then | ||
echo "Can't create lock after removing invalid lock." >&2 | ||
exit 247 | ||
fi | ||
trap 'rm -r -f "${LOCK_FILE}"' EXIT | ||
echo $$ > "$LOCK_PIDFILE" | ||
if [ $? -ne 0 ]; then | ||
echo "Can't create lock file after removing invalid lock file." >&2 | ||
exit 246 | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
create_lock | ||
|
||
TMP_HOSTNAME_DIR="`mktemp -d /tmp/perun-send.XXXXXXXXXX`" | ||
if [ $? -ne 0 ]; then | ||
echo "Can't create temporary dir" >&2 | ||
exit 255 | ||
fi | ||
|
||
#prepare removing of temporary files and dirs after exit of script | ||
trap 'rm -r -f "${LOCK_FILE}" "${TMP_HOSTNAME_DIR}"' EXIT | ||
|
||
cp $SERVICE_FILES_DIR/$SERVICE_NAME $TMP_HOSTNAME_DIR | ||
if [ $? -ne 0 ]; then | ||
echo "Can't copy service file to temporary dir" >&2 | ||
exit 254 | ||
fi | ||
|
||
EXECSCRIPT="./tinia_process.pl" | ||
|
||
if [ ! -f "$EXECSCRIPT" ]; then | ||
echo "Can't locate process script!" >&2 | ||
exit 253 | ||
fi | ||
|
||
$EXECSCRIPT -d $DBNAME -p $TMP_HOSTNAME_DIR -s $SERVICE_NAME | ||
|
||
ERRORCODE=$? | ||
if [ $ERRORCODE -ne 0 ]; then | ||
echo "Process exit with error" >&2 | ||
exit $ERRORCODE | ||
fi | ||
|
||
ERR_CODE=$? | ||
|
||
if [ $ERR_CODE -ne 0 ]; then | ||
echo "Slave script ends with return code: $ERR_CODE" >&2 | ||
fi | ||
|
||
exit $ERR_CODE | ||
dbname = destination | ||
|
||
service_files_dir = send_lib.get_gen_folder(facility, service_name) | ||
send_lib.create_lock(service_name, dbname) | ||
|
||
# copy service file to temporary directory | ||
with send_lib.prepare_temporary_directory() as tmp_dir: | ||
send_lib.copy_files_to_directory(service_files_dir, tmp_dir, re.compile(service_name)) | ||
scriptpath = "./tinia_process.pl" | ||
process = send_lib.exec_script(scriptpath, ["-d", dbname, "-p", tmp_dir, "-s", service_name]) | ||
process.wait() | ||
stdout, stderr = process.communicate() | ||
print(stdout.decode()) | ||
if process.returncode != 0: | ||
send_lib.die_with_error("Slave script ends with return code: " + str(process.returncode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
PROTOCOL_VERSION='3.0.0' | ||
|
||
function process { | ||
|
||
E_MISSING_DST_PATH=(50 'Missing path of handling script (DST_SCRIPT), need to be set in pre_script.') | ||
E_MISSING_DST_EXIST=(51 'Handling script does not exist at the specified location (' + "${DST_SCRIPT}" + '), please check that the correct path is set in pre_script') | ||
E_MISSING_DST_EXEC=(52 'Handling script is not executable (' + "${DST_SCRIPT}" + '), please check that the correct permissions are set') | ||
|
||
E_MISSING_CONF_PATH=(53 'Missing path of configuration (DST_CONF), need to be set in pre_script.') | ||
E_MISSING_CONF_EXIST=(54 'Configuration does not exist at the specified location (' + "${DST_CONF}" + '), please check that the correct path is set in pre_script') | ||
|
||
if [ -z ${DST_SCRIPT} ]; then | ||
log_msg E_MISSING_DST_PATH | ||
fi | ||
|
||
if [ ! -f ${DST_SCRIPT} ]; then | ||
log_msg E_MISSING_DST_EXIST | ||
fi | ||
|
||
if [ ! -x ${DST_SCRIPT} ]; then | ||
log_msg E_MISSING_DST_EXEC | ||
fi | ||
|
||
if [ -z ${DST_CONF} ]; then | ||
log_msg E_MISSING_CONF_PATH | ||
fi | ||
|
||
if [ ! -d ${DST_CONF} ]; then | ||
log_msg E_MISSING_CONF_EXIST | ||
fi | ||
|
||
create_lock | ||
|
||
FROM_PERUN="${WORK_DIR}" | ||
|
||
${DST_SCRIPT} -f $FROM_PERUN -c $DST_CONF | ||
|
||
exit $? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
perun-slave-process-dhus (3.0.0) stable; urgency=low | ||
|
||
* New service dhus | ||
|
||
-- Johana Supikova <[email protected]> Wed, 12 Apr 2023 14:32:00 +0200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
# set handling script | ||
#DST_SCRIPT=/tmp/dhus.py | ||
|
||
# set configuration path - specific config will be retrieved by facility name (e.g. /etc/dhus/facility.yml) | ||
#DST_CONF=/etc/dhus/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
perun-slave-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
perun-slave-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package for perun service - dhus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters