2020-01-03 21:16:40 +01:00
#!/bin/bash
2023-04-21 10:10:59 +02:00
# shellcheck shell=bash disable=SC2016
2024-04-08 10:33:56 +02:00
umask 022
2023-04-21 10:10:59 +02:00
2021-03-20 18:38:22 +01:00
2020-01-03 21:16:40 +01:00
set -e
2021-03-20 18:38:22 +01:00
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
renice 10 $$
2020-01-03 21:16:40 +01:00
2023-04-21 07:47:00 +02:00
srcdir = /run/readsb
2020-01-03 21:16:40 +01:00
repo = "https://github.com/wiedehopf/tar1090"
db_repo = "https://github.com/wiedehopf/tar1090-db"
2023-04-21 07:47:00 +02:00
# optional command line options for this install script
# $1: data source directory
# $2: web path, default is "tar1090", use "webroot" to place the install at /
# $3: specify install path
2023-06-18 06:43:19 +02:00
# $4: specify git path as source instead of pulling from git
2023-04-21 07:47:00 +02:00
2020-01-03 21:16:40 +01:00
ipath = /usr/local/share/tar1090
2023-04-21 07:47:00 +02:00
if [ [ -n " $3 " ] ] ; then ipath = " $3 " ; fi
2023-06-18 06:43:19 +02:00
if [ [ -n " $4 " ] ] && grep -qs -e 'tar1090' " $4 /install.sh " ; then git_source = " $4 " ; fi
2020-01-03 21:16:40 +01:00
lighttpd = no
nginx = no
2024-10-06 20:35:57 +02:00
function useSystemd ( ) { command -v systemctl & >/dev/null; }
2020-01-03 21:16:40 +01:00
2024-04-11 22:01:36 +02:00
gpath = " $TAR1090_UPDATE_DIR "
if [ [ -z " $gpath " ] ] ; then gpath = " $ipath " ; fi
2023-04-21 10:10:59 +02:00
mkdir -p " $ipath "
2024-04-11 22:01:36 +02:00
mkdir -p " $gpath "
2020-01-03 21:16:40 +01:00
2023-04-21 07:47:00 +02:00
if useSystemd && ! id -u tar1090 & >/dev/null
2020-01-03 21:16:40 +01:00
then
2023-04-21 10:10:59 +02: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 /
2024-07-13 18:32:51 +02:00
command_package = "git git/jq jq/curl curl"
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 [*] } "
2022-01-29 23:44:14 +01:00
if ! apt-get install -y --no-install-suggests --no-install-recommends " ${ packages [@] } " ; then
apt-get update || true
apt-get install -y --no-install-suggests --no-install-recommends " ${ packages [@] } " || true
fi
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 )
2024-04-11 22:01:36 +02:00
if ( ( $( { du -s " $gpath /git-db " 2>/dev/null || echo 0; } | cut -f1) > 150000 ) ) ; then
rm -rf " $gpath /git-db "
2020-10-21 12:32:09 +02:00
fi
2024-02-07 17:17:17 +01:00
function copyNoClobber( ) {
if ! [ [ -f " $2 " ] ] ; then
cp " $1 " " $2 "
fi
}
2021-03-22 12:47:16 +01:00
function getGIT( ) {
2021-09-07 08:16:16 +02:00
# getGIT $REPO $BRANCH $TARGET (directory)
if [ [ -z " $1 " ] ] || [ [ -z " $2 " ] ] || [ [ -z " $3 " ] ] ; then echo "getGIT wrong usage, check your script or tell the author!" 1>& 2; return 1; fi
2022-07-13 03:12:51 +02:00
REPO = " $1 " ; BRANCH = " $2 " ; TARGET = " $3 " ; pushd . >/dev/null
if cd " $TARGET " & >/dev/null && git fetch --depth 1 origin " $BRANCH " 2>/dev/null && git reset --hard FETCH_HEAD; then popd >/dev/null && return 0; fi
if ! cd /tmp || ! rm -rf " $TARGET " ; then popd > /dev/null; return 1; fi
if git clone --depth 1 --single-branch --branch " $BRANCH " " $REPO " " $TARGET " ; then popd > /dev/null; return 0; fi
2022-08-04 19:43:09 +02:00
rm -rf " $TARGET " ; tmp = /tmp/getGIT-tmp-tar1090
2022-07-13 03:12:51 +02:00
if wget -O " $tmp " " $REPO /archive/refs/heads/ $BRANCH .zip " && unzip " $tmp " -d " $tmp .folder " >/dev/null; then
if mv -fT " $tmp .folder/ $( ls " $tmp .folder " ) " " $TARGET " ; then rm -rf " $tmp " " $tmp .folder " ; popd > /dev/null; return 0; fi
fi
rm -rf " $tmp " " $tmp .folder " ; popd > /dev/null; return 1;
}
function revision( ) {
git rev-parse --short HEAD 2>/dev/null || echo " $RANDOM - $RANDOM "
2021-03-22 12:47:16 +01:00
}
2024-04-11 22:01:36 +02:00
if ! { [ [ " $1 " = = "test" ] ] && cd " $gpath /git-db " ; } ; then
2024-04-14 04:15:56 +02:00
DB_VERSION_NEW = $( curl --silent --show-error "https://raw.githubusercontent.com/wiedehopf/tar1090-db/master/version" )
2024-04-25 16:18:20 +02:00
if [ [ " $( cat " $gpath /git-db/version " 2>/dev/null) " != " $DB_VERSION_NEW " ] ] ; then
2024-04-14 04:15:56 +02:00
getGIT " $db_repo " "master" " $gpath /git-db " || true
fi
2021-03-22 12:47:16 +01:00
fi
2020-08-05 13:26:36 +02:00
2024-04-11 22:01:36 +02:00
if ! cd " $gpath /git-db "
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
2022-07-13 03:12:51 +02:00
DB_VERSION = $( revision)
2020-02-23 17:07:36 +01:00
2020-01-03 21:16:40 +01:00
cd " $dir "
2023-06-18 06:43:19 +02:00
if [ [ " $1 " = = "test" ] ] || [ [ -n " $git_source " ] ] ; then
2024-04-11 22:01:36 +02:00
mkdir -p " $gpath /git "
rm -rf " $gpath /git " /* || true
2023-06-18 06:43:19 +02:00
if [ [ -n " $git_source " ] ] ; then
2024-04-11 22:01:36 +02:00
cp -r " $git_source " /* " $gpath /git "
2023-06-18 06:43:19 +02:00
else
2024-04-11 22:01:36 +02:00
cp -r ./* " $gpath /git "
2023-06-18 06:43:19 +02:00
fi
2024-04-11 22:01:36 +02:00
cd " $gpath /git "
2024-05-18 18:06:56 +02:00
TAR_VERSION = " $( cat version) _dirty "
2020-08-05 13:26:36 +02:00
else
2024-04-14 04:15:56 +02:00
VERSION_NEW = $( curl --silent --show-error "https://raw.githubusercontent.com/wiedehopf/tar1090/master/version" )
2024-04-25 16:18:20 +02:00
if [ [ " $( cat " $gpath /git/version " 2>/dev/null) " != " $VERSION_NEW " ] ] ; then
2024-04-14 04:15:56 +02:00
if ! getGIT " $repo " "master" " $gpath /git " ; then
echo "Unable to download files, exiting! (Maybe try again?)"
exit 1
fi
fi
if ! cd " $gpath /git " ; then
2020-08-05 23:27:28 +02:00
echo "Unable to download files, exiting! (Maybe try again?)"
exit 1
fi
2024-05-18 18:37:38 +02:00
TAR_VERSION = " $( cat version) "
2020-03-08 13:22:18 +01:00
fi
2021-03-15 08:10:05 +01:00
if [ [ -n $1 ] ] && [ " $1 " != "test" ] ; then
2020-03-23 00:29:07 +01:00
srcdir = $1
2021-03-15 08:10:05 +01:00
elif [ -f /etc/default/tar1090_instances ] ; then
true
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
2024-02-07 17:20:29 +01:00
elif [ [ -f /run/shm/aircraft.json ] ] ; then
srcdir = /run/shm
2020-05-06 08:04:20 +02:00
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 --------------
2021-11-19 22:34:48 +01:00
echo "You need to have a decoder installed first, readsb is recommended:"
echo "https://github.com/wiedehopf/adsb-scripts/wiki/Automatic-installation-for-readsb"
echo --------------
2020-05-06 08:04:20 +02:00
exit 1
2020-01-03 21:16:40 +01:00
fi
2021-03-15 08:10:05 +01:00
if [ [ -n $2 ] ] ; then
instances = " $srcdir $2 "
elif [ [ -n $1 ] ] && [ " $1 " != "test" ] ; then
2023-04-21 07:47:00 +02:00
instances = " $1 tar1090 "
2021-03-15 08:10:05 +01:00
elif [ -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
2021-04-16 19:32:34 +02:00
if [ [ -d /usr/local/share/adsbexchange-978 ] ] ; then
instances += "\n /run/adsbexchange-978 ax978"
fi
instances = $( echo -e " $instances " | grep -v -e '^#' )
2021-03-17 19:57:00 +01:00
2023-04-21 07:47:00 +02:00
if ! diff tar1090.sh " $ipath " /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
2023-04-21 10:10:59 +02:00
if useSystemd; then
systemctl stop " $service " 2>/dev/null || true
fi
2020-03-23 00:29:07 +01:00
done < <( echo " $instances " )
2024-11-10 16:09:16 +01:00
rm -f " $ipath " /tar1090.sh
2023-04-21 10:10:59 +02:00
cp tar1090.sh " $ipath "
2020-01-03 21:16:40 +01:00
fi
# copy over base files
2023-04-21 10:10:59 +02:00
cp install.sh uninstall.sh getupintheair.sh LICENSE README.md " $ipath "
cp default " $ipath /example_config_dont_edit "
2023-04-22 09:06:18 +02:00
cp html/config.js " $ipath /example_config.js "
2023-04-21 10:10:59 +02:00
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
2023-04-26 14:39:55 +02:00
services = ( )
2020-01-03 21:16:40 +01:00
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
2022-08-04 19:43:09 +02:00
TMP = " $ipath /.instance_tmp "
rm -rf " $TMP "
mkdir -p " $TMP "
2020-07-30 10:15:58 +08:00
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
2023-04-21 10:10:59 +02:00
services += ( " $service " )
2020-03-23 00:29:07 +01:00
names += " $instance "
2020-01-03 21:16:40 +01:00
2020-03-23 00:29:07 +01:00
# don't overwrite existing configuration
2024-02-07 17:17:17 +01:00
useSystemd && copyNoClobber default /etc/default/" $service "
2020-01-03 21:16:40 +01:00
2023-04-21 10:10:59 +02:00
sed -i.orig -e " s?SOURCE_DIR? $srcdir ?g " -e " s?SERVICE? ${ service } ?g " \
2020-03-16 15:08:21 +01:00
-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
2023-04-21 10:10:59 +02: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
2023-04-21 10:10:59 +02: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
2023-04-21 10:10:59 +02: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
2023-04-21 10:10:59 +02: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
2021-03-22 10:34:34 +01:00
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
2021-03-22 10:34:34 +01:00
sed -i -e 's/compress.filetype/deflate.mimetypes/' 88-tar1090.conf
sed -i -e 's/compress.filetype/deflate.mimetypes/' 95-tar1090-otherport.conf
if ! grep -qs -e '^[^#]*"mod_deflate"' /etc/lighttpd/lighttpd.conf /etc/lighttpd/conf-enabled/*; then
sed -i -e 's/^[^#]*deflate.mimetypes/#\0/' 88-tar1090.conf
sed -i -e 's/^[^#]*deflate.mimetypes/#\0/' 95-tar1090-otherport.conf
fi
2020-11-13 22:18:38 +01:00
fi
2020-01-19 12:38:39 +01:00
2023-04-21 10:10:59 +02: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 "
2024-04-11 22:01:36 +02:00
cp -r -T " $gpath /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
2022-04-16 06:39:18 +02:00
# in case we have offlinemaps installed, modify config.js
MAX_OFFLINE = ""
2025-10-06 14:15:30 +00:00
MAX_OFFLINE_OFM = ""
2022-04-16 06:39:18 +02:00
for i in { 0..15} ; do
2025-10-06 14:15:30 +00:00
if [ [ -d /usr/local/share/openfreemap_offline/mnt/tiles/$i ] ] ; then
MAX_OFFLINE_OFM = $i
fi
2022-04-16 06:39:18 +02:00
if [ [ -d /usr/local/share/osm_tiles_offline/$i ] ] ; then
MAX_OFFLINE = $i
fi
done
if [ [ -n " $MAX_OFFLINE " ] ] ; then
2025-10-06 14:15:30 +00:00
if ! grep " $TMP /config.js " -E -e '^offlineMapDetail\s*=.*' -qs; then
2022-04-16 06:39:18 +02:00
echo " offlineMapDetail= $MAX_OFFLINE ; " >> " $TMP /config.js "
else
2025-10-06 14:15:30 +00:00
sed -i -e " s/^offlineMapDetail\s*=.*/offlineMapDetail= $MAX_OFFLINE ;/ " " $TMP /config.js "
fi
fi
if [ [ -n " $MAX_OFFLINE_OFM " ] ] ; then
if ! grep " $TMP /config.js " -E -e '^offlineMapDetailOFM\s*=.*' -qs; then
echo " offlineMapDetailOFM= $MAX_OFFLINE_OFM ; " >> " $TMP /config.js "
else
sed -i -e " s/^offlineMapDetailOFM\s=.*/offlineMapDetailOFM= $MAX_OFFLINE_OFM ;/ " " $TMP /config.js "
2022-04-16 06:39:18 +02:00
fi
fi
2021-05-04 15:24:31 +02:00
cp " $ipath /customIcon.png " " $TMP /images/tar1090-favicon.png " & >/dev/null || true
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
2025-09-28 02:16:13 +00:00
sed -i -e 's/id="webinterface_version">/\0' " ( ${ TAR_VERSION } )/ " index.html
2020-01-03 21:16:40 +01:00
2024-04-11 22:01:36 +02:00
" $gpath /git/cachebust.sh " " $gpath /git/cachebust.list " " $TMP "
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
2023-04-21 10:10:59 +02: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
2021-09-19 15:43:08 +02:00
# clean up broken symlinks in conf-enabled ...
2022-01-21 14:08:52 +01:00
for link in /etc/lighttpd/conf-enabled/*; do [ [ -e " $link " ] ] || rm -f " $link " ; done
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
2023-04-21 10:10:59 +02:00
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
2023-04-21 10:10:59 +02:00
cp 88-tar1090.conf /etc/lighttpd/conf-available/88-" ${ service } " .conf
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
2023-04-21 10:10:59 +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
2023-04-21 07:47:00 +02:00
if useSystemd; then
2023-04-21 10:10:59 +02:00
if [ [ $changed = = yes ] ] || ! diff tar1090.service /lib/systemd/system/" ${ service } " .service & >/dev/null
2020-01-14 17:18:45 +01:00
then
2023-04-21 10:10:59 +02:00
cp tar1090.service /lib/systemd/system/" ${ service } " .service
if systemctl enable " ${ service } "
2023-04-21 07:47:00 +02:00
then
2023-04-21 10:10:59 +02:00
echo " Restarting ${ service } ... "
systemctl restart " $service " || ! pgrep systemd
2023-04-21 07:47:00 +02:00
else
2023-04-21 10:10:59 +02:00
echo " ${ service } .service is masked, could not start it! "
2023-04-21 07:47:00 +02:00
fi
2020-01-14 17:18:45 +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
# 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
2021-03-22 10:34:34 +01:00
if grep -qs -e '^deflate.cache-dir' /etc/lighttpd/lighttpd.conf; then
echo -----
echo "Disabling deflate.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 deflate.cache-dir line if you don't want tar1090 to mess with it in the future."
echo -----
sed -i -e 's$^deflate.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
sed -i -e 's$^deflate.cache-dir.*$# CAUTION, enabling cache-dir and filetype json will cause full disk when using tar1090\n\0$' /etc/lighttpd/lighttpd.conf
fi
2020-01-03 21:16:40 +01:00
fi
2023-04-21 07:47:00 +02:00
if useSystemd && 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 ..."
2022-01-26 14:59:40 +01:00
systemctl restart lighttpd || ! pgrep systemd
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
2023-04-21 10:10:59 +02:00
for service in " ${ services [@] } " ; do
echo " include ${ ipath } /nginx- ${ service } .conf; "
2020-03-23 00:29:07 +01:00
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
2023-04-21 07:47:00 +02:00
echo " All done! You'll need to configure your webserver yourself, see ${ ipath } /nginx-tar1090.conf for a reference nginx configuration "
2020-01-03 21:16:40 +01:00
fi