2017-02-27 23:45:08 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Check to see if this script has access to all the commands it needs
|
|
|
|
for CMD in sshfs rsync find fusermount mkdir; do
|
|
|
|
type $CMD 2>&1 > /dev/null
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo
|
|
|
|
echo "ERROR: The script cannot find the required command \"${CMD}\"."
|
|
|
|
echo
|
2017-02-28 21:28:07 +08:00
|
|
|
exit 1
|
2017-02-27 23:45:08 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-03-05 00:16:05 +08:00
|
|
|
# We only want to deploy packages during cron events
|
|
|
|
# See https://docs.travis-ci.com/user/cron-jobs/
|
2019-09-23 01:02:13 +08:00
|
|
|
if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then
|
2017-02-27 23:45:08 +08:00
|
|
|
|
2017-04-22 07:57:10 +08:00
|
|
|
if [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then
|
2017-05-03 02:44:34 +08:00
|
|
|
targetfolder="debian/master/mini-dinstall/incoming"
|
2017-04-22 07:57:10 +08:00
|
|
|
else
|
|
|
|
targetfolder="travis"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Target subfolder set to $targetfolder"
|
|
|
|
echo
|
2019-10-09 00:31:01 +08:00
|
|
|
if [ "${USE_SFTP}" == "yes" ]; then
|
2019-11-19 22:36:43 +08:00
|
|
|
echo "Running \$(rsync -v -e 'ssh -vvv' build/* zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1)"
|
2019-11-21 03:21:01 +08:00
|
|
|
rsync -v -e 'ssh -vvv' build/* zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2019-10-09 00:31:01 +08:00
|
|
|
echo
|
|
|
|
echo "Files copied successfully."
|
2017-04-19 20:11:20 +08:00
|
|
|
echo
|
2019-10-09 00:31:01 +08:00
|
|
|
else
|
2017-03-05 00:16:05 +08:00
|
|
|
echo
|
2019-10-10 01:00:29 +08:00
|
|
|
echo "ERROR: Attempt to rsync to zmrepo.zoneminder.com failed!"
|
2017-03-05 00:16:05 +08:00
|
|
|
echo
|
2017-04-19 20:11:20 +08:00
|
|
|
exit 99
|
2019-10-09 00:31:01 +08:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
mkdir -p ./zmrepo
|
|
|
|
ssh_mntchk="$(sshfs zmrepo@zmrepo.zoneminder.com:./ ./zmrepo -o workaround=rename,reconnect 2>&1)"
|
|
|
|
|
|
|
|
if [ -z "$ssh_mntchk" ]; then
|
|
|
|
echo
|
|
|
|
echo "Remote filesystem mounted successfully."
|
|
|
|
echo "Begin transfering files..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
# Don't keep packages older than 5 days
|
|
|
|
find ./zmrepo/$targetfolder/ -maxdepth 1 -type f,l -mtime +5 -delete
|
|
|
|
rsync -vzlh --ignore-errors build/* zmrepo/$targetfolder/
|
|
|
|
fusermount -zu zmrepo
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "ERROR: Attempt to mount zmrepo.zoneminder.com failed!"
|
|
|
|
echo "sshfs gave the following error message:"
|
|
|
|
echo \"$ssh_mntchk\"
|
|
|
|
echo
|
|
|
|
exit 99
|
|
|
|
fi
|
2017-03-05 00:16:05 +08:00
|
|
|
fi
|
|
|
|
fi
|