Skip to content
Open
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
18 changes: 17 additions & 1 deletion icons/upload_icon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ upload_icon() {
curl -L -s -X GET "$GIF_FILE" -o "$TEMP_FILE"

if verify_gif "$TEMP_FILE"; then
curl -X POST -F "file=@$TEMP_FILE;filename=/ICONS/$FILE_NAME" "$URL"
curl -X POST -F "file=@$TEMP_FILE;filename=/ICONS/$FILE_NAME" "$URL" $AUTH
echo -e "${GREEN}Uploaded icon:${NC} $FILE_NAME${NC}"
else
echo -e "${RED}Error: File $FILE_NAME does not appear to be a valid GIF file.${NC}"
Expand All @@ -89,6 +89,19 @@ upload_icon() {
rm -f "$TEMP_FILE"
}

# Prompt for authentication if required
prompt_for_auth() {
read -rp "Is authentication required on awtrix device? (y/n): " auth_needed
if [[ "$auth_needed" == "y" ]]; then
read -rp "Enter username: " USERNAME
read -rsp "Enter password: " PASSWORD
echo
AUTH="--user \"$USERNAME:$PASSWORD\""
else
AUTH=""
fi
}

# Prompt for IP address if not provided as a command-line argument
prompt_ip_address() {
if [ -z "$1" ]; then
Expand All @@ -112,6 +125,9 @@ main() {
# Prompt for IP address
prompt_ip_address "$1"

# Prompt for Auth
prompt_for_auth

# List icon directories
echo -e "${GREEN}Available icon directories:${NC}"
directories=($(list_icon_directories))
Expand Down