Created
May 13, 2011 07:40
-
-
Save dynax60/970155 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
| PIDFILE=${PIDFILE:-"/var/run/mv2smb.pid"} | |
| LOCAL_DIR=${LOCAL_DIR:-"/var/lib/asterisk/records"} | |
| REMOTE_SMB=${REMOTE_SMB:-"//10.1.1.1/homes"} | |
| REMOTE_SMB_AUTH=${REMOTE_SMB_AUTH:-"/path/to/mv2smb.conf"} | |
| REMOTE_DIR=${REMOTE_DIR:-""} | |
| if [ -f $PIDFILE ]; then | |
| pid=`head $PIDFILE 2>/dev/null` | |
| if kill -0 $pid; then | |
| echo "Seems that $0 is already running with PID: $pid" >&2 | |
| exit 1 | |
| fi | |
| rm -f $PIDFILE | |
| fi | |
| store() { | |
| [ -d $1 ] || return | |
| echo "Move $1/* to ${REMOTE_SMB}$2" | |
| (cd $1 && smbclient -A $REMOTE_SMB_AUTH $REMOTE_SMB \ | |
| -c "recurse; prompt; cd $2; mput *" 2>&1 && rm -rf $1/*) | grep -v Domain= | |
| } | |
| echo $$ > $PIDFILE | |
| trap "rm -f $PIDFILE $ERR_LOGFILE" 1 2 3 15 EXIT | |
| echo "Start time `date`" | |
| smbclient -A $REMOTE_SMB_AUTH $REMOTE_SMB -c "ls $REMOTE_DIR/*" 2>&1 \ | |
| | grep DA | awk '{print $1}' | egrep -v '^(\.|\.\.|Domain=)' | while read userdir | |
| do | |
| store ${LOCAL_DIR}/$userdir $REMOTE_DIR/$userdir | |
| done | |
| echo "End time `date`" | |
| sync |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Файл mv2smb.conf такого содержания:
username=myuser
password=mypass