You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 lines
1.1 KiB

  1. #!/bin/bash
  2. # Check if user exits
  3. USER=mqttnetsrv
  4. USEREXISTS=$(id -u $USER >/dev/null 2>&1; echo $?)
  5. EC=0
  6. BASEPATH=/opt
  7. INSTALLPATH=$BASEPATH/MQTTnetServer
  8. # If user does not exist, create it
  9. if (( $USEREXISTS == 1 )); then
  10. useradd -d $INSTALLPATH -r $USER
  11. EC=$(echo $?)
  12. if (( $EC == 1 )); then
  13. exit 1;
  14. fi
  15. fi
  16. # Set permissions on files
  17. chown -R root:root $INSTALLPATH
  18. # Check if config does not exist and create it
  19. if [ ! -f "$INSTALLPATH/appsettings.json" ]; then
  20. cp $INSTALLPATH/appsettings.template.json $INSTALLPATH/appsettings.json
  21. fi
  22. # Check if setcap exists, does not exist in docker containers
  23. SCAP=$(which setcap >/dev/null; echo $?)
  24. if [ "$SCAP" -eq "0" ]; then
  25. # Enable MQTTServer.NET to bind to IP interface
  26. setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server
  27. fi
  28. chmod 644 /etc/systemd/system/mqttnet-server.service
  29. # Check if systemctl exists, does not exist in docker containers
  30. SCTL=$(which systemctl >/dev/null; echo $?)
  31. if [ "$SCTL" -eq "0" ]; then
  32. # Reload systemd because of new service file
  33. systemctl daemon-reload
  34. fi