#!/bin/bash
# FLAN: Flan Local-Access Notifier
# http://www.aperture.akron.oh.us/~asm/flan/
#
# Maintainer: Anton McClure
#             http://www.aperture.akron.oh.us/~asm/
#             asm@aperture.akron.oh.us
#
# Copyright (C) 2025, 2026 Anton McClure
# All rights reserved.
apt-get install -y make gcc xorg lib{xml2-*,x{11,pm},curl4-gnutls}-dev xinit xfonts-{base,{75,100}dpi}
mkdir -p /usr/local/share/flan/ && \
wget http://www.aperture.akron.oh.us/~coblabs/cal/uakron.xpm -O /usr/local/share/flan/uakron.xpm && \
cd /tmp/ && \
FLANVER=$(wget "http://ocelot.aperture.akron.oh.us/flan/ver" -O-)
wget "http://ocelot.aperture.akron.oh.us/flan/flan-${FLANVER}-gnu-amd64.tar.gz" -O flan-${FLANVER}-gnu-amd64.tar.gz && \
tar -xzvf flan-${FLANVER}-gnu-amd64.tar.gz && \
cd flan-${FLANVER}-gnu-amd64/ && \
printf "/bin/wget --retry-connrefused --waitretry=1 --timeout=360 --quiet --output-document=/tmp/setup.bash http://www.aperture.akron.oh.us/~coblabs/cal/setup.bash && /bin/bash /tmp/setup.bash; /bin/rm /tmp/setup.bash" > /usr/local/bin/update-cobcal && \
chmod +x /usr/local/bin/update-cobcal && \
make install && \
wget http://www.aperture.akron.oh.us/ucgi/~coblabs/cobcal/config.cgi?$(hostname -s | tr -d '\r\n') -O /etc/flan.cfg && \
wget http://www.aperture.akron.oh.us/ucgi/~coblabs/cobcal/cron.cgi?$(hostname -s | tr -d '\r\n') -O /etc/cron.d/cobcal && \
update-rc.d flan defaults
service flan restart
