/usr/lib/bosixnet/update_hosts is in bosixnet-daemon 1.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #!/bin/sh
# Config file
CONF_FILE="/etc/bosixnet/bosixnet-daemon.conf"
# Directory where generated host file is stored
LOG_DIR="/var/tmp/bosixnet"
# Default web-site URL
URL="http://ipv6.example.com/bosixnet"
# Read settings from config file if it exists
[ -e "${CONF_FILE}" ] && . "${CONF_FILE}"
# Protect file with list of hosts from simultaneous editing
SCRIPT_NAME="$(basename ${0})"
if [ ! -z "$(pidof -o %PPID -x ${SCRIPT_NAME})" ]; then
echo "Another instance of ${SCRIPT_NAME} script is already running."
echo "Please wait until it is finished and try again."
exit 1
fi
HOSTS="/etc/hosts"
FILE="${LOG_DIR}/hosts"
[ -e "${FILE}" ] && CUR_INFO="$(cat ${FILE} | grep '^....:.*:.*:.*')"
if [ -z "${CUR_INFO}" ]; then
echo "File ${FILE} does not exist or does not contain correct data."
for DEST in ${URL} ; do
LINK="${DEST}/hosts"
echo "Trying to get data from ${LINK}..."
CUR_INFO="$(curl -L ${LINK} 2>/dev/null | sed 's/<br>//' | grep '^....:.*:.*:.*')"
if [ -z "${CUR_INFO}" ]; then
echo "Attempt to get data from ${LINK} failed."
else
echo "Data from ${LINK} have been received successfully."
break
fi
done
fi
if [ -z "${CUR_INFO}" ]; then
echo "Data failed to be received from specified resources."
exit 1
fi
cp -f "${HOSTS}" "${HOSTS}.backup"
cat "${HOSTS}.backup" | grep -v '^....:.*:.*:.*' | tee "${HOSTS}" > /dev/null
echo "${CUR_INFO}" | tee -a "${HOSTS}" > /dev/null
|