25 lines
683 B
Bash
25 lines
683 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
|
||
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||
|
|
source $SCRIPT_DIR/constants.sh
|
||
|
|
source $SCRIPT_DIR/functions.sh
|
||
|
|
|
||
|
|
# Setup logging
|
||
|
|
setup_logging
|
||
|
|
|
||
|
|
# Trap signals to ensure proper cleanup
|
||
|
|
trap 'cleanup 1' HUP INT QUIT TERM
|
||
|
|
|
||
|
|
path=$VK_CATEGORIES_PATH/$VK_API_GROUP_ID
|
||
|
|
mkdir -p $path
|
||
|
|
printf -v fileName "$VK_RESPONSE_FILE_NAME_FORMAT.$VK_RESPONSE_FILE_NAME_EXT" -1
|
||
|
|
|
||
|
|
# Handle request for categories
|
||
|
|
handle_vk_request "categories list" "$VK_API_GET_CATEGORIES" "$path" "$fileName" "" false
|
||
|
|
|
||
|
|
# Clean up old files
|
||
|
|
find $path ! -type d -mmin +$VK_STORE_PERIOD_MINUTES -delete
|
||
|
|
|
||
|
|
# Use the cleanup function instead of directly exiting
|
||
|
|
cleanup 0
|