build: refactor lftp call to use subshell, echo, & tee

This commit is contained in:
Starbeamrainbowlabs 2019-04-07 17:48:30 +01:00
parent 2894ae9141
commit 02a73e4ade
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

24
build
View file

@ -320,19 +320,17 @@ task_deploy() {
# 3. Create data dir symlink # 3. Create data dir symlink
# 4. Swap in new directory # 4. Swap in new directory
# 5. Delete old directory # 5. Delete old directory
lftp << SFTPCOMMANDS (
set sftp:connect-program 'ssh -x -i "${SSH_KEY_PATH}" -p "${deploy_ssh_port}" -o "PasswordAuthentication=no"'; echo "set sftp:connect-program 'ssh -x -i \"${SSH_KEY_PATH}\" -p \"${deploy_ssh_port}\" -o \"PasswordAuthentication=no\"'";
connect sftp://${deploy_ssh_user}:@${deploy_ssh_host}; echo "connect sftp://${deploy_ssh_user}:@${deploy_ssh_host}";
echo "glob mirror -R -P 3 -r \"${source_upload_dir}\" \"${deploy_root_dir}/www-new\""
glob mirror -R -P 3 -r ${source_upload_dir}/* "${deploy_root_dir}/www-new"; echo "ln -s \"${deploy_root_dir}/data\" \"${deploy_root_dir}/www-new/data\"";
ln -s "${deploy_root_dir}/data" "${deploy_root_dir}/www-new/data"; echo "mv \"${deploy_root_dir}/www\" \"${deploy_root_dir}/www-old\"";
echo "mv \"${deploy_root_dir}/www-new\" \"${deploy_root_dir}/www\"";
mv "${deploy_root_dir}/www" "${deploy_root_dir}/www-old"; echo "rm -r \"${deploy_root_dir}/www-old\"";
mv "${deploy_root_dir}/www-new" "${deploy_root_dir}/www"; echo "bye";
rm -r "${deploy_root_dir}/www-old"; ) | tee | lftp
bye
SFTPCOMMANDS
exec 9>&- # Close file descriptor 9 and release the lock exec 9>&- # Close file descriptor 9 and release the lock
task_end $? "Failed to upload release"; task_end $? "Failed to upload release";