0

I have a script that is a one time run to copy all of our SSLs over to a sandbox server. The script took me 15 mins to build, and it works perfectly, for a single iteration! It's the tar or ssh command that is causing the script to exit, but I can't figure out why, since the script is working flawless, with no exit codes:

#!/bin/bash

mysql --login-path=main-data -Ne "SELECT user_file FROM table" | while read user_file; do

echo "$user_file | /var/www/liveSites/websites/$user_file/ssl"

mkdir -p /var/www/liveSites/websites/$user_file
chmod -R a+w /var/www/liveSites/websites/$user_file

rm -rf /var/www/liveSites/websites/$user_file/ssl

sshpass -p SUPERSECRET ssh user@8.8.8.8 tar -zcvf - /var/www/liveSites/websites/$user_file/ssl > /var/www/liveSites/websites/$user_file/ssl.tgz --absolute-names

tar -zxvf /var/www/liveSites/websites/$user_file/ssl.tgz --absolute-names

chmod -R a+w /var/www/liveSites/websites/$user_file/ssl

rm /var/www/liveSites/websites/$user_file/ssl.tgz

done

Why when remote tar-ing a directory is my script working, exiting after first iteration without error?

The last line of the loop rm ... runs, so I know it's not "breaking" before that.

Zak
  • 6,976
  • 2
  • 26
  • 48

0 Answers0