2020-01-03 21:16:40 +01:00
#!/bin/bash
set -e
2020-11-28 01:35:52 +01:00
if [ -d /bup ] ; then
echo Talk to @PIL. Dieses Skript ist nichts fuer dich!
exit 1
fi
2020-04-10 22:50:12 +02:00
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
2020-01-03 21:16:40 +01:00
srcdir = /run/dump1090-fa
repo = "https://github.com/wiedehopf/tar1090"
db_repo = "https://github.com/wiedehopf/tar1090-db"
ipath = /usr/local/share/tar1090
lighttpd = no
nginx = no
mkdir -p $ipath
2021-01-28 18:08:46 +01:00
mkdir -p $ipath /aircraft_sil
2020-01-03 21:16:40 +01:00
if ! id -u tar1090 & >/dev/null
then
2021-03-10 22:13:47 +01:00
adduser --system --home $ipath --no-create-home --quiet tar1090 || adduser --system --home-dir $ipath --no-create-home tar1090
2020-01-03 21:16:40 +01:00
fi
2021-03-10 22:13:47 +01:00
# terminate with /
2020-05-24 12:40:03 +02:00
command_package = "git git/jq jq/"
2020-07-30 10:15:58 +08:00
packages = ( )
2020-01-03 21:16:40 +01:00
while read -r -d '/' CMD PKG
do
2020-03-23 00:29:07 +01:00
if ! command -v " $CMD " & >/dev/null
then
2021-03-10 22:13:47 +01:00
#echo "command $CMD not found, will try to install package $PKG"
2020-07-30 10:15:58 +08:00
packages += ( " $PKG " )
2020-03-23 00:29:07 +01:00
fi
2020-01-03 21:16:40 +01:00
done < <( echo " $command_package " )
2021-03-10 22:13:47 +01:00
if [ [ -n " ${ packages [*] } " ] ] ; then
if ! command -v "apt-get" & >/dev/null; then
echo "Please install the following packages and rerun the install:"
echo " ${ packages [*] } "
exit 1
fi
2020-07-30 10:15:58 +08:00
echo " Installing required packages: ${ packages [*] } "
2020-03-23 00:29:07 +01:00
apt-get update || true
2021-01-11 20:39:37 +01:00
apt-get install -y --no-install-suggests --no-install-recommends " ${ packages [@] } " || true
2020-03-23 00:29:07 +01:00
hash -r || true
2020-05-24 12:40:03 +02:00
while read -r -d '/' CMD PKG
do
if ! command -v " $CMD " & >/dev/null
then
echo " command $CMD not found, seems we failed to install package $PKG "
echo "FATAL: Exiting!"
exit 1
fi
done < <( echo " $command_package " )
2020-01-03 21:16:40 +01:00
fi
if [ -d /etc/lighttpd/conf.d/ ] && ! [ -d /etc/lighttpd/conf-enabled/ ] && ! [ -d /etc/lighttpd/conf-available ] && command -v lighttpd & >/dev/null
then
ln -s /etc/lighttpd/conf.d /etc/lighttpd/conf-enabled
mkdir -p /etc/lighttpd/conf-available
fi
if [ -d /etc/lighttpd/conf-enabled/ ] && [ -d /etc/lighttpd/conf-available ] && command -v lighttpd & >/dev/null
then
2020-03-23 00:29:07 +01:00
lighttpd = yes
2020-01-03 21:16:40 +01:00
fi
if command -v nginx & >/dev/null
then
2020-03-23 00:29:07 +01:00
nginx = yes
2020-01-03 21:16:40 +01:00
fi
dir = $( pwd )
2020-10-21 12:45:24 +02:00
if ( ( $( { du -s " $ipath /git-db " 2>/dev/null || echo 0; } | cut -f1) > 150000 ) ) ; then
2020-10-21 12:32:09 +02:00
rm -rf " $ipath /git-db "
fi
2020-08-05 13:26:36 +02:00
{ [ [ " $1 " = = "test" ] ] && cd " $ipath /git-db " && git rev-parse; } ||
{ cd " $ipath /git-db " & >/dev/null && git fetch --depth 1 origin master && git reset --hard FETCH_HEAD; } ||
2020-12-26 19:58:12 +01:00
{ cd /tmp && rm -rf " $ipath /git-db " && git clone --depth 1 " $db_repo " " $ipath /git-db " ; }
2020-08-05 13:26:36 +02:00
if ! cd $ipath /git-db || ! git rev-parse
2020-01-03 21:16:40 +01:00
then
2020-08-05 13:26:36 +02:00
echo "Unable to download files, exiting! (Maybe try again?)"
exit 1
2020-01-03 21:16:40 +01:00
fi
2020-02-23 17:07:36 +01:00
DB_VERSION = $( git rev-parse --short HEAD)
2020-01-03 21:16:40 +01:00
cd " $dir "
if [ [ " $1 " = = "test" ] ]
then
2020-03-23 00:29:07 +01:00
rm -r /tmp/tar1090-test 2>/dev/null || true
mkdir -p /tmp/tar1090-test
cp -r ./* /tmp/tar1090-test
cd /tmp/tar1090-test
2020-08-05 23:27:28 +02:00
TAR_VERSION = $( date +%s)
2020-08-05 13:26:36 +02:00
else
{ cd " $ipath /git " & >/dev/null && git fetch origin master && git reset --hard FETCH_HEAD; } ||
2020-12-26 19:58:12 +01:00
{ cd /tmp && rm -rf " $ipath /git " && git clone --depth 1 " $repo " " $ipath /git " ; }
2020-01-03 21:16:40 +01:00
2020-08-05 23:27:28 +02:00
if ! cd $ipath /git || ! git rev-parse
then
echo "Unable to download files, exiting! (Maybe try again?)"
exit 1
fi
2020-11-30 22:41:53 +01:00
TAR_VERSION = " $( git rev-parse --short HEAD) "
2020-03-08 13:22:18 +01:00
fi
2020-04-19 19:00:57 +02:00
if [ -f /etc/default/tar1090_instances ] ; then
true
elif [ [ -n $1 ] ] && [ " $1 " != "test" ] ; then
2020-03-23 00:29:07 +01:00
srcdir = $1
2020-05-06 08:04:20 +02:00
elif [ [ -f /run/dump1090-fa/aircraft.json ] ] ; then
srcdir = /run/dump1090-fa
elif [ [ -f /run/readsb/aircraft.json ] ] ; then
srcdir = /run/readsb
elif [ [ -f /run/adsbexchange-feed/aircraft.json ] ] ; then
srcdir = /run/adsbexchange-feed
elif [ [ -f /run/dump1090/aircraft.json ] ] ; then
srcdir = /run/dump1090
elif [ [ -f /run/dump1090-mutability/aircraft.json ] ] ; then
srcdir = /run/dump1090-mutability
elif [ [ -f /run/skyaware978/aircraft.json ] ] ; then
srcdir = /run/skyaware978
else
echo --------------
echo FATAL: could not find aircraft.json in any of the usual places!
echo "checked these: /run/readsb /run/dump1090-fa /run/dump1090 /run/dump1090-mutability /run/adsbexchange-feed /run/skyaware978"
echo --------------
exit 1
2020-01-03 21:16:40 +01:00
fi
if [ -f /etc/default/tar1090_instances ] ; then
2020-03-23 00:29:07 +01:00
instances = $( </etc/default/tar1090_instances)
2020-01-03 21:16:40 +01:00
else
2020-03-23 00:29:07 +01:00
instances = " $srcdir tar1090 "
2020-01-03 21:16:40 +01:00
fi
if ! diff tar1090.sh /usr/local/share/tar1090/tar1090.sh & >/dev/null; then
2020-03-23 00:29:07 +01:00
changed = yes
while read -r srcdir instance; do
2020-07-22 22:40:06 +02:00
if [ [ -z " $srcdir " || -z " $instance " ] ] ; then
continue
fi
2020-03-23 00:29:07 +01:00
if [ [ " $instance " != "tar1090" ] ] ; then
service = " tar1090- $instance "
else
service = "tar1090"
fi
systemctl stop $service 2>/dev/null || true
done < <( echo " $instances " )
cp tar1090.sh $ipath
2020-01-03 21:16:40 +01:00
fi
# copy over base files
2020-05-22 05:17:34 +02:00
cp install.sh uninstall.sh LICENSE README.md $ipath
cp default $ipath /example_config_dont_edit
rm -f $ipath /default
2020-01-03 21:16:40 +01:00
2020-11-16 12:46:24 +01:00
# create 95-tar1090-otherport.conf
{
echo '# serve tar1090 directly on port 8504'
echo '$SERVER["socket"] == ":8504" {'
cat 88-tar1090.conf
echo '}'
} > 95-tar1090-otherport.conf
2020-01-03 21:16:40 +01:00
services = ""
names = ""
2020-03-16 15:08:21 +01:00
otherport = ""
2020-01-03 21:16:40 +01:00
while read -r srcdir instance
do
2020-07-22 22:40:06 +02:00
if [ [ -z " $srcdir " || -z " $instance " ] ] ; then
continue
fi
2020-07-30 10:15:58 +08:00
TMP = $( mktemp -d -p " $ipath " )
chmod 755 " $TMP "
2020-03-23 00:28:21 +01:00
2020-03-23 00:29:07 +01:00
if [ [ " $instance " != "tar1090" ] ] ; then
html_path = " $ipath /html- $instance "
service = " tar1090- $instance "
else
html_path = " $ipath /html "
service = "tar1090"
fi
services += " $service "
names += " $instance "
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
# don't overwrite existing configuration
cp -n default /etc/default/$service
sed -i -e 's/skyview978/skyaware978/' /etc/default/$service
2020-01-03 21:16:40 +01:00
2020-03-16 15:08:21 +01:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? $service ?g " \
-e "s?/INSTANCE??g" -e " s?HTMLPATH? $html_path ?g " 95-tar1090-otherport.conf
2020-11-11 15:00:53 +01:00
if [ [ " $instance " = = "webroot" ] ] ; then
2020-03-27 08:51:09 +01:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? $service ?g " \
2020-11-11 15:00:53 +01:00
-e "s?/INSTANCE??g" -e " s?HTMLPATH? $html_path ?g " 88-tar1090.conf
2020-01-19 12:38:39 +01:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? $service ?g " \
2020-11-11 15:00:53 +01:00
-e "s?/INSTANCE/?/?g" -e " s?HTMLPATH? $html_path ?g " nginx.conf
2020-03-27 08:51:09 +01:00
sed -i -e "s?/INSTANCE?/?g" nginx.conf
2020-11-11 15:00:53 +01:00
else
2020-03-27 08:51:09 +01:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? $service ?g " \
2020-11-11 15:00:53 +01:00
-e " s?INSTANCE? $instance ?g " -e " s?HTMLPATH? $html_path ?g " 88-tar1090.conf
2020-03-27 08:51:09 +01:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? $service ?g " \
2020-11-11 15:00:53 +01:00
-e " s?INSTANCE? $instance ?g " -e " s?HTMLPATH? $html_path ?g " nginx.conf
fi
2020-12-31 22:11:18 +01:00
if [ [ $lighttpd = = yes ] ] && lighttpd -v | grep -E 'lighttpd/1.4.(5[6-9]|[6-9])' -qs; then
2020-11-13 22:18:38 +01:00
sed -i -e 's/compress.filetype/deflate.mimetypes/g' 88-tar1090.conf
fi
2020-01-19 12:38:39 +01:00
2020-03-23 00:29:07 +01:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? $service ?g " tar1090.service
2020-01-03 21:16:40 +01:00
2020-07-30 10:15:58 +08:00
cp -r -T html " $TMP "
cp -r -T " $ipath /git-db/db " " $TMP /db- $DB_VERSION "
2020-11-30 21:31:41 +01:00
sed -i -e " s/let databaseFolder = .*;/let databaseFolder = \"db- $DB_VERSION \";/ " " $TMP /index.html "
2020-07-30 10:15:58 +08:00
echo " { \"tar1090Version\": \" $TAR_VERSION \", \"databaseVersion\": \" $DB_VERSION \" } " > " $TMP /version.json "
2020-03-23 00:28:21 +01:00
2020-03-23 00:29:07 +01:00
# keep some stuff around
2020-07-30 10:15:58 +08:00
mv " $html_path /config.js " " $TMP /config.js " 2>/dev/null || true
mv " $html_path /upintheair.json " " $TMP /upintheair.json " 2>/dev/null || true
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
# bust cache for all css and js files
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
dir = $( pwd )
2020-07-30 10:15:58 +08:00
cd " $TMP "
2020-03-23 00:28:21 +01:00
sed -i -e " s/tar1090 on github/tar1090 on github ( $( date +%y%m%d) )/ " index.html
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
sed -i \
-e " s/dbloader.js/dbloader_ $TAR_VERSION .js/ " \
-e " s/defaults.js/defaults_ $TAR_VERSION .js/ " \
-e " s/early.js/early_ $TAR_VERSION .js/ " \
-e " s/flags.js/flags_ $TAR_VERSION .js/ " \
-e " s/formatter.js/formatter_ $TAR_VERSION .js/ " \
-e " s/layers.js/layers_ $TAR_VERSION .js/ " \
-e " s/markers.js/markers_ $TAR_VERSION .js/ " \
-e " s/planeObject.js/planeObject_ $TAR_VERSION .js/ " \
-e " s/registrations.js/registrations_ $TAR_VERSION .js/ " \
-e " s/script.js/script_ $TAR_VERSION .js/ " \
-e " s/style.css/style_ $TAR_VERSION .css/ " \
index.html
2020-07-30 10:15:58 +08:00
mv dbloader.js " dbloader_ $TAR_VERSION .js "
mv defaults.js " defaults_ $TAR_VERSION .js "
mv early.js " early_ $TAR_VERSION .js "
mv flags.js " flags_ $TAR_VERSION .js "
mv formatter.js " formatter_ $TAR_VERSION .js "
mv layers.js " layers_ $TAR_VERSION .js "
mv markers.js " markers_ $TAR_VERSION .js "
mv planeObject.js " planeObject_ $TAR_VERSION .js "
mv registrations.js " registrations_ $TAR_VERSION .js "
mv script.js " script_ $TAR_VERSION .js "
mv style.css " style_ $TAR_VERSION .css "
2020-01-03 21:16:40 +01:00
2020-01-31 02:47:01 +01:00
if [ [ $nginx = = yes ] ] ; then
2020-07-30 10:15:58 +08:00
gzip -k -9 " dbloader_ $TAR_VERSION .js "
gzip -k -9 " defaults_ $TAR_VERSION .js "
gzip -k -9 " early_ $TAR_VERSION .js "
gzip -k -9 " flags_ $TAR_VERSION .js "
gzip -k -9 " formatter_ $TAR_VERSION .js "
gzip -k -9 " layers_ $TAR_VERSION .js "
gzip -k -9 " markers_ $TAR_VERSION .js "
gzip -k -9 " planeObject_ $TAR_VERSION .js "
gzip -k -9 " registrations_ $TAR_VERSION .js "
gzip -k -9 " script_ $TAR_VERSION .js "
gzip -k -9 " style_ $TAR_VERSION .css "
2020-11-13 16:34:48 +01:00
gzip -k -9 ./libs/*.js
2020-01-31 02:47:01 +01:00
#gzip -k -9 db2/*.json .... already exists compressed
fi
2020-03-23 00:28:21 +01:00
2020-10-21 12:32:09 +02:00
rm -rf " $html_path "
2020-07-30 10:15:58 +08:00
mv " $TMP " " $html_path "
2020-01-31 02:47:01 +01:00
2020-03-23 00:29:07 +01:00
cd " $dir "
2020-01-03 21:16:40 +01:00
2020-07-30 10:15:58 +08:00
cp nginx.conf " $ipath /nginx- $service .conf "
2020-01-03 21:16:40 +01:00
2020-12-31 22:11:18 +01:00
if [ [ $lighttpd = = yes ] ] ; then
2020-12-11 16:06:03 +01:00
if [ [ " $otherport " != "done" ] ] ; then
2020-03-16 15:08:21 +01:00
cp 95-tar1090-otherport.conf /etc/lighttpd/conf-available/
ln -f -s /etc/lighttpd/conf-available/95-tar1090-otherport.conf /etc/lighttpd/conf-enabled/95-tar1090-otherport.conf
otherport = "done"
2020-05-08 08:49:13 +02:00
if [ -f /etc/lighttpd/conf.d/69-skybup.conf ] ; then
mv /etc/lighttpd/conf-enabled/95-tar1090-otherport.conf /etc/lighttpd/conf-enabled/68-tar1090-otherport.conf
fi
2020-03-16 15:08:21 +01:00
fi
2020-01-19 12:38:39 +01:00
if [ -f /etc/lighttpd/conf.d/69-skybup.conf ] && [ [ " $instance " = = "webroot" ] ] ; then
true
elif [ [ " $instance " = = "webroot" ] ]
then
cp 88-tar1090.conf /etc/lighttpd/conf-available/99-$service .conf
ln -f -s /etc/lighttpd/conf-available/99-$service .conf /etc/lighttpd/conf-enabled/99-$service .conf
2020-01-03 21:16:40 +01:00
else
2020-01-19 12:38:39 +01:00
cp 88-tar1090.conf /etc/lighttpd/conf-available/88-$service .conf
2020-05-08 08:49:13 +02:00
ln -f -s /etc/lighttpd/conf-available/88-$service .conf /etc/lighttpd/conf-enabled/88-$service .conf
2020-01-19 12:38:39 +01:00
if [ -f /etc/lighttpd/conf.d/69-skybup.conf ] ; then
2020-05-08 08:49:13 +02:00
mv /etc/lighttpd/conf-enabled/88-$service .conf /etc/lighttpd/conf-enabled/66-$service .conf
2020-01-19 12:38:39 +01:00
fi
2020-01-03 21:16:40 +01:00
fi
2020-03-23 00:29:07 +01:00
fi
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
if [ [ $changed = = yes ] ] || ! diff tar1090.service /lib/systemd/system/$service .service & >/dev/null
then
cp tar1090.service /lib/systemd/system/$service .service
if systemctl enable $service
2020-01-14 17:18:45 +01:00
then
echo " Restarting $service ... "
systemctl restart $service
else
echo " $service .service is masked, could not start it! "
fi
2020-03-23 00:29:07 +01:00
fi
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
# restore sed modified configuration files
mv 88-tar1090.conf.orig 88-tar1090.conf
2020-03-16 15:08:21 +01:00
mv 95-tar1090-otherport.conf.orig 95-tar1090-otherport.conf
2020-03-23 00:29:07 +01:00
mv nginx.conf.orig nginx.conf
mv tar1090.service.orig tar1090.service
2020-01-03 21:16:40 +01:00
done < <( echo " $instances " )
2020-12-31 22:11:18 +01:00
if [ [ $lighttpd = = yes ] ] ; then
2021-03-12 00:55:17 +01:00
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>& 1 | grep -i duplicate >/dev/null; then
mv -f /etc/lighttpd/conf-available/89-dump1090-fa.conf.dpkg-dist /etc/lighttpd/conf-available/89-dump1090-fa.conf & >/dev/null || true
fi
2021-01-12 21:53:08 +01:00
if ! grep -qs -E -e '^[^#]*"mod_alias"' /etc/lighttpd/lighttpd.conf /etc/lighttp/conf-enabled/* /etc/lighttpd/external.conf; then
echo 'server.modules += ( "mod_alias" )' > /etc/lighttpd/conf-available/07-mod_alias.conf
ln -s -f /etc/lighttpd/conf-available/07-mod_alias.conf /etc/lighttpd/conf-enabled/07-mod_alias.conf
else
rm -f /etc/lighttpd/conf-enabled/07-mod_alias.conf
fi
2020-12-29 20:43:54 +01:00
rm -f /etc/lighttpd/conf-available/87-mod_setenv.conf /etc/lighttpd/conf-enabled/87-mod_setenv.conf
2020-03-23 00:29:07 +01:00
while read -r FILE; do
sed -i -e 's/^server.modules.*mod_setenv.*/#\0/' " $FILE "
sed -i -e 's/^server.stat-cache-engine.*disable.*/#\0/' " $FILE "
2020-12-29 20:37:14 +01:00
done < <( find /etc/lighttpd/conf-available/* | grep -v setenv)
2020-01-03 21:16:40 +01:00
# add mod_setenv to lighttpd modules, check if it's one too much
2020-12-29 20:43:54 +01:00
echo 'server.modules += ( "mod_setenv" )' > /etc/lighttpd/conf-available/07-mod_setenv.conf
2020-03-11 17:30:34 +01:00
echo 'server.stat-cache-engine = "disable"' > /etc/lighttpd/conf-available/47-stat-cache.conf
2020-12-29 20:43:54 +01:00
ln -s -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
2020-03-11 17:30:34 +01:00
ln -s -f /etc/lighttpd/conf-available/47-stat-cache.conf /etc/lighttpd/conf-enabled/47-stat-cache.conf
2020-11-13 20:42:28 +01:00
2020-11-22 15:18:25 +01:00
if ( ( $( cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.stat-cache-engine *\= *"disable")' ) > 1 ) ) ; then
rm -f /etc/lighttpd/conf-enabled/47-stat-cache.conf
2020-03-11 17:30:34 +01:00
fi
2020-11-16 12:56:34 +01:00
if ( ( $( cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.modules.?\+=.?\(.?"mod_setenv".?\)' ) > 1 ) ) ; then
2020-12-29 20:43:54 +01:00
rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
2020-11-13 20:42:28 +01:00
fi
2020-03-11 17:30:34 +01:00
2020-11-22 15:18:25 +01:00
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>& 1 | grep mod_setenv >/dev/null; then
2020-12-29 20:43:54 +01:00
rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
2020-11-22 15:18:25 +01:00
fi
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>& 1 | grep stat-cache >/dev/null; then
2020-11-12 13:36:38 +01:00
rm -f /etc/lighttpd/conf-enabled/47-stat-cache.conf
2020-01-03 21:16:40 +01:00
fi
2020-03-12 14:30:31 +01:00
2020-05-08 08:49:13 +02:00
#lighttpd -tt -f /etc/lighttpd/lighttpd.conf && echo success || true
2020-03-12 14:30:31 +01:00
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>& 1 | grep mod_setenv >/dev/null
then
2020-12-29 20:43:54 +01:00
rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
2020-03-12 14:30:31 +01:00
fi
2020-05-08 08:49:13 +02:00
#lighttpd -tt -f /etc/lighttpd/lighttpd.conf && echo success || true
2020-05-08 09:06:07 +02:00
if ! lighttpd -tt -f /etc/lighttpd/lighttpd.conf & >/dev/null; then
echo ----------------
echo "Lighttpd error, tar1090 will probably not work correctly:"
lighttpd -tt -f /etc/lighttpd/lighttpd.conf
2020-11-01 21:05:59 +01:00
fi
2020-11-22 15:18:25 +01:00
if grep -qs -e '^compress.cache-dir' /etc/lighttpd/lighttpd.conf; then
2020-11-01 21:05:59 +01:00
echo -----
2020-11-22 15:18:25 +01:00
echo "Disabling compress.cache-dir in /etc/lighttpd/lighttpd.conf due to often causing full disk issues as there is no automatic cleanup mechanism. Add a leading space to the compress.cache-dir line if you don't want tar1090 to mess with it in the future."
2020-11-01 21:05:59 +01:00
echo -----
2020-11-22 15:18:25 +01:00
sed -i -e 's$^compress.cache-dir.*$#\0 # disabled by tar1090, often causes full disk due to not having a cleanup mechanism$' /etc/lighttpd/lighttpd.conf
elif ! grep -qs -e 'disabled by tar1090' /etc/lighttpd/lighttpd.conf; then
2020-11-01 21:05:59 +01:00
sed -i -e 's$^compress.cache-dir.*$# CAUTION, enabling cache-dir and filetype json will cause full disk when using tar1090\n\0$' /etc/lighttpd/lighttpd.conf
2020-05-08 09:06:07 +02:00
fi
2020-01-03 21:16:40 +01:00
fi
2020-12-29 20:53:46 +01:00
if systemctl show lighttpd 2>/dev/null | grep -qs -F -e 'UnitFileState=enabled' -e 'ActiveState=active' ; then
2020-03-23 00:29:07 +01:00
echo "Restarting lighttpd ..."
systemctl restart lighttpd
2020-01-03 21:16:40 +01:00
fi
echo --------------
if [ [ $nginx = = yes ] ] ; then
2020-03-23 00:29:07 +01:00
echo
echo "To configure nginx for tar1090, please add the following line(s) in the server {} section:"
echo
for service in $services ; do
echo " include /usr/local/share/tar1090/nginx- $service .conf; "
done
2020-01-03 21:16:40 +01:00
fi
echo --------------
if [ [ $lighttpd = = yes ] ] ; then
2020-03-23 00:29:07 +01:00
for name in $names ; do
echo " All done! Webinterface available at http:// $( ip route get 1.2.3.4 | grep -m1 -o -P 'src \K[0-9,.]*' ) / $name "
done
2020-01-03 21:16:40 +01:00
elif [ [ $nginx = = yes ] ] ; then
2020-03-23 00:29:07 +01:00
for name in $names ; do
echo " All done! Webinterface once nginx is configured will be available at http:// $( ip route get 1.2.3.4 | grep -m1 -o -P 'src \K[0-9,.]*' ) / $name "
done
2020-01-03 21:16:40 +01:00
else
2020-03-23 00:29:07 +01:00
echo "All done! You'll need to configure your webserver yourself, see /usr/local/share/tar1090/nginx-tar1090.conf for a reference nginx configuration"
2020-01-03 21:16:40 +01:00
fi