Skip to content
Snippets Groups Projects
Commit 38892c4a authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Merge branch 'stable'

parents b1e34ed1 37561326
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ def setup(interactive=True): ...@@ -22,6 +22,7 @@ def setup(interactive=True):
'mkdir -p /usr/local/bin', 'mkdir -p /usr/local/bin',
'cp "%s/mediaimport_create_ftp_user.sh" /usr/local/bin' % (dir_path), 'cp "%s/mediaimport_create_ftp_user.sh" /usr/local/bin' % (dir_path),
'cp "%s/mediaimport_remove_ftp_user.sh" /usr/local/bin' % (dir_path), 'cp "%s/mediaimport_remove_ftp_user.sh" /usr/local/bin' % (dir_path),
'cp "%s/cron.d/* /etc/cron.d' % dir_path,
'mkdir -p /home/ftp/storage', 'mkdir -p /home/ftp/storage',
'mkdir -p /home/ftp/storage/incoming', 'mkdir -p /home/ftp/storage/incoming',
'mkdir -p /home/ftp/storage/watchfolder', 'mkdir -p /home/ftp/storage/watchfolder',
......
# purge mediaimport files that are older than 60 days
0 23 * * * root /usr/bin/find /home/ftp/storage/incoming/ -type f -mtime +60 -delete
# purge empty folders
0 23 * * * root /usr/bin/find /home/ftp/storage -type d -empty -name thumbnails -delete
0 23 * * * root /usr/bin/find /home/ftp/storage -type d -empty -name "*20*-*" -delete
...@@ -54,13 +54,21 @@ fn_parse_date() { ...@@ -54,13 +54,21 @@ fn_parse_date() {
case "$OSTYPE" in case "$OSTYPE" in
linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;;
cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;;
darwin8*) yy=`expr ${1:0:4}`
mm=`expr ${1:5:2} - 1`
dd=`expr ${1:8:2}`
hh=`expr ${1:11:2}`
mi=`expr ${1:13:2}`
ss=`expr ${1:15:2}`
# Because under MacOS X Tiger 'date -j' doesn't work, we do this:
perl -e 'use Time::Local; print timelocal('$ss','$mi','$hh','$dd','$mm','$yy'),"\n";' ;;
darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;
FreeBSD*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; FreeBSD*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;
esac esac
} }
fn_find_backups() { fn_find_backups() {
fn_run_cmd "find "$DEST_FOLDER" -maxdepth 1 -type d -name \"????-??-??-??????\" -prune | sort -r" fn_run_cmd "find "$DEST_FOLDER/" -maxdepth 1 -type d -name \"????-??-??-??????\" -prune | sort -r"
} }
fn_expire_backup() { fn_expire_backup() {
...@@ -76,14 +84,15 @@ fn_expire_backup() { ...@@ -76,14 +84,15 @@ fn_expire_backup() {
} }
fn_parse_ssh() { fn_parse_ssh() {
if [[ "$DEST_FOLDER" =~ ^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$ ]] # To keep compatibility with bash version < 3, we use grep
if echo "$DEST_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$'
then then
SSH_USER=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/') SSH_USER=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/')
SSH_HOST=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/') SSH_HOST=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/')
SSH_DEST_FOLDER=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\3/') SSH_DEST_FOLDER=$(echo "$DEST_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\3/')
SSH_CMD="ssh -p $SSH_PORT ${SSH_USER}@${SSH_HOST}" SSH_CMD="ssh -p $SSH_PORT ${SSH_USER}@${SSH_HOST}"
SSH_DEST_FOLDER_PREFIX="${SSH_USER}@${SSH_HOST}:" SSH_DEST_FOLDER_PREFIX="${SSH_USER}@${SSH_HOST}:"
elif [[ "$SRC_FOLDER" =~ ^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$ ]] elif echo "$SRC_FOLDER"|grep -Eq '^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9.\-]+\:.+$'
then then
SSH_USER=$(echo "$SRC_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/') SSH_USER=$(echo "$SRC_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\1/')
SSH_HOST=$(echo "$SRC_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/') SSH_HOST=$(echo "$SRC_FOLDER" | sed -E 's/^([A-Za-z0-9\._%\+\-]+)@([A-Za-z0-9.\-]+)\:(.+)$/\2/')
...@@ -94,7 +103,7 @@ fn_parse_ssh() { ...@@ -94,7 +103,7 @@ fn_parse_ssh() {
} }
fn_run_cmd() { fn_run_cmd() {
if [ -n "$SSH_DEST_FOLDER_PREFIX" ] if [ -n "$SSH_DEST_FOLDER_PREFIX" ]
then then
eval "$SSH_CMD '$1'" eval "$SSH_CMD '$1'"
else else
...@@ -182,7 +191,7 @@ while :; do ...@@ -182,7 +191,7 @@ while :; do
EXCLUSION_FILE="$3" EXCLUSION_FILE="$3"
break break
;; ;;
-?*) -*)
fn_log_error "Unknown option: \"$1\"" fn_log_error "Unknown option: \"$1\""
fn_log_info "" fn_log_info ""
fn_display_usage fn_display_usage
...@@ -296,9 +305,9 @@ if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then ...@@ -296,9 +305,9 @@ if [ -n "$(fn_find "$INPROGRESS_FILE")" ]; then
fn_log_error "Previous backup task is still active - aborting (command: $RUNNINGCMD)." fn_log_error "Previous backup task is still active - aborting (command: $RUNNINGCMD)."
exit 1 exit 1
fi fi
else else
RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")" RUNNINGPID="$(fn_run_cmd "cat $INPROGRESS_FILE")"
if [ "$RUNNINGPID" = "$(pgrep "$APPNAME")" ]; then if [ "$RUNNINGPID" = "$(pgrep -o -f "$APPNAME")" ]; then
fn_log_error "Previous backup task is still active - aborting." fn_log_error "Previous backup task is still active - aborting."
exit 1 exit 1
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment