Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit script if scan cancelled #35

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions script/scanRear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ fi
device="$1"
script_dir="/opt/brother/scanner/brscan-skey/script"

set -e # Exit on error

mkdir -p /tmp
cd /tmp || exit
cd /tmp
date=$(ls -rd */ | grep "$(date +"%Y-%m-%d")" | head -1)
date=${date%/}
tmp_dir="/tmp/${date}"
Expand All @@ -25,7 +27,7 @@ tmp_output_file="${filename_base}%04d.pnm"
tmp_output_pdf_file="${tmp_dir}/${date}.pdf"
output_pdf_file="/scans/${date}.pdf"

cd "$tmp_dir" || exit
cd "$tmp_dir"

kill -9 "$(cat scan_pid)"
rm scan_pid
Expand Down
6 changes: 5 additions & 1 deletion script/scantofile-0.2.4-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
tmp_output_file="${filename_base}%04d.pnm"
output_pdf_file="/scans/${date}.pdf"

set -e # Exit on error

mkdir -p "$tmp_dir"
cd "$tmp_dir" || exit
cd "$tmp_dir"
filename_base="/tmp/${date}/${date}-front-page"
output_file="${filename_base}%04d.pnm"
echo "filename: $tmp_output_file"

function scan_cmd() {
Expand Down
23 changes: 11 additions & 12 deletions script/trigger_telegram.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
# Check if TELEGRAM_TOKEN and TELEGRAM_CHATID are both set
if [ -z "${TELEGRAM_TOKEN}" ] || [ -z "${TELEGRAM_CHATID}" ]; then
echo "TELEGRAM_TOKEN or TELEGRAM_CHATID is not set"
exit 1
fi

# Use the environment variables TELEGRAM_TOKEN and TELEGRAM_CHATID
TOKEN="$TELEGRAM_TOKEN"
CHAT_ID="$TELEGRAM_CHATID"
else
# Use the environment variables TELEGRAM_TOKEN and TELEGRAM_CHATID
TOKEN="$TELEGRAM_TOKEN"
CHAT_ID="$TELEGRAM_CHATID"

# The message is passed as a parameter
MESSAGE="Scanner: $1"
# The message is passed as a parameter
MESSAGE="Scanner: $1"

# URL encode the message to handle spaces and special characters
ENCODED_MESSAGE=$(echo "$MESSAGE" | jq -sRr @uri)
# URL encode the message to handle spaces and special characters
ENCODED_MESSAGE=$(echo "$MESSAGE" | jq -sRr @uri)

# Send the message using wget
wget -qO- --post-data="chat_id=$CHAT_ID&text=$ENCODED_MESSAGE" "https://api.telegram.org/$TOKEN/sendMessage" >/dev/null
# Send the message using wget
wget -qO- --post-data="chat_id=$CHAT_ID&text=$ENCODED_MESSAGE" "https://api.telegram.org/$TOKEN/sendMessage" >/dev/null
fi
Loading