#!/bin/sh SEND_LOGFILE=1 SEND_BACKUP=0 TMP_DIR_LOG=/tmp/log TMP_DIR_BACKUP=/tmp/backup LOGGER_ID="exportfiles.sh" SERVER_SETTINGS_FILE="/home/tool/config/ResFtpCfg.json" #logger -t $LOGGER_ID "Test" #pruefen, ob was scharf ist if [ $SEND_LOGFILE -eq 0 ] && [ $SEND_BACKUP -eq 0 ];then return fi SERVER_IP=`cat $SERVER_SETTINGS_FILE | grep server | awk '{print $2}'` SERVER_IP=${SERVER_IP//[,'"']/} if [ -z "$SERVER_IP" ]; then logger -t $LOGGER_ID "no server ip" return fi logger -t $LOGGER_ID "Server IP: $SERVER_IP" PORT=`cat $SERVER_SETTINGS_FILE | grep port | awk '{print $2}'` PORT=${PORT//[,'"']/} if [ -z "$PORT" ]; then return fi logger -t $LOGGER_ID "Port: $PORT" USR=`cat $SERVER_SETTINGS_FILE | grep user | awk '{print $2}'` USR=${USR//[,'"']/} if [ -n "$USR" ]; then logger -t $LOGGER_ID "User: $USR" fi PWD=`cat $SERVER_SETTINGS_FILE | grep pass | awk '{print $2}'` PWD=${PWD//[,'"']/} if [ -n "$PWD" ]; then logger -t $LOGGER_ID "Pwd: $PWD" fi if [ $SEND_LOGFILE -eq 1 ]; then logger -t $LOGGER_ID "generating logfile" mkdir -p $TMP_DIR_LOG rm -r $TMP_DIR_LOG/* cp -rvf /var/log/* $TMP_DIR_LOG cp -rvf /var/run/diag/* $TMP_DIR_LOG cp -vf /etc/version $TMP_DIR_LOG FILENAME=$(python ./generatefile.py "logfile" "$TMP_DIR_LOG/*") #Filename verkuerzen #FILENAME="${FILENAME//$'\n'/}" $(curl -T $FILENAME ftp://$USR:$PWD@$SERVER_IP:$PORT) ret=$? if [ $ret -eq 0 ]; then logger -t $LOGGER_ID "file " $FILENAME " successfully transferred to server "$SERVER_IP rm -f $FILENAME else logger -t "curl failed with error: "$ret fi fi if [ $SEND_BACKUP -eq 1 ]; then logger -t $LOGGER_ID "generating backup" mkdir -p $TMP_DIR_BACKUP rm -r $TMP_DIR_BACKUP/* VERSION=`cat /etc/version` #echo "Version: " $VERSION cp -rvf /mnt/data/config/$VERSION/* /$TMP_DIR_BACKUP FILENAME=$(python ./generatefile.py "backup" "$TMP_DIR_BACKUP/*") $(curl -T $FILENAME ftp://$USR:$PWD@$SERVER_IP:$PORT) ret=$? #if [ $ret -eq 0 ]; then if [ $ret -ne 0 ]; then logger -t $LOGGER_ID "curl failed with error: "$ret else logger -t $LOGGER_ID "file " $FILENAME " successfully transferred to server "$SERVER_IP rm -f $FILENAME fi fi exit #filename=$(python ./test.py "filename") #echo $filename #pwd=$(python ./test.py "pwd") #echo $pwd #files zusammen packen