t-r.de/deploy-via-ftp.sh

20 lines
542 B
Bash
Executable File

#!/usr/bin/env bash
# -*- coding: utf8 -*-
# source login credentials and paths
source ./deploy.conf
# get remote directory directly above target dir
# parameter expansion with '%' (remove suffix): cut off the rightmost occurrence of what comes after the percent sign
REMOTE_BASE_DIR=${REMOTE_DIR%/*}
lftp -c "
open $HOST;
user $USER $PASS;
rm -rf $REMOTE_BASE_DIR/tmp;
mirror --reverse --continue --verbose $LOCAL_DIR $REMOTE_BASE_DIR/tmp;
rm -rf $REMOTE_DIR-old;
mv $REMOTE_DIR $REMOTE_DIR-old;
mv $REMOTE_BASE_DIR/tmp $REMOTE_DIR;
"