1
0
mirror of https://github.com/PDP-10/its.git synced 2026-04-26 20:27:13 +00:00

Updated deploy-ftp with retry flow

This commit is contained in:
Mike Kostersitz (Oilcan Productions)
2024-04-26 16:05:17 -07:00
parent 5bc1f3195c
commit ec672e1566
4 changed files with 59 additions and 42 deletions

View File

@@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh
set -e
HOST="hactrn.kostersitz.com" HOST="hactrn.kostersitz.com"
USER="if0_35726802@hactrn.kostersitz.com" USER="if0_35726802@hactrn.kostersitz.com"
DIR="/images" DIR="/images"
TESTDIR="test" TESTDIR="test"
NETRC="$HOME/.netrc" NETRC="$HOME/.netrc"
RETRY_LIMIT=5
retry_count=0
if test -z "$FTP_SECRET"; then if test -z "$FTP_SECRET"; then
echo 'ERROR: No password in $FTP_SECRET.' echo 'ERROR: No password in $FTP_SECRET.'
@@ -18,11 +18,12 @@ echo "login $USER" >> "$NETRC"
echo "password $FTP_SECRET" >> "$NETRC" echo "password $FTP_SECRET" >> "$NETRC"
chmod 600 "$NETRC" chmod 600 "$NETRC"
(cd out; tar czf $EMULATOR.tgz $EMULATOR) upload_file(){
(cd out; tar czf $EMULATOR.tgz $EMULATOR)
echo "Deploying as $USER at $HOST" echo "Deploying as $USER at $HOST"
ftp "$HOST" <<EOF ftp "$HOST" <<EOF
passive on passive on
type image type image
cd $DIR cd $DIR
@@ -30,49 +31,64 @@ lcd out
put $EMULATOR.tgz put $EMULATOR.tgz
bye bye
EOF EOF
}
# test the upload and see if it expands correctly test_archive_integrity(){
echo "Testing download of $EMULATOR.tgz" echo "Testing download of $EMULATOR.tgz"
mkdir -p "$TESTDIR" mkdir -p "$TESTDIR"
cd "$TESTDIR" cd "$TESTDIR"
curl "http://$HOST/$DIR/$EMULATOR.tgz" -o "$EMULATOR.tgz" curl "http://$HOST/$DIR/$EMULATOR.tgz" -o "$EMULATOR.tgz"
if [ ! -f "$EMULATOR.tgz" ]; then if [ ! -f "$EMULATOR.tgz" ]; then
echo "File $EMULATOR.tgz not found!" echo "File $EMULATOR.tgz not found!"
exit 1 cd ..
else rm -rf "$TESTDIR"
echo "Testing archive $EMULATOR.tgz" return 1
tar -xzf "$EMULATOR.tgz"
if [ $? -eq 0 ]; then
echo "Unpacking successful!"
else else
echo "Error unpacking $EMULATOR.tgz: $(tar -xzf "$EMULATOR.tgz" 2>&1)" echo "Testing archive $EMULATOR.tgz"
exit 1 if tar -xzf "$EMULATOR.tgz"; then
echo "Unpacking successful!"
else
echo "Error unpacking $EMULATOR.tgz: $(tar -xzf "$EMULATOR.tgz" 2>&1)"
cd ..
rm -rf "$TESTDIR"
return 1
fi
fi fi
fi
echo "Testing archive integrity" echo "Testing archive integrity"
# Define the paths to the folders BUILDDIR="../$EMULATOR"
BUILDDIR="../$EMULATOR" DLDIR="./$EMULATOR"
DLDIR="./$EMULATOR"
# Generate MD5 hashes for files in FOLDER1 (with relative filenames) find "$BUILDDIR" -type f -exec md5sum {} + | sed "s|$BUILDDIR/||" > "$BUILDDIR_hashes.txt"
find "$BUILDDIR" -type f -exec md5sum {} + | sed "s|$BUILDDIR/||" > "$BUILDDIR_hashes.txt" find "$DLDIR" -type f -exec md5sum {} + | sed "s|$DLDIR/||" > "$DLDIR_hashes.txt"
# Generate MD5 hashes for files in FOLDER2 (with relative filenames) if cmp -s "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt"; then
find "$DLDIR" -type f -exec md5sum {} + | sed "s|$DLDIR/||" > "$DLDIR_hashes.txt" echo "The contents of $BUILDDIR and $DLDIR are binary identical."
cd ..
rm -rf "$TESTDIR"
return 0
else
echo "Differences found between $BUILDDIR and $DLDIR:"
diff -u "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt"
cd ..
rm -rf "$TESTDIR"
return 1
fi
}
# Compare the hash files
if cmp -s "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt"; then
echo "The contents of $BUILDDIR and $DLDIR are binary identical."
else
echo "Differences found between $BUILDDIR and $DLDIR:"
diff -u "$BUILDDIR_hashes.txt" "$DLDIR_hashes.txt"
fi
# Clean up temporary files while [ $retry_count -lt $RETRY_LIMIT ]; do
cd .. upload_file
rm -r "$TESTDIR" if test_archive_integrity; then
echo "File integrity verified successfully."
exit 0
else
echo "File integrity verification failed, retrying... ($((retry_count+1))/$RETRY_LIMIT)"
retry_count=$((retry_count+1))
fi
done
exit 0 echo "Reached maximum retry limit, exiting with failure."
exit 1

1
tools/tv11.old Submodule

Submodule tools/tv11.old added at e45a330754