Commit c71c0646 authored by Dillenn Terumalai's avatar Dillenn Terumalai
Browse files

Hid logs and outbox folders, fixed small issues

parent cfb4abb9
*
!logs
!outbox
!.logs
!.outbox
!sent
!.env
!.gitignore
......
......@@ -22,7 +22,7 @@ If you want to be able to use the tool smoothly, make sure that you have:
- OS: macOS or Linux - This script can only run on those operative systems
- SSH: public key uploaded - This script is assuming that you have generated and transferred your public SSH key to the SPSP SFTP Server. If not, please read the [Installation](#installation) chapter
- GPG: gpg avaiable - This script uses GPG to encrypt the data, make sure that you can run this command (`which gpg`)
- GPG: gpg avaiable - This script uses [GnuPG](https://gnupg.org/) to encrypt the data , make sure that it is installed and you can run this command (`which gpg`)
- (Optional) CRON: automatic mode - If you want to activate the automatic mode of the transfer-tool make sure that you can setup a CRON task
Due to the secure environment where SPSP is hosted, data cannot be directly uploaded via the SPSP online platform. Instead SPSP users should use a dedicated drive within their institution to submit data to SPSP.
......
......@@ -132,7 +132,7 @@ if [ $# -gt 0 ]; then
echo "No .env file found within current working directory ${pwd}"
echo "You need to create this file to use this script"
echo "Please refer to the documentation for further informations"
exit 1
exit 2
fi
if [ "$1" == "--version" ] || [ "$1" == "-v" ] || [ "$1" == "version" ]; then
......@@ -158,10 +158,19 @@ if [ $# -gt 0 ]; then
exit 22
fi
if [ ! -f .env ]; then
echo "No .env file found within current working directory $(pwd)"
echo "Create a .env file before re-initializing"
exit 2
if [ ! -x "$(command -v nc)" ]; then
echo "Error: nc command is not available."
exit 22
fi
if [ ! -x "$(command -v gpg)" ]; then
echo "Error: gpg command is not available, this error may happen when you use a CRON task. Modifying the PATH..."
export PATH=$PATH:/usr/local/bin
if [ ! -x "$(command -v gpg)" ]; then
echo "Error: gpg command is not available (no gpg instance is installed)."
echo "GnuPG is mandatory for encrypting the data. Please consult https://gnupg.org/, to install gpg."
exit 22
fi
fi
if [ ! -f spsp ]; then
......@@ -189,7 +198,7 @@ if [ $# -gt 0 ]; then
echo "############# $CURRENTDATE #############"
echo "SPSP: Starting the transfer-tool..."
OUTBOX=outbox
OUTBOX=".outbox"
if [ ! -d "$OUTBOX" ]; then
echo "SPSP: No $OUTBOX folder found within current working directory ${pwd}"
echo "SPSP: Creating the $OUTBOX folder..."
......@@ -203,24 +212,21 @@ if [ $# -gt 0 ]; then
mkdir $SENT
fi
LOGS=logs
LOGS=".logs"
if [ ! -d "$LOGS" ]; then
echo "SPSP: No $LOGS folder found within current working directory ${pwd}"
echo "SPSP: Creating the $LOGS folder..."
mkdir $LOGS
fi
LOGFILE="./logs/spsp-$CURRENTDATE.log"
if [ ! -f $LOGFILE ]; then
touch $LOGFILE
fi
LOGFILE="./$LOGS/spsp-$CURRENTDATE.log"
if [ ! -x "$(command -v gpg)" ]; then
echo "Error: gpg command is not available, this error may happen when you use a CRON task. Modifying the PATH..."
export PATH=$PATH:/usr/local/bin
if [ ! -x "$(command -v gpg)" ]; then
echo "Error: gpg command is not available (no gpg instance is installed)."
echo "GnuPG is mandatory for encrypting the data. Please consult https://gnupg.org/, to install gpg."
exit 22
fi
fi
......@@ -243,6 +249,7 @@ if [ $# -gt 0 ]; then
echo "SPSP: Removing the source and moving the tar.gz to outbox folder."
mv $DIRECTORY.tar.gz ./outbox/.
rm -rf $DIRECTORY
echo "SPSP: Deleted!"
else
echo "[`date +"%T"`] local.ERROR: Missing files (*.fastq/.fastq.gz and/or *.xlsx) inside ${DIRECTORY}" >> $LOGFILE
echo "SPSP: Error detected please check $LOGFILE"
......@@ -252,7 +259,7 @@ if [ $# -gt 0 ]; then
fi
done
for FILE in ./outbox/*; do
for FILE in ./$OUTBOX/*; do
if [ -f "$FILE" ]; then
echo "SPSP: Encrypting $FILE using SPSP public key..."
encryptFile $FILE
......@@ -265,11 +272,19 @@ if [ $# -gt 0 ]; then
transferFile $FILE.gpg.sha256
transferFile $FILE.gpg
echo "SPSP: $FILE has been transferred sucessfully!"
mv $FILE.gpg.sha256 ./sent/.
mv $FILE.gpg ./sent/.
echo "SPSP: Removing unencrypted version of $FILE"
rm -rf "$FILE"
echo "SPSP: Removing unencrypted version of $FILE..."
rm "$FILE"
echo "SPSP: Deleted!"
if [ "$1" == "--no-archive" ] || [ "$1" == "no-archive" ]; then
echo "SPSP: 'No archive' mode is activated, removing archives..."
rm "$FILE.gpg"
rm "$FILE.gpg.sha256"
else
echo "SPSP: Moving $FILE.gpg and $FILE.gpg.sha256 to '$SENT' directory!"
mv $FILE.gpg.sha256 ./$SENT/.
mv $FILE.gpg ./$SENT/.
echo "SPSP: Archives have been moved sucessfully!"
fi
else
echo "[`date +"%T"`] local.ERROR: Missing the encrypted version or the signature for $FILE" >> $LOGFILE
echo "SPSP: Error detected please check $LOGFILE"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment