-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote branch 'upstreamrepo/main'
- Loading branch information
Showing
7 changed files
with
72 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,69 @@ | ||
#!/bin/bash | ||
|
||
ret=0 | ||
base_url="192.168.0.90" | ||
exclude_dir_list="\ | ||
--exclude-dir=.github \ | ||
--exclude-dir=src \ | ||
--exclude-dir=_site \ | ||
--exclude-dir=capture \ | ||
--exclude=test.sh \ | ||
" | ||
allowed_patterns="\ | ||
\`$base_url\` \ | ||
$base_url<space> \ | ||
$base_url/index.html \ | ||
$base_url/axis-cgi \ | ||
@$base_url \ | ||
" | ||
|
||
# Set +e to not having to handle the grep exit status | ||
__url_grep_list=$(grep -nir "$base_url" $exclude_dir_list | \ | ||
grep -vE "$base_url(\`| |/axis-cgi|/index.html#)" | \ | ||
grep -vE "@$base_url" || :) | ||
[ -z "$__url_grep_list" ] || { | ||
#------------------------------------------------------------------------------- | ||
# Functions | ||
#------------------------------------------------------------------------------- | ||
|
||
print_section() { | ||
local sep40="----------------------------------------" | ||
printf '\n\n%s\n%s\n%s\n' "$sep40$sep40" " $*" "$sep40$sep40" | ||
} | ||
|
||
check_device_ip_paths() { | ||
local ret=0 | ||
local __url_grep_list= | ||
local base_url="192.168.0.90" | ||
local exclude_dir_list="\ | ||
--exclude-dir=.github \ | ||
--exclude-dir=.git \ | ||
--exclude-dir=src \ | ||
--exclude-dir=_site \ | ||
--exclude-dir=capture \ | ||
" | ||
local allowed_patterns="\ | ||
\`$base_url\` \ | ||
$base_url<end-of-line> \ | ||
$base_url<space> \ | ||
$base_url: \ | ||
$base_url/index.html#[a-z] \ | ||
$base_url/axis-cgi \ | ||
$base_url/local \ | ||
@$base_url \ | ||
" | ||
|
||
print_section "Check that device URLs follow allowed pattern" | ||
|
||
# shellcheck disable=SC2086 | ||
__url_grep_list=$(grep -nir "$base_url" $exclude_dir_list | | ||
grep -vE "$base_url(\`|$| |:|/axis-cgi|/index.html#[a-z]|/local)" | | ||
grep -vE "@$base_url" || :) | ||
|
||
if [ "$__url_grep_list" ]; then | ||
printf '\n%s\n%s\n\n' \ | ||
"## Error - The following device URLs are not matching allowed patterns" \ | ||
"$__url_grep_list" | ||
printf "## Allowed patterns (Including URLs prefixed http://):\n" | ||
for pattern in $allowed_patterns | ||
do | ||
for pattern in $allowed_patterns; do | ||
printf '%s\n' "* $pattern" | ||
done | ||
printf "\nA typical error is to copy the redirected URL that include e.g. product specific string 'camera'\n" | ||
ret=1 | ||
else | ||
printf "* All device URLs follow pattern\n" | ||
fi | ||
|
||
return $ret | ||
} | ||
exit $ret | ||
|
||
#------------------------------------------------------------------------------- | ||
# Main | ||
#------------------------------------------------------------------------------- | ||
|
||
exit_value=0 | ||
found_error=no | ||
|
||
if ! check_device_ip_paths; then found_error=yes; fi | ||
|
||
[ "$found_error" = no ] || exit_value=1 | ||
|
||
exit $exit_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ that can communicate via SSH. This will be exemplified using `ssh` and a | |
non-root SSH user called `my-ssh-user`. | ||
|
||
> The SSH user needs to be created on the device before connecting to the | ||
> device, see [Create an SSH user](create-an-ssh-user). | ||
> device, see [Create an SSH user](#create-an-ssh-user). | ||
```sh | ||
ssh [email protected] | ||
|