Added an installer script

* Added an installer script

* Finished deployment script

---------

Co-authored-by: Cynopolis <megaveganzombie@gmail.com>
This commit is contained in:
Cynopolis
2025-04-02 11:54:23 -04:00
committed by GitHub
parent 4baed385d8
commit 976d2453a2
5 changed files with 55 additions and 16 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
logs/ logs/
meshtastic/ meshtastic/
.vscode/ .vscode/
__pycache__/ __pycache__/
MeshtasticLogger.service

View File

@@ -1,14 +0,0 @@
[Unit]
Description=A simple chat interface and autoresponder for meshtastic
[Service]
Type=simple
WorkingDirectory=/home/quinn/Projects/Meshtastic-Webserver/
ExecStart=sudo /home/quinn/Projects/Meshtastic-Webserver/meshtastic/bin/python -m flask --app /home/quinn/Projects/Meshtastic-Webserver/app.py run --host=0.0.0.0 --port=80
Restart=always
User=quinn
StandardOutput=append:/home/quinn/Projects/Meshtastic-Webserver/logs/meshtastic_system.log
StandardError=append:/home/quinn/Projects/Meshtastic-Webserver/logs/meshtastic_system_error.log
[Install]
WantedBy=multi-user.target

View File

@@ -24,4 +24,9 @@ And you can stop the service by running:
`sudo systemctl stop MeshtasticLogger` `sudo systemctl stop MeshtasticLogger`
To have the service start on boot run: To have the service start on boot run:
`systemctl enable MeshtasticLogger` `systemctl enable MeshtasticLogger`
# Automatic Deployment
Make sure the bash script is executable by running: `chmod u+x install.sh`
Make certain you are actually in the Meshtastic-Webserver Directory or this will fail. Run the script with: `sudo ./install.sh`

33
install.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
CURRENT_DIRECTORY=$(pwd)
echo "Current directory: $CURRENT_DIRECTORY"
cd $CURRENT_DIRECTORY
if test -f "meshtastic"; then
echo "Virtual environment already exists. Skipping venv creation."
else
echo "Making virtual environment..."
python3 -m venv meshtastic
fi
echo "Installing venv requirements"
meshtastic/bin/python -m pip install -r requirements.txt
echo "Generating service file from template"
read -p "Do you want to continue? (y/n): " choice
# Check if the user typed 'n' or 'N'
if [[ "$choice" == "n" || "$choice" == "N" ]]; then
echo "Exiting the script..."
exit 0
fi
echo "Continuing...\n Creating Service file..."
# Replace all instances of ${WORKING_DIRECTORY} with the actual working directory and write to the new file
sed "s|\${WORKING_DIRECTORY}|$CURRENT_DIRECTORY|g" "service-template/MeshtasticLogger-template.service" > "MeshtasticLogger.service"
echo "Deploying service"
sudo cp "$CURRENT_DIRECTORY/MeshtasticLogger.service" /etc/systemd/system/ && sudo systemctl daemon-reload && sudo systemctl start MeshtasticLogger

View File

@@ -0,0 +1,14 @@
[Unit]
Description=A simple chat interface and autoresponder for meshtastic
[Service]
Type=simple
WorkingDirectory=${WORKING_DIRECTORY}/
ExecStart=sudo ${WORKING_DIRECTORY}/meshtastic/bin/python -m flask --app ${WORKING_DIRECTORY}/app.py run --host=0.0.0.0 --port=80
Restart=always
User=quinn
StandardOutput=append:${WORKING_DIRECTORY}/logs/meshtastic_system.log
StandardError=append:${WORKING_DIRECTORY}/logs/meshtastic_system_error.log
[Install]
WantedBy=multi-user.target