Added an installer script
* Added an installer script * Finished deployment script --------- Co-authored-by: Cynopolis <megaveganzombie@gmail.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ logs/
|
|||||||
meshtastic/
|
meshtastic/
|
||||||
.vscode/
|
.vscode/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
MeshtasticLogger.service
|
||||||
@@ -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
|
|
||||||
@@ -25,3 +25,8 @@ And you can stop the service by running:
|
|||||||
|
|
||||||
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
33
install.sh
Executable 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
|
||||||
|
|
||||||
|
|
||||||
14
service-template/MeshtasticLogger-template.service
Normal file
14
service-template/MeshtasticLogger-template.service
Normal 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
|
||||||
Reference in New Issue
Block a user