Commit ca98bdd2 authored by sokai's avatar sokai

UPDATEURL is now full URL + fix for more consistent usage of bash vars

parent b38b0cb8
......@@ -9,16 +9,16 @@
SCRIPTNAME='ffp-apdb'
SCRIPTPATH='/etc/init.d/' # _with_ trailing / !
UPDATEURL='http://freifunk-potsdam.de/apdb/' # _with_ trailing / !
UPDATEURL='http://freifunk-potsdam.de/apdb/ap.php'
UPGRADEURL="http://freifunk-potsdam.de/${SCRIPTNAME}.php"
##### ----- do NOT edit from this line on ----- #####
## needed for init script
## needed for init script; do: https://wiki.openwrt.org/doc/techref/initscripts
START=99
EXTRA_COMMANDS="status update upgrade"
## script
SCRIPTVERSION='160122-bf'
SCRIPTVERSION='160123-bf'
SCRIPT=${SCRIPTPATH}${SCRIPTNAME}
CRONTAB='/var/spool/cron/crontabs/root'
CRONINTERVAL=$(head -30 /dev/urandom | tr -dc "0123456789" | head -c2) # run cron hourly at a random minute
......@@ -104,16 +104,16 @@ update() {
# only one instance should be running at time
# if exists an other one kill them and all wgets
PID_FILE="/tmp/run/${SCRIPTNAME}.pid"
if [ -f $PID_FILE ]; then
if [ -f ${PID_FILE} ]; then
PID="$(cat ${PID_FILE} 2> /dev/null)"
if [ ! -z $PID ]; then
kill $PID >/dev/null 2> /dev/null
if [ ! -z ${PID} ]; then
kill ${PID} >/dev/null 2> /dev/null
fi
fi
# get rid of wget-s hanging arround
for f in /proc/[0-9]*/cmdline; do
if grep -sq 'ap.php' "$f"; then
if $(grep -sq 'ap.php' "${f}"); then
WGET_PID="${f#/proc/}";
WGET_PID="${WGET_PID%%/*}"
kill "${WGET_PID}" 2>/dev/null
......@@ -122,10 +122,10 @@ update() {
echo "$$" > $PID_FILE
KEY=$(wget -q -O - ${UPDATEURL}ap.php?mode=get)
KEY=$(wget -q -O - ${UPDATEURL}?mode=get)
PARAM="&key=${KEY}&ip=%22${IP}%22&host=%22${HOSTNAME}%22&geoloc=%22${GEOLOC}%22&location=%22${LOCATION}%22&contact=%22${CONTACT}%22&gw_ip=%22${GWIP}%22&uptime=%22${UPTIME}%22&machine=%22${MACHINE}%22&systemtype=%22${SYSTEMTYPE}%22&scriptversion=%22${SCRIPTVERSION}%22&firmware=%22${FIRMWARE}%22"
wget -q -O - ${UPDATEURL}ap.php?mode=put"${PARAM}"
#echo ${URL}ap.php?mode=put"${PARAM}"
wget -q -O - ${UPDATEURL}?mode=put"${PARAM}"
#echo ${URL}?mode=put"${PARAM}"
logger -t ${SCRIPTNAME} "AP information transfered to AP database (${SCRIPT} update)"
# everything looks fine
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment