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

Auth funcionality added #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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