/sqs-‐‑‒waifu2x.bash #!/bin/bash INTERVAL=30 REGION=us-‐‑‒west-‐‑‒1 QUEUE_̲URL=https://sqs.us-‐‑‒west-‐‑‒1.amazonaws.com/602604506680/waifu2x_̲input BUCKET_̲NAME=waifu2x-‐‑‒sample export HOME=/root cd /home/ubuntu/waifu2x/ if [ ! -‐‑‒d out/ ]; then mkdir out/ fi while : do aws sqs receive-‐‑‒message -‐‑‒-‐‑‒queue-‐‑‒url \$QUEUE_̲URL -‐‑‒-‐‑‒region \$REGION -‐‑‒-‐‑‒output text > result.txt if [ -‐‑‒s result.txt ]; then SOURCE_̲URL=\`̀cut -‐‑‒f 2 < result.txt\`̀ RECEIPT_̲HANDLE=\`̀cut -‐‑‒f 5 < result.txt\`̀ wget \$SOURCE_̲URL IMG_̲FILENAME=\`̀basename \$SOURCE_̲URL\`̀ th waifu2x.lua -‐‑‒i \$IMG_̲FILENAME -‐‑‒o out/\${IMG_̲FILENAME} aws s3 cp -‐‑‒-‐‑‒region \$REGION out/\${IMG_̲FILENAME} s3://\${BUCKET_̲NAME}/\${IMG_̲FILENAME} aws sqs delete-‐‑‒message -‐‑‒-‐‑‒receipt-‐‑‒handle \$RECEIPT_̲HANDLE -‐‑‒-‐‑‒queue-‐‑‒url \$QUEUE_̲URL -‐‑‒-‐‑‒region \$REGION else sleep \$INTERVAL fi done EOF nohup bash /sqs-‐‑‒waifu2x.bash