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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. # Source our persisted env variables from container startup
  3. . /etc/transmission/environment-variables.sh
  4. # This script will be called with tun/tap device name as parameter 1, and local IP as parameter 4
  5. # See https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html (--up cmd)
  6. echo "Up script executed with $*"
  7. if [ "$4" = "" ]; then
  8. echo "ERROR, unable to obtain tunnel address"
  9. echo "killing $PPID"
  10. kill -9 $PPID
  11. exit 1
  12. fi
  13. # If transmission-pre-start.sh exists, run it
  14. if [ -x /scripts/transmission-pre-start.sh ]
  15. then
  16. echo "Executing /scripts/transmission-pre-start.sh"
  17. /scripts/transmission-pre-start.sh
  18. echo "/scripts/transmission-pre-start.sh returned $?"
  19. fi
  20. echo "Updating TRANSMISSION_BIND_ADDRESS_IPV4 to the ip of $1 : $4"
  21. export TRANSMISSION_BIND_ADDRESS_IPV4=$4
  22. if [ "combustion" = "$TRANSMISSION_WEB_UI" ]; then
  23. echo "Using Combustion UI, overriding TRANSMISSION_WEB_HOME"
  24. export TRANSMISSION_WEB_HOME=/opt/transmission-ui/combustion-release
  25. fi
  26. if [ "kettu" = "$TRANSMISSION_WEB_UI" ]; then
  27. echo "Using Kettu UI, overriding TRANSMISSION_WEB_HOME"
  28. export TRANSMISSION_WEB_HOME=/opt/transmission-ui/kettu
  29. fi
  30. echo "Generating transmission settings.json from env variables"
  31. # Ensure TRANSMISSION_HOME is created
  32. mkdir -p ${TRANSMISSION_HOME}
  33. dockerize -template /etc/transmission/settings.tmpl:${TRANSMISSION_HOME}/settings.json
  34. echo "sed'ing True to true"
  35. sed -i 's/True/true/g' ${TRANSMISSION_HOME}/settings.json
  36. if [ ! -e "/dev/random" ]; then
  37. # Avoid "Fatal: no entropy gathering module detected" error
  38. echo "INFO: /dev/random not found - symlink to /dev/urandom"
  39. ln -s /dev/urandom /dev/random
  40. fi
  41. . /etc/transmission/userSetup.sh
  42. if [ "true" = "$DROP_DEFAULT_ROUTE" ]; then
  43. echo "DROPPING DEFAULT ROUTE"
  44. ip r del default || exit 1
  45. fi
  46. echo "STARTING TRANSMISSION"
  47. exec su --preserve-environment ${RUN_AS} -s /bin/bash -c "/usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log" &
  48. if [ "$OPENVPN_PROVIDER" = "PIA" ]
  49. then
  50. echo "CONFIGURING PORT FORWARDING"
  51. exec /etc/transmission/updatePort.sh &
  52. else
  53. echo "NO PORT UPDATER FOR THIS PROVIDER"
  54. fi
  55. # If transmission-post-start.sh exists, run it
  56. if [ -x /scripts/transmission-post-start.sh ]
  57. then
  58. echo "Executing /scripts/transmission-post-start.sh"
  59. /scripts/transmission-post-start.sh
  60. echo "/scripts/transmission-post-start.sh returned $?"
  61. fi
  62. echo "Transmission startup script complete."