Commit 71ecbb64 authored by Florian Bruggisser's avatar Florian Bruggisser
Browse files

implemented install and uninstall scripts

parent 6eab6807
# Telemersion Server
Telemersion Server that contains an MQTT broker and the telemersion-manager
\ No newline at end of file
Telemersion Server that contains an MQTT broker and the telemersion-manager.
## Installation
To install the telemersion server on an instance clone the github repository into the installation directory (for example `/opt/telemersion-server`).
```
git clone https://gitlab.zhdk.ch/iaspace/05_projects/telemersion-server
```
### Mosquitto Broker Service
To install the mosquitto broker as a service (Debian with systemd) use the following command:
```bash
sudo ./broker-service-install.sh
```
### Manager Service
tdb
## Usage
### Mosquitto Broker
To test the mosquitto broker it is possible to run it without service installation:
```bash
./broker-run.sh
```
#### Service
```bash
# start service
sudo systemctl start telemersion-broker.service
# stop service
sudo systemctl start telemersion-broker.service
# restart service
sudo systemctl restart telemersion-broker.service
# enable service (auto-start on restart)
sudo systemctl enable telemersion-broker.service
# disbale service
sudo systemctl disable telemersion-broker.service
# show status
sudo systemctl status telemersion-broker.service
```
### Manager
tbd
\ No newline at end of file
#!/bin/bash
### Installs the broker as a service and all its dependencies.
### Florian Bruggisser 16.02.2021
# Read the asolute path to the script file.
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
pushd "$SCRIPT_PATH"
# load configuration
source broker-service.cfg
# install prerequisites if necessary (only on Linux)
echo "installing msoquitto..."
sudo apt update
sudo apt install mosquitto -y
# add user
echo "adding service user..."
useradd -s /usr/sbin/nologin -r -M $SERVICE_USER_NAME
# grant access
setfacl -R -m u:$SERVICE_USER_NAME:rwx "$SCRIPT_PATH"
# prepare service configuration form template
echo "installing service..."
RUN_SCRIPT_PATH="$SCRIPT_PATH/broker-run.sh"
cp "broker/$SERVICE_NAME.service.txt" "$SERVICE_NAME.service"
sed -i -e "s~%COMMAND%~$RUN_SCRIPT_PATH~g" "$SERVICE_NAME.service"
sed -i -e "s~%USER%~$SERVICE_USER_NAME~g" "$SERVICE_NAME.service"
# install as service
sudo mv $SERVICE_NAME.service "/etc/systemd/system/$SERVICE_NAME.service"
echo "enabling service..."
sudo systemctl enable $SERVICE_NAME.service
echo "Please start your service now:"
echo "sudo systemctl start $SERVICE_NAME.service"
popd
\ No newline at end of file
#!/bin/bash
### Uninstalls the broker as a service without it's dependencies.
### Florian Bruggisser 16.02.2021
# Read the asolute path to the script file.
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
pushd "$SCRIPT_PATH"
# load configuration
source broker-service.cfg
echo "stopping service..."
sudo systemctl stop $SERVICE_NAME.service
echo "disabling service..."
sudo systemctl disable $SERVICE_NAME.service
echo "cleaning up service files..."
sudo rm -f "/etc/systemd/system/$SERVICE_NAME.service"
echo "removing service user"
userdel $SERVICE_USER_NAME
echo "uninstall completed!"
popd
\ No newline at end of file
# broker service configuration
SERVICE_NAME=telemersion-broker
SERVICE_USER_NAME=telemersion_broker
\ No newline at end of file
[Unit]
Description=Mosquitto Service for telemersive-server.
# run after network is up
Requires=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=%COMMAND%
User=%USER%
[Install]
WantedBy=multi-user.target
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment