-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvendor_import.sh
executable file
·28 lines (27 loc) · 1.22 KB
/
vendor_import.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
MAGMI_PATH="/home/www.wypo.cl/html/up/magmi/cli/magmi.cli.php"
IMOPRT_DIRECTORY="/home/www.wypo.cl/html/up/magmi/import"
PROCESSED_DIRECTORY="/home/www.wypo.cl/html/up/magmi/import/processed/"
for file in $IMOPRT_DIRECTORY/*_*.csv;
do
file_name=$(basename $file)
magmi_profile=$(echo "$file_name" | grep -Po '(?<=(_)).*(?=.csv)')
udropship_vendor=$(echo "$file_name" | sed 's/_.*//')
if [ -f "$PROCESSED_DIRECTORY$file_name" ]
then
file1=$(md5sum $file | cut -d ' ' -f 1)
file2=$(md5sum $PROCESSED_DIRECTORY$file_name | cut -d ' ' -f 1)
if [ "$file1" = "$file2" ]
then
echo "Nothing to do - File:$file_name already processed"
else
echo "$MAGMI_PATH -profile=$magmi_profile -mode=update -CSV:filename="$file" -udropship_vendor=$udropship_vendor"
php $MAGMI_PATH -profile=$magmi_profile -mode=update -CSV:filename="$file" -udropship_vendor=$udropship_vendor
cp -R $file $PROCESSED_DIRECTORY$file_name
fi
else
echo "$MAGMI_PATH -profile=$magmi_profile -mode=update -CSV:filename="$file" -udropship_vendor=$udropship_vendor"
php $MAGMI_PATH -profile=$magmi_profile -mode=update -CSV:filename="$file" -udropship_vendor=$udropship_vendor
cp -R $file $PROCESSED_DIRECTORY$file_name
fi
done