2017-10-25 09:02:21 +00:00
|
|
|
#!/bin/bash
|
2017-10-25 21:59:10 +00:00
|
|
|
|
2018-02-06 19:36:37 +00:00
|
|
|
if [ -z "$FTP_USERNAME" ]; then
|
2017-10-25 21:59:10 +00:00
|
|
|
echo "Need to set username"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PLUGIN_HOSTNAME" ]; then
|
|
|
|
echo "Need to set hostname"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PLUGIN_SECURE" ]; then
|
|
|
|
PLUGIN_SECURE="true"
|
|
|
|
fi
|
|
|
|
|
2018-02-10 17:49:18 +00:00
|
|
|
if [ -z "$PLUGIN_VERIFY" ]; then
|
|
|
|
PLUGIN_VERIFY="true"
|
|
|
|
fi
|
|
|
|
|
2017-10-25 21:59:10 +00:00
|
|
|
if [ -z "$PLUGIN_DEST_DIR" ]; then
|
|
|
|
PLUGIN_DEST_DIR="/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PLUGIN_SRC_DIR" ]; then
|
|
|
|
PLUGIN_SRC_DIR="/"
|
|
|
|
fi
|
|
|
|
|
2018-03-05 01:59:44 +00:00
|
|
|
if [ "$PLUGIN_CHMOD" = false ]; then
|
|
|
|
PLUGIN_CHMOD="-p"
|
2018-03-02 10:05:40 +00:00
|
|
|
else
|
2018-03-05 01:59:44 +00:00
|
|
|
PLUGIN_CHMOD=""
|
2018-03-02 10:05:40 +00:00
|
|
|
fi
|
|
|
|
|
2018-09-12 20:10:49 +00:00
|
|
|
if [ "$PLUGIN_ONLY_NEWER" = true ]; then
|
|
|
|
PLUGIN_ONLY_NEWER="-n"
|
|
|
|
else
|
|
|
|
PLUGIN_ONLY_NEWER=""
|
|
|
|
fi
|
|
|
|
|
2018-03-05 02:09:46 +00:00
|
|
|
if [ "$PLUGIN_CLEAN_DIR" = true ]; then
|
|
|
|
PLUGIN_CLEAN_DIR="rm -r $PLUGIN_DEST_DIR"
|
|
|
|
else
|
|
|
|
PLUGIN_CLEAN_DIR=""
|
|
|
|
fi
|
|
|
|
|
2017-10-25 21:59:10 +00:00
|
|
|
PLUGIN_EXCLUDE_STR=""
|
|
|
|
PLUGIN_INCLUDE_STR=""
|
|
|
|
|
|
|
|
IFS=',' read -ra in_arr <<< "$PLUGIN_EXCLUDE"
|
|
|
|
for i in "${in_arr[@]}"; do
|
|
|
|
PLUGIN_EXCLUDE_STR="$PLUGIN_EXCLUDE_STR -x $i"
|
|
|
|
done
|
|
|
|
IFS=',' read -ra in_arr <<< "$PLUGIN_INCLUDE"
|
|
|
|
for i in "${in_arr[@]}"; do
|
2018-02-22 18:41:41 +00:00
|
|
|
PLUGIN_INCLUDE_STR="$PLUGIN_INCLUDE_STR -i $i"
|
2017-10-25 21:59:10 +00:00
|
|
|
done
|
|
|
|
|
2018-03-05 01:44:04 +00:00
|
|
|
lftp -e "set xfer:log 1; \
|
2018-02-10 17:49:18 +00:00
|
|
|
set ftp:ssl-allow $PLUGIN_SECURE; \
|
|
|
|
set ftp:ssl-force $PLUGIN_SECURE; \
|
|
|
|
set ftp:ssl-protect-data $PLUGIN_SECURE; \
|
|
|
|
set ssl:verify-certificate $PLUGIN_VERIFY; \
|
|
|
|
set ssl:check-hostname $PLUGIN_VERIFY; \
|
2018-03-05 02:07:13 +00:00
|
|
|
$PLUGIN_CLEAN_DIR; \
|
2018-09-12 20:10:49 +00:00
|
|
|
mirror --verbose $PLUGIN_CHMOD $PLUGIN_ONLY_NEWER -R $PLUGIN_INCLUDE_STR $PLUGIN_EXCLUDE_STR $(pwd)$PLUGIN_SRC_DIR $PLUGIN_DEST_DIR" \
|
2018-02-10 17:49:18 +00:00
|
|
|
-u $FTP_USERNAME,$FTP_PASSWORD $PLUGIN_HOSTNAME
|