Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

start.sh 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "Check transmission settings.json file attributes"
  35. SETTINGS_PATH=${TRANSMISSION_HOME}/settings.json
  36. SETTINGS_ATTRIBUTES=$(stat -c %a ${SETTINGS_PATH})
  37. if [ ${SETTINGS_ATTRIBUTES} = 0 ]; then
  38. # Ensure settings.json have non zero attributes (actual for Synology NAS)
  39. chmod 640 ${SETTINGS_PATH} && echo "INFO: Attributes of setting.json changed to 640"
  40. fi
  41. echo "sed'ing True to true"
  42. sed -i 's/True/true/g' ${TRANSMISSION_HOME}/settings.json
  43. if [ ! -e "/dev/random" ]; then
  44. # Avoid "Fatal: no entropy gathering module detected" error
  45. echo "INFO: /dev/random not found - symlink to /dev/urandom"
  46. ln -s /dev/urandom /dev/random
  47. fi
  48. . /etc/transmission/userSetup.sh
  49. if [ "true" = "$DROP_DEFAULT_ROUTE" ]; then
  50. echo "DROPPING DEFAULT ROUTE"
  51. ip r del default || exit 1
  52. fi
  53. echo "STARTING TRANSMISSION"
  54. exec su --preserve-environment ${RUN_AS} -s /bin/bash -c "/usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log" &
  55. if [ "$OPENVPN_PROVIDER" = "PIA" ]
  56. then
  57. echo "CONFIGURING PORT FORWARDING"
  58. exec /etc/transmission/updatePort.sh &
  59. else
  60. echo "NO PORT UPDATER FOR THIS PROVIDER"
  61. fi
  62. # If transmission-post-start.sh exists, run it
  63. if [ -x /scripts/transmission-post-start.sh ]
  64. then
  65. echo "Executing /scripts/transmission-post-start.sh"
  66. /scripts/transmission-post-start.sh
  67. echo "/scripts/transmission-post-start.sh returned $?"
  68. fi
  69. echo "Transmission startup script complete."