Improve import script UI, errors (#887)
* Improve import script UI, errors * Fix jq check * Add space between ! and which
This commit is contained in:
parent
3e6508f484
commit
ce8e22ae3b
1 changed files with 39 additions and 7 deletions
42
docker/prod/migrate-pictshare-to-pictrs.bash
vendored
42
docker/prod/migrate-pictshare-to-pictrs.bash
vendored
|
@ -11,6 +11,11 @@ if [[ ! -f docker-compose.yml ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! which jq > /dev/null; then
|
||||||
|
echo "jq must be installed to run this migration. On ubuntu systems, try 'sudo apt-get install jq'"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# Fixing pictrs permissions
|
# Fixing pictrs permissions
|
||||||
mkdir -p volumes/pictrs
|
mkdir -p volumes/pictrs
|
||||||
sudo chown -R 991:991 volumes/pictrs
|
sudo chown -R 991:991 volumes/pictrs
|
||||||
|
@ -26,6 +31,8 @@ fi
|
||||||
# echo "Stopping Lemmy so that users dont upload new images during the migration"
|
# echo "Stopping Lemmy so that users dont upload new images during the migration"
|
||||||
# docker-compose stop lemmy
|
# docker-compose stop lemmy
|
||||||
|
|
||||||
|
CRASHED_ON=()
|
||||||
|
|
||||||
pushd volumes/pictshare/
|
pushd volumes/pictshare/
|
||||||
echo "Importing pictshare images to pict-rs..."
|
echo "Importing pictshare images to pict-rs..."
|
||||||
IMAGE_NAMES=*
|
IMAGE_NAMES=*
|
||||||
|
@ -34,11 +41,36 @@ for image in $IMAGE_NAMES; do
|
||||||
if [[ ! -f $IMAGE_PATH ]]; then
|
if [[ ! -f $IMAGE_PATH ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo -e "\nImporting $IMAGE_PATH"
|
res=$(curl -s -F "images[]=@$IMAGE_PATH" http://127.0.0.1:8537/import | jq .msg)
|
||||||
ret=0
|
if [ "${res}" == "" ]; then
|
||||||
curl --silent --fail -F "images[]=@$IMAGE_PATH" http://127.0.0.1:8537/import || ret=$?
|
echo -n "C" >&2
|
||||||
if [[ $ret != 0 ]]; then
|
echo ""
|
||||||
echo "Error for $IMAGE_PATH : $ret"
|
CRASHED_ON+=("${IMAGE_PATH}")
|
||||||
|
echo "Failed to import $IMAGE_PATH with no error message"
|
||||||
|
echo " assuming crash, sleeping"
|
||||||
|
sleep 10
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "${res}" != "\"ok\"" ]; then
|
||||||
|
echo -n "F" >&2
|
||||||
|
echo ""
|
||||||
|
echo "Failed to import $IMAGE_PATH"
|
||||||
|
echo " Reason: ${res}"
|
||||||
|
else
|
||||||
|
echo -n "." >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for image in ${CRASHED_ON[@]}; do
|
||||||
|
echo "Retrying ${image}"
|
||||||
|
res=$(curl -s -F "images[]=@$IMAGE_PATH" http://127.0.0.1:8537/import | jq .msg)
|
||||||
|
if [ "${res}" != "\"ok\"" ]; then
|
||||||
|
echo -n "F" >&2
|
||||||
|
echo ""
|
||||||
|
echo "Failed to upload ${image} on 2nd attempt"
|
||||||
|
echo " Reason: ${res}"
|
||||||
|
else
|
||||||
|
echo -n "." >&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue