Added option app_dns
This commit is contained in:
parent
2fa48971f0
commit
90aeec2af0
2 changed files with 57 additions and 0 deletions
49
RESOURCES/OPTIONS/app_dns/app_dns.sh
Executable file
49
RESOURCES/OPTIONS/app_dns/app_dns.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
# global definitions:
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
# check the parameters
|
||||
if [ $# != 2 ]; then
|
||||
echo "usage : $0 <project_root> <dns_replacement>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
project_root="$1"
|
||||
dns_replacement="$2"
|
||||
|
||||
# check the project root folder
|
||||
if [ ! -d "$project_root" ]; then
|
||||
echo -e "${RED}ERROR: Cannot find the folder '$project_root' ${NC}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# check the target file
|
||||
def_target="$project_root/unpacked/squashfs-root/app/app"
|
||||
if [ ! -f "$def_target" ]; then
|
||||
echo -e "${RED}ERROR: Cannot find the target file '$def_target' ${NC}"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# patch the app
|
||||
old_dns=$(echo -n "$dns_replacement" | cut -d "|" -f 1)
|
||||
new_dns=$(echo -n "$dns_replacement" | cut -d "|" -f 2)
|
||||
if [ -z "$old_dns" ] || [ -z "$new_dns" ]; then
|
||||
echo -e "${RED}ERROR: The requested DNS replacement is not valid: '$dns_replacement' ${NC}"
|
||||
exit 4
|
||||
fi
|
||||
dns_url="udp://$old_dns:53"
|
||||
# find all records with offsets that match the requested old DNS
|
||||
results=$(grep --binary-files=text -b -o "$dns_url" "$def_target" | xargs echo -n)
|
||||
if [ -z "$results" ]; then
|
||||
echo -e "${RED}ERROR: The 'app' might be already patched. Cannot find the expected DNS '$dns_url' ${NC}"
|
||||
exit 5
|
||||
fi
|
||||
# replace all found old DNS with the new one
|
||||
for result in $results; do
|
||||
offset=$(echo -n "$result" | awk -F: '{print $1}')
|
||||
printf "udp://%s:53\x00" "$new_dns" | dd of="$def_target" bs=1 seek="$offset" conv=notrunc &>>/dev/null
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -66,6 +66,14 @@ kobra_unleashed="localhost.mr-a.de"
|
|||
# Available settings are: 5s, 10s, 20s, 30s and 60s
|
||||
app_net_ready="30s"
|
||||
|
||||
# Modify the hardcoded app DNS
|
||||
# For parameter(s) provide "old_dns|new_dns"
|
||||
# Available hardcoded DNS in the app:
|
||||
# "8.8.8.8", "208.67.222.222", "114.114.114.114", "223.5.5.5"
|
||||
# You can replace one, more or all of them
|
||||
# Example: app_dns="208.67.222.222|4.4.4.4" "223.5.5.5|8.8.4.4"
|
||||
#app_dns="223.5.5.5|8.8.4.4"
|
||||
|
||||
# Replace some of the app images
|
||||
# Use it for one or more sets: app_images="set1" "set2" "set3"
|
||||
#app_images="set1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue