Skip to content

Commit

Permalink
make shellcheck happy
Browse files Browse the repository at this point in the history
correct slight bug from last commit
  • Loading branch information
wiedehopf committed Apr 21, 2023
1 parent 037bdfa commit 15a1e42
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion default
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ HISTORY_SIZE=450
# Change to yes to enable UAT/978 display in tar1090
ENABLE_978=no
# If running dump978-fa on another computer, modify the IP-address as appropriate.
# The URL needs to point at where you would normally find the skyview978 webinterface
# The URL needs to point at where you would normally find the skyaware978 webinterface
URL_978="http://127.0.0.1/skyaware978"

# 1-9 are valid, lower lvl: less CPU usage, higher level: less network bandwidth used when loading the page
Expand Down
66 changes: 34 additions & 32 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# shellcheck shell=bash disable=SC2016


set -e
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
Expand All @@ -19,13 +21,12 @@ if [[ -n "$3" ]]; then ipath="$3"; fi
lighttpd=no
nginx=no
function useSystemd () { command -v systemd &>/dev/null; }
function useSystemd () { return 1; }

mkdir -p $ipath
mkdir -p "$ipath"

if useSystemd && ! id -u tar1090 &>/dev/null
then
adduser --system --home $ipath --no-create-home --quiet tar1090 || adduser --system --home-dir $ipath --no-create-home tar1090
adduser --system --home "$ipath" --no-create-home --quiet tar1090 || adduser --system --home-dir "$ipath" --no-create-home tar1090
fi

# terminate with /
Expand Down Expand Up @@ -107,7 +108,7 @@ if ! { [[ "$1" == "test" ]] && cd "$ipath/git-db"; }; then
getGIT "$db_repo" "master" "$ipath/git-db" || true
fi

if ! cd $ipath/git-db
if ! cd "$ipath/git-db"
then
echo "Unable to download files, exiting! (Maybe try again?)"
exit 1
Expand Down Expand Up @@ -190,16 +191,18 @@ if ! diff tar1090.sh "$ipath"/tar1090.sh &>/dev/null; then
else
service="tar1090"
fi
useSystemd && systemctl stop $service 2>/dev/null || true
if useSystemd; then
systemctl stop "$service" 2>/dev/null || true
fi
done < <(echo "$instances")
cp tar1090.sh $ipath
cp tar1090.sh "$ipath"
fi


# copy over base files
cp install.sh uninstall.sh getupintheair.sh LICENSE README.md $ipath
cp default $ipath/example_config_dont_edit
rm -f $ipath/default
cp install.sh uninstall.sh getupintheair.sh LICENSE README.md "$ipath"
cp default "$ipath/example_config_dont_edit"
rm -f "$ipath/default"

# create 95-tar1090-otherport.conf
{
Expand Down Expand Up @@ -230,26 +233,25 @@ do
html_path="$ipath/html"
service="tar1090"
fi
services+="$service "
services+=("$service")
names+="$instance "

# don't overwrite existing configuration
cp -n default /etc/default/$service
sed -i -e 's/skyview978/skyaware978/' /etc/default/$service
useSystemd && cp -n default /etc/default/"$service"

sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?$service?g" \
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

if [[ "$instance" == "webroot" ]]; then
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?$service?g" \
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?${service}?g" \
-e "s?/INSTANCE??g" -e "s?HTMLPATH?$html_path?g" 88-tar1090.conf
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?$service?g" \
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?${service}?g" \
-e "s?/INSTANCE/?/?g" -e "s?HTMLPATH?$html_path?g" nginx.conf
sed -i -e "s?/INSTANCE?/?g" nginx.conf
else
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?$service?g" \
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?${service}?g" \
-e "s?INSTANCE?$instance?g" -e "s?HTMLPATH?$html_path?g" 88-tar1090.conf
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?$service?g" \
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?${service}?g" \
-e "s?INSTANCE?$instance?g" -e "s?HTMLPATH?$html_path?g" nginx.conf
fi

Expand All @@ -263,7 +265,7 @@ do
fi


sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?$service?g" tar1090.service
sed -i.orig -e "s?SOURCE_DIR?$srcdir?g" -e "s?SERVICE?${service}?g" tar1090.service

cp -r -T html "$TMP"
cp -r -T "$ipath/git-db/db" "$TMP/db-$DB_VERSION"
Expand Down Expand Up @@ -305,7 +307,7 @@ do

cd "$dir"

cp nginx.conf "$ipath/nginx-$service.conf"
cp nginx.conf "$ipath/nginx-${service}.conf"

if [[ $lighttpd == yes ]]; then
# clean up broken symlinks in conf-enabled ...
Expand All @@ -322,27 +324,27 @@ do
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
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
else
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
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
if [ -f /etc/lighttpd/conf.d/69-skybup.conf ]; then
mv /etc/lighttpd/conf-enabled/88-$service.conf /etc/lighttpd/conf-enabled/66-$service.conf
mv /etc/lighttpd/conf-enabled/88-"${service}".conf /etc/lighttpd/conf-enabled/66-"${service}".conf
fi
fi
fi

if useSystemd; then
if [[ $changed == yes ]] || ! diff tar1090.service /lib/systemd/system/$service.service &>/dev/null
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
cp tar1090.service /lib/systemd/system/"${service}".service
if systemctl enable "${service}"
then
echo "Restarting $service ..."
systemctl restart $service || ! pgrep systemd
echo "Restarting ${service} ..."
systemctl restart "$service" || ! pgrep systemd
else
echo "$service.service is masked, could not start it!"
echo "${service}.service is masked, could not start it!"
fi
fi
fi
Expand Down Expand Up @@ -436,8 +438,8 @@ if [[ $nginx == yes ]]; then
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 ${ipath}/nginx-$service.conf;"
for service in "${services[@]}"; do
echo "include ${ipath}/nginx-${service}.conf;"
done
fi

Expand Down

0 comments on commit 15a1e42

Please sign in to comment.