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

ffac-ssid-changer: replace string indexing #55

Merged
Merged
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
8 changes: 4 additions & 4 deletions ffac-ssid-changer/shsrc/ssid-changer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ if [ "$SETTINGS_SUFFIX" = 'nodename' ]; then
# 32 would be possible as well
if [ ${#SUFFIX} -gt $((30 - ${#PREFIX})) ]; then
# calculate the length of the first part of the node identifier in the offline-ssid
HALF=$(( (28 - ${#PREFIX} ) / 2 ))
# jump to this charakter for the last part of the name
SKIP=$(( ${#SUFFIX} - HALF ))
max_suffix_length=$(( (28 - ${#PREFIX} ) / 2 ))
# use the first and last part of the nodename for nodes with long name
SUFFIX=${SUFFIX:0:$HALF}...${SUFFIX:$SKIP:${#SUFFIX}}
suffix_first_chars="$(printf '%s' "$SUFFIX" | head -c ${max_suffix_length})"
suffix_last_chars="$(printf '%s' "$SUFFIX" | tail -c ${max_suffix_length})"
SUFFIX="${suffix_first_chars}...${suffix_last_chars}"
fi
elif [ "$SETTINGS_SUFFIX" = 'mac' ]; then
SUFFIX="$(uci -q get network.bat0.macaddr | /bin/sed 's/://g')"
Expand Down