2023-09-13 08:09:25 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Copyright (c) 2021-2023 tteck
|
|
|
|
# Author: tteck (tteckster)
|
|
|
|
# License: MIT
|
|
|
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
|
|
|
|
|
|
|
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
|
|
|
color
|
|
|
|
verb_ip6
|
|
|
|
catch_errors
|
|
|
|
setting_up_container
|
|
|
|
network_check
|
|
|
|
update_os
|
|
|
|
|
|
|
|
msg_info "Installing Dependencies"
|
|
|
|
$STD apt-get -y install \
|
|
|
|
sudo \
|
|
|
|
mc \
|
|
|
|
curl \
|
2023-09-16 13:54:54 -04:00
|
|
|
git \
|
2023-09-13 08:09:25 -04:00
|
|
|
apt-utils \
|
|
|
|
lighttpd \
|
|
|
|
sqlite3 \
|
|
|
|
mmdb-bin \
|
|
|
|
arp-scan \
|
|
|
|
dnsutils \
|
|
|
|
net-tools \
|
|
|
|
libwww-perl \
|
|
|
|
nmap \
|
|
|
|
zip \
|
|
|
|
wakeonlan
|
|
|
|
msg_ok "Installed Dependencies"
|
|
|
|
|
|
|
|
msg_info "Installing PHP Dependencies"
|
|
|
|
$STD apt-get -y install \
|
|
|
|
php \
|
|
|
|
php-cgi \
|
|
|
|
php-fpm \
|
|
|
|
php-curl \
|
|
|
|
php-sqlite3
|
|
|
|
$STD lighttpd-enable-mod fastcgi-php
|
|
|
|
service lighttpd force-reload
|
|
|
|
msg_ok "Installed PHP Dependencies"
|
|
|
|
#arp-scan -l
|
|
|
|
|
|
|
|
msg_info "Installing Python Dependencies"
|
|
|
|
$STD apt-get -y install \
|
|
|
|
python3-pip \
|
|
|
|
python3-requests
|
|
|
|
$STD pip3 install mac-vendor-lookup
|
|
|
|
$STD pip3 install fritzconnection
|
|
|
|
$STD pip3 install cryptography
|
|
|
|
msg_ok "Installed Python Dependencies"
|
|
|
|
|
2023-09-17 22:33:28 -04:00
|
|
|
msg_info "Installing Pi.Alert"
|
|
|
|
curl -sL https://github.com/leiweibau/Pi.Alert/raw/main/tar/pialert_latest.tar | tar xvf - -C /opt >/dev/null 2>&1
|
2023-09-16 11:42:03 -04:00
|
|
|
mkdir -p /opt/pialert/front/reports
|
2023-09-16 22:53:33 -04:00
|
|
|
rm -rf /var/www/html/index.html
|
2023-09-13 08:09:25 -04:00
|
|
|
mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old
|
|
|
|
ln -s /opt/pialert/install/index.html /var/www/html/index.html
|
|
|
|
ln -s /opt/pialert/front /var/www/html/pialert
|
2023-09-16 11:42:03 -04:00
|
|
|
chmod go+x /opt/pialert /opt/pialert/back/shoutrrr/x86/shoutrrr
|
|
|
|
chgrp -R www-data /opt/pialert/db /opt/pialert/front/reports /opt/pialert/config /opt/pialert/config/pialert.conf
|
|
|
|
chmod -R 775 /opt/pialert/db /opt/pialert/db/temp /opt/pialert/config /opt/pialert/front/reports
|
|
|
|
touch /opt/pialert/log/pialert.vendors.log /opt/pialert/log/pialert.IP.log /opt/pialert/log/pialert.1.log /opt/pialert/log/pialert.cleanup.log /opt/pialert/log/pialert.webservices.log
|
|
|
|
src_dir="/opt/pialert/log"
|
|
|
|
dest_dir="/opt/pialert/front/php/server"
|
|
|
|
for file in pialert.vendors.log pialert.IP.log pialert.1.log pialert.cleanup.log pialert.webservices.log; do
|
|
|
|
ln -s "$src_dir/$file" "$dest_dir/$file"
|
|
|
|
done
|
2023-09-17 22:33:28 -04:00
|
|
|
git config --global --add safe.directory /opt/pialert
|
2023-09-13 08:09:25 -04:00
|
|
|
sed -i 's#PIALERT_PATH\s*=\s*'\''/home/pi/pialert'\''#PIALERT_PATH = '\''/opt/pialert'\''#' /opt/pialert/config/pialert.conf
|
2023-09-17 23:45:47 -04:00
|
|
|
sed -i 's/~/\/opt/g' /opt/pialert/install/pialert.cron
|
|
|
|
crontab /opt/pialert/install/pialert.cron
|
2023-09-17 22:33:28 -04:00
|
|
|
cp -R /opt/pialert/install/pialert_update.sh /usr/bin/update
|
|
|
|
sed -i 's/~/\/opt/g' /usr/bin/update
|
|
|
|
chmod +x /usr/bin/update
|
2023-09-17 10:55:33 -04:00
|
|
|
echo "python3 /opt/pialert/back/pialert.py 1" >/usr/bin/scan
|
|
|
|
chmod +x /usr/bin/scan
|
|
|
|
echo "/opt/pialert/back/pialert-cli set_permissions --lxc" >/usr/bin/permissions
|
|
|
|
chmod +x /usr/bin/permissions
|
|
|
|
echo "/opt/pialert/back/pialert-cli set_sudoers --lxc" >/usr/bin/sudoers
|
|
|
|
chmod +x /usr/bin/sudoers
|
2023-09-13 08:09:25 -04:00
|
|
|
msg_ok "Installed Pi.Alert"
|
|
|
|
|
2023-09-13 08:28:57 -04:00
|
|
|
msg_info "Start Pi.Alert Scan (Patience)"
|
2023-09-13 08:09:25 -04:00
|
|
|
$STD python3 /opt/pialert/back/pialert.py update_vendors
|
|
|
|
$STD python3 /opt/pialert/back/pialert.py internet_IP
|
|
|
|
$STD python3 /opt/pialert/back/pialert.py 1
|
|
|
|
msg_ok "Finished Pi.Alert Scan"
|
|
|
|
|
|
|
|
motd_ssh
|
|
|
|
customize
|
|
|
|
|
|
|
|
msg_info "Cleaning up"
|
|
|
|
$STD apt-get autoremove
|
|
|
|
$STD apt-get autoclean
|
|
|
|
msg_ok "Cleaned"
|