mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
Install rewrite v2
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
.vscode
|
||||
.DS_Store
|
||||
config/*
|
||||
config/pialert.conf
|
||||
db/*
|
||||
db/pialert.db
|
||||
|
||||
20
Dockerfile
20
Dockerfile
@@ -25,8 +25,24 @@ RUN groupadd --gid "${USER_GID}" "${USER}" && \
|
||||
|
||||
COPY --chmod=775 --chown=${USER_ID}:${USER_GID} . /home/pi/pialert/
|
||||
|
||||
# ENTRYPOINT ["tini", "--"]
|
||||
|
||||
# ❗ IMPORTANT - if you modify this file modify the /install/install_dependecies.sh file as well ❗
|
||||
|
||||
RUN apt-get install -y \
|
||||
tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo \
|
||||
nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools \
|
||||
python3 iproute2 nmap python3-pip zip systemctl usbutils traceroute
|
||||
|
||||
# Alternate dependencies
|
||||
RUN apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8.2-sqlite3 -y
|
||||
RUN phpenmod -v 8.2 sqlite3
|
||||
|
||||
# Setup virtual python environment and use pip3 to install packages
|
||||
RUN apt-get install -y python3-venv
|
||||
RUN python3 -m venv myenv
|
||||
RUN /bin/bash -c "source myenv/bin/activate && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet"
|
||||
|
||||
|
||||
CMD ["/home/pi/pialert/dockerfiles/start.sh"]
|
||||
|
||||
## command to build docker: DOCKER_BUILDKIT=1 docker build . --iidfile dockerID
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ services:
|
||||
network_mode: host
|
||||
# restart: unless-stopped
|
||||
volumes:
|
||||
# - ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config
|
||||
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||
# - ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db
|
||||
- ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||
- ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config
|
||||
# - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||
- ${APP_DATA_LOCATION}/pialert_dev/db:/home/pi/pialert/db
|
||||
# - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -33,11 +33,10 @@ services:
|
||||
- ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js
|
||||
- ${DEV_LOCATION}/dockerfiles/start.sh:/home/pi/pialert/dockerfiles/start.sh
|
||||
- ${DEV_LOCATION}/dockerfiles/user-mapping.sh:/home/pi/pialert/dockerfiles/user-mapping.sh
|
||||
- ${DEV_LOCATION}/install/install.sh:/home/pi/pialert/install/install.sh
|
||||
- ${DEV_LOCATION}/install/install_python.sh:/home/pi/pialert/install/install_python.sh
|
||||
- ${DEV_LOCATION}/install/install.sh:/home/pi/pialert/install/install.sh
|
||||
- ${DEV_LOCATION}/install/install_dependencies.sh:/home/pi/pialert/install/install_dependencies.sh
|
||||
- ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api
|
||||
- ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php
|
||||
- ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php
|
||||
- ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php
|
||||
- ${DEV_LOCATION}/front/deviceDetailsTools.php:/home/pi/pialert/front/deviceDetailsTools.php
|
||||
- ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php
|
||||
|
||||
@@ -27,8 +27,7 @@ fi
|
||||
echo "[INSTALL] Run setup scripts"
|
||||
|
||||
"$INSTALL_DIR/pialert/dockerfiles/user-mapping.sh"
|
||||
"$INSTALL_DIR/pialert/install/install_dependencies.sh"
|
||||
"$INSTALL_DIR/pialert/install/install_python.sh"
|
||||
"$INSTALL_DIR/pialert/install/install_dependencies.sh" # if modifying this file transfer the chanegs into the root Dockerfile as well!
|
||||
|
||||
# Change port number if set
|
||||
if [ -n "${PORT}" ]; then
|
||||
@@ -73,11 +72,10 @@ fi
|
||||
# Fixing file permissions
|
||||
echo "[INSTALL] Fixing file permissions"
|
||||
|
||||
chmod -R a+rwx $INSTALL_DIR
|
||||
|
||||
chmod -R a+rwx /var/www/html
|
||||
chmod -R a+rw $INSTALL_DIR/pialert/front/log
|
||||
chmod -R a+rw $INSTALL_DIR/pialert/config
|
||||
sudo chgrp -R www-data $INSTALL_DIR/pialert
|
||||
chmod -R a+rwx $INSTALL_DIR
|
||||
|
||||
FILEDB=$INSTALL_DIR/pialert/db/pialert.db
|
||||
|
||||
@@ -85,14 +83,16 @@ if [ -f "$FILEDB" ]; then
|
||||
chown -R www-data:www-data $INSTALL_DIR/pialert/db/pialert.db
|
||||
fi
|
||||
|
||||
echo "[INSTALL] Copy starter pialert.db and pialert.conf if they don't exist"
|
||||
|
||||
echo "[INSTALL] Create pialert.db and pialert.conf backups"
|
||||
# Copy starter pialert.db and pialert.conf if they don't exist
|
||||
cp -n "$INSTALL_DIR/pialert/back/pialert.conf" "$INSTALL_DIR/pialert/config/pialert.conf"
|
||||
cp -n "$INSTALL_DIR/pialert/back/pialert.db" "$INSTALL_DIR/pialert/db/pialert.db"
|
||||
|
||||
# Create a backup of pialert.conf
|
||||
cp "$INSTALL_DIR/pialert/config/pialert.conf" "$INSTALL_DIR/pialert/back/pialert.conf_bak"
|
||||
|
||||
# Create a backup of pialert.db
|
||||
cp "$INSTALL_DIR/pialert/db/pialert.db" "$INSTALL_DIR/pialert/back/pialert.db_bak"
|
||||
chmod -R a+rwx $INSTALL_DIR # second time after we copied the files
|
||||
chmod -R a+rw $INSTALL_DIR/pialert/config
|
||||
sudo chgrp -R www-data $INSTALL_DIR/pialert
|
||||
|
||||
# Create buildtimestamp.txt
|
||||
date +%s > "$INSTALL_DIR/pialert/front/buildtimestamp.txt"
|
||||
|
||||
@@ -607,6 +607,8 @@
|
||||
"Systeminfo_USB_Devices" : "USB Devices",
|
||||
"report_select_format": "Select Format:",
|
||||
"report_time": "Notification time:",
|
||||
"report_guid": "Notification guid:",
|
||||
"report_guid_missing": "Linked notification not found. The selected notification might have been deleted during maintenance as specified in the <code>DBCLNP_NOTIFI_HIST</code> setting. The latest notification is dispalyed instead. The missing notification has the following GUID:",
|
||||
"Donations_Title" : "Donations",
|
||||
"Donations_Text" : "Hey 👋! </br> Thanks for clicking on this menu item 😅 </br> </br> I'm trying to collect some donations to make you better software. Also, it would help me not to get burned out. Me burning out might mean end of support for this app. Any small (recurring or not) sponsorship makes me want ot put more effort into this app. I don't want to lock features (new plugins) behind paywalls 🔐. </br> Currently, I'm waking up 2h before work so I contribute to the app a bit. If I had some recurring income I could shorten my workweek and in the remaining time fully focus on PiAlert. You'd get more functionality, a more polished app and less bugs. </br> </br> Thanks for reading - I'm super grateful for any support ❤🙏 </br> </br> TL;DR: By supporting me you get: </br> </br> <ul><li>Regular updates to keep your data and family safe 🔄</li><li>Less bugs 🐛🔫</li><li>Better and more functionality➕</li><li>I don't get burned out 🔥🤯</li><li>Less rushed releases 💨</li><li>Better docs📚</li><li>Quicker and better support with issues 🆘</li><li>Less grumpy me 😄</li></ul> </br> 📧Email me to <a href='mailto:jokob@duck.com?subject=PiAlert'>jokob@duck.com</a> if you want to get in touch or if I should add other sponsorship platforms. </br>",
|
||||
"Donations_Platforms" : "Sponsor platforms",
|
||||
|
||||
@@ -58,9 +58,14 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-8">
|
||||
<div class="col-sm-4">
|
||||
<label><?= lang('report_time') ;?></label>
|
||||
<span id="timestamp">Timestamp</span>
|
||||
<span id="timestamp"></span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<label><?= lang('report_guid') ;?></label>
|
||||
<span id="guid"></span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -77,6 +82,7 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const notificationData = document.getElementById('notificationData');
|
||||
const timestamp = document.getElementById('timestamp');
|
||||
const notiGuid = document.getElementById('guid');
|
||||
const prevButton = document.getElementById('prevButton');
|
||||
const nextButton = document.getElementById('nextButton');
|
||||
const formatSelect = document.getElementById('formatSelect');
|
||||
@@ -113,7 +119,10 @@
|
||||
break;
|
||||
}
|
||||
|
||||
// console.log(notification)
|
||||
|
||||
timestamp.textContent = notification.DateTimeCreated;
|
||||
notiGuid.textContent = notification.GUID;
|
||||
currentIndex = index;
|
||||
|
||||
$("#notificationOutOff").html(`${currentIndex + 1}/${data.data.length}`);
|
||||
@@ -125,7 +134,7 @@
|
||||
|
||||
// Function to find the index of a notification by GUID
|
||||
function findIndexByGUID(data, guid) {
|
||||
return data.findIndex(notification => notification.GUID === guid);
|
||||
return data.findIndex(notification => notification.GUID == guid);
|
||||
}
|
||||
|
||||
// Listen for format selection changes
|
||||
@@ -151,10 +160,16 @@
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const index = findIndexByGUID(data.data, guid);
|
||||
if (index !== -1) {
|
||||
// Load the notification with the specified GUID
|
||||
updateData(formatSelect.value, index);
|
||||
|
||||
console.log(index)
|
||||
|
||||
if (index == -1) {
|
||||
showModalOk('WARNING', `${getString("report_guid_missing")} <br/> <br/> <code>${guid}</code>`)
|
||||
}
|
||||
|
||||
// Load the notification with the specified GUID
|
||||
updateData(formatSelect.value, index);
|
||||
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
|
||||
@@ -4,8 +4,7 @@ echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Run install_dependencies.sh"
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
# Set environment variables
|
||||
INSTALL_DIR=/home/pi # Specify the installation directory here
|
||||
# ❗ IMPORTANT - if you modify this file modify the root Dockerfile as well ❗
|
||||
|
||||
# Check if script is run as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
@@ -13,19 +12,22 @@ if [[ $EUID -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Install dependencies
|
||||
apt-get install -y \
|
||||
tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo \
|
||||
nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools \
|
||||
python3 iproute2 nmap python3-pip zip systemctl usbutils traceroute
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# alternate dependencies
|
||||
# sudo apt-get install mtr-tiny -y
|
||||
sudo apt-get install nginx nginx-core mtr php-fpm php8.2-fpm -y
|
||||
sudo apt-get install php-cli php8.2 php8.2-fpm -y
|
||||
sudo apt-get install php8.2-sqlite3 -y
|
||||
sudo apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8.2-sqlite3 -y
|
||||
sudo phpenmod -v 8.2 sqlite3
|
||||
# sudo apt-get install net-tools -y
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
# setup virtual python environment so we can use pip3 to install packages
|
||||
apt-get install python3.11-venv -y
|
||||
python3 -m venv myenv
|
||||
source myenv/bin/activate
|
||||
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3 10
|
||||
|
||||
# install packages thru pip3
|
||||
pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# apt-get install python3-requests python3-paho-mqtt python3-scapy -y
|
||||
echo "---------------------------------------------------------"
|
||||
echo "[INSTALL] Run install_python.sh"
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
# setup virtual python environment so we can use pip3 to install packages
|
||||
apt-get install python3.11-venv -y
|
||||
python3 -m venv myenv
|
||||
source myenv/bin/activate
|
||||
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3 10
|
||||
|
||||
# install packages thru pip3
|
||||
pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli chardet
|
||||
|
||||
@@ -191,11 +191,11 @@ def filePermissions():
|
||||
(confR_access, dbR_access) = checkPermissionsOK() # Initial check
|
||||
|
||||
if confR_access == False:
|
||||
initialiseFile(fullConfPath, "/home/pi/pialert/back/pialert.conf_bak" )
|
||||
initialiseFile(fullConfPath, "/home/pi/pialert/back/pialert.conf" )
|
||||
|
||||
# check and initialize pialert.db
|
||||
if dbR_access == False:
|
||||
initialiseFile(fullDbPath, "/home/pi/pialert/back/pialert.db_bak")
|
||||
initialiseFile(fullDbPath, "/home/pi/pialert/back/pialert.db")
|
||||
|
||||
# last attempt
|
||||
fixPermissions()
|
||||
|
||||
Reference in New Issue
Block a user