...
 
Showing with 36 additions and 27 deletions
......@@ -5,6 +5,26 @@ The APDB consists of two parts:
A productive used installation is available at http://freifunk-potsdam.de/apdb/.
## Installation (at Access Point)
* `ssh` into your AP
* execute the following commands (copy-paste-ready)
```bash
wget -q -O - 'http://freifunk-potsdam.de/ffp-apdb.php' > /etc/init.d/ffp-apdb && \
chmod +x /etc/init.d/ffp-apdb; \
/etc/init.d/ffp-apdb start
```
## Configuration
* edit `/etc/init.d/ffp-apdb`for your needs
## (Self-)Upgrade
* `ssh` into your AP
```bash
/etc/init.d/ffp-apdb upgrade
```
## Legal
APDB is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
......@@ -33,24 +53,3 @@ A productive used installation is available at http://freifunk-potsdam.de/apdb/.
Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
## Installation (at Access Point)
* `ssh` into your AP
* execute the following commands (copy-paste-ready)
```bash
wget -q -O - 'http://freifunk-potsdam.de/ffp-apdb.php' > /etc/init.d/ffp-apdb && \
chmod +x /etc/init.d/ffp-apdb; \
/etc/init.d/ffp-apdb enable; \
/etc/init.d/ffp-apdb start
```
## Configuration
* edit `/etc/init.d/ffp-apdb`for your needs
## Upgrade
* `ssh` into your AP
```bash
/etc/init.d/ffp-apdb upgrade
```
......@@ -52,25 +52,36 @@ SYSTEMTYPE=$(grep 'system type' /proc/cpuinfo|awk '{$1=$2=""; print}'| sed 's/
#CLIENTS=$(cat /tmp/dhcp.leases|wc -l)
start() {
# INFO: enable init script AND add update cron job
if [ ! -f "/etc/rc.d/S${START}${SCRIPTNAME}" ]; then
enable
logger -t ${SCRIPTNAME} "init scrip enabled (${SCRIPT} start)"
fi
if ! $(grep -q ${SCRIPT} ${CRONTAB}); then
CRONJOB="${UPDATEINTERVAL} * * * * ${SCRIPT} update # FreiFunkPotsdam-AccessPointsDataBase"
CRONJOB="${UPDATEINTERVAL} * * * * ${SCRIPT} update # FreiFunkPotsdam-AccessPointsDataBase (v${SCRIPTVERSION})"
echo "${CRONJOB}" >> ${CRONTAB}
echo "${CRONTABUSER}" > ${CRONTABPATH}cron.update # reload crontab
logger -t ${SCRIPTNAME} "update cron job (every ${UPDATEINTERVAL} minute past every hour) for user ${CRONTABUSER} added (${SCRIPT} start)"
logger -t ${SCRIPTNAME} "update cron job (every ${UPDATEINTERVAL}th minute past every hour) for user ${CRONTABUSER} added (${SCRIPT} start)"
update
fi
}
stop() {
# INFO: remove update cron job AND disable init script
if $(grep -q ${SCRIPT} ${CRONTAB}) ;then
# better grep than sed with unescaped file pathes ... -> http://stackoverflow.com/a/5413132/338049
grep -v ${SCRIPT} ${CRONTAB} > /tmp/crontab.temp && mv /tmp/crontab.temp ${CRONTAB} && chmod 600 ${CRONTAB}
echo "root" > /var/spool/cron/crontabs/cron.update # reload crontab
logger -t ${SCRIPTNAME} "cron job removed (${SCRIPT} stop)"
fi
if [ -f "/etc/rc.d/S${START}${SCRIPTNAME}" ]; then
disable
logger -t ${SCRIPTNAME} "init scrip disabled (${SCRIPT} stop)"
fi
}
update() {
# INFO: updates own status to remote database
# only one instance should be running at time
# if exists an other one kill them and all wgets
PID_FILE="/tmp/run/${SCRIPTNAME}.pid"
......@@ -103,7 +114,7 @@ update() {
}
upgrade() {
## self-upgrade of this script
# INFO: self-upgrade of this script
NEWSCRIPT="/tmp/${SCRIPTNAME}"
wget -q -O ${NEWSCRIPT} ${UPGRADEURL} 2>/dev/null
......@@ -111,17 +122,16 @@ upgrade() {
if [ -f ${NEWSCRIPT} ]; then
# remove current script
stop
disable
# install new script
chmod +x ${NEWSCRIPT}
mv ${NEWSCRIPT} ${SCRIPT}
${SCRIPT} enable
${SCRIPT} start
VERSION=$(grep 'SCRIPTVERSION=' ${SCRIPT} -m 1 | cut -f2 -d'='|sed 's/ /%20/g'|sed "s/'//g")
SUCCESS="version (${VERSION}) installed at ${SCRIPT} (${SCRIPT} upgrade)"
echo ${SUCCESS}
logger -t ${SCRIPTNAME} ${SUCCESS}
exec ${SCRIPT} start && exit
else
ERROR="download wasn't successful, so current version remains at ${SCRIPT} (${SCRIPT} upgrade)"
echo ${ERROR}
......