minor changes

This commit is contained in:
Roger Pàmies Fabra 2023-07-25 18:39:35 +02:00
parent 4323a3940d
commit 8fe4e56c04
2 changed files with 12 additions and 7 deletions

View File

@ -6,7 +6,7 @@
TITLE=$1 TITLE=$1
MESSAGE=$2 MESSAGE=$2
PRIORITY=$3 PRIORITY=$3
URL="$ES7_GOTIFY_SERVER_URL/message?token=$4" URL="$E7S_GOTIFY_SERVER_URL/message?token=$4"
#if url passed by parameter, set to extras #if url passed by parameter, set to extras
if [ -n "$5" ] if [ -n "$5" ]
then then

View File

@ -6,14 +6,19 @@
REMOTE_PATH="$ES7_LOGS_PATH$2" REMOTE_PATH="$ES7_LOGS_PATH$2"
PUBLIC_LOG_URL="$ES7_LOGS_URL/$2" PUBLIC_LOG_URL="$ES7_LOGS_URL/$2"
# get file name in case of $1 is a path
file=$(basename -- "$1")
extension=${file##*.}
base=$(basename "${file%.*}")
# create remote folder to store logs if not exist # create remote folder to store logs if not exist
ssh $ES7_LOGS_SERVER_SSH "sudo mkdir -p $REMOTE_PATH" ssh $ES7_LOGS_SERVER_SSH "mkdir -p $REMOTE_PATH"
# Copy local logfile to remote destination # Copy local logfile to remote destination
scp $1 "$ES7_LOGS_SERVER_SSH:$REMOTE_PATH" scp $1 "$ES7_LOGS_SERVER_SSH:$REMOTE_PATH"
# set correct permissions # set correct permissions
ssh $ES7_LOGS_SERVER_SSH "sudo chmod 644 $REMOTE_PATH$1" ssh $ES7_LOGS_SERVER_SSH "chmod 644 $REMOTE_PATH$file"
# Clear x days old remote logs # Clear x days old remote logs
ssh $ES7_LOGS_SERVER_SSH 'bash -s' << EOF ssh $ES7_LOGS_SERVER_SSH 'bash -s' << EOF
@ -21,12 +26,12 @@ find $REMOTE_PATH -maxdepth 1 -mtime +$E7S_LOGS_PRESERVE_DAYS -exec "rm" -R {} \
EOF EOF
# return final log url # return final log url
# get file name in case of $1 is a path
file=$(basename -- "$1")
extension=${file##*.}
base=$(basename "${file%.*}")
# change to txt if log is another text format # change to txt if log is another text format
if [ $extension != "txt" ]; then if [ $extension != "txt" ]; then
ssh $ES7_LOGS_SERVER_SSH "mv $REMOTE_PATH$file $REMOTE_PATH$base.txt" ssh $ES7_LOGS_SERVER_SSH "mv $REMOTE_PATH$file $REMOTE_PATH$base.txt"
fi fi
# set correct owner of webserver files
ssh $ES7_LOGS_SERVER_SSH "chown -R www-data: $REMOTE_PATH"
echo "${PUBLIC_LOG_URL}${base}.txt" echo "${PUBLIC_LOG_URL}${base}.txt"