forked from dstreufert/adsbx-webconfig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·74 lines (59 loc) · 2.15 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
if [ $(id -u) -ne 0 ]; then
echo -e "This script must be run as root. \n"
exit 1
fi
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
function aptInstall() {
if ! apt install -y --no-install-recommends --no-install-suggests "$@"; then
apt update
apt install -y --no-install-recommends --no-install-suggests "$@"
fi
}
if ! [[ -f /boot/adsb-version ]]; then
echo 8.0123456789 > /boot/adsb-version
fi
aptInstall whois php php-common php-fpm php-cgi dnsmasq
command -v rsyslogd &>/dev/null && apt remove -y rsyslog || true
lighttpd-enable-mod fastcgi-php 2>&1 | grep -F -v -e 'force-reload'
systemctl restart lighttpd
systemctl disable dnsmasq &>/dev/null
systemctl stop dnsmasq || true
for dir in /etc/php/*; do
echo -e "; Put session info here, to prevent SD card writes\nsession.save_path = \"/tmp\"" > "$dir/cgi/conf.d/30-session_path.ini" || true
done
ipath=/adsb/webconfig
mkdir -p $ipath
cp adsb-config.txt.webtemplate webconfig.sh leds.sh sanitize-uuid.sh $ipath
cp ./webconfig.service /etc/systemd/system/
cp ./leds.service /etc/systemd/system/
rm -f /var/www/html/index.htm*
cp -r ./html/* /var/www/html
cp ./dnsmasq.conf /etc/
rm -rf $ipath/helpers
cp -r -T ./helpers $ipath/helpers
chmod a+x $ipath/helpers/*.sh
cp ./010_www-data /etc/sudoers.d/
for file in helpers/*.sh; do
echo "www-data ALL = NOPASSWD: /adsb/webconfig/$file" >> /etc/sudoers.d/010_www-data
done
rm -rf /adsb/update
mkdir -p /adsb
git clone --depth 1 https://github.com/ADSB-One/adsb-update.git /adsb/update
pushd /adsb/update/
# always copy over this file
cp -v -T boot-configs/wpa_supplicant.conf /boot/wpa_supplicant.conf.bak
if [[ "$1" != "dont_reset_config" ]]; then
cp -v -T boot-configs/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf
cp -v boot-configs/* /boot
echo -e "\n UNLOCKING UNIT UNTIL FIRST CONFIG"
touch /boot/unlock
fi
popd
# We do not use hostapd. Setup network is open.
systemctl disable hostapd &>/dev/null || true
systemctl enable webconfig
systemctl enable leds
systemctl restart webconfig
systemctl restart leds || true