htaborda

WD Mybook Live - Transmission installation script

Apr 25th, 2016
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 18.60 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #Compile and Install transmission bittorrent client on mybooklive
  4. #
  5. #Author: Proglin 2015-09-10
  6. #Modified by HTaborda 2015-04-24
  7. #
  8. # Update: 2016-04-24 Introduced --no-check-certificate to the Transmission source download; server certificate outdated
  9. # Update: 2016-02-26 LibEvent Extract Folder name changed + Compile Changed
  10. # Update: 2016-02-22 LibEvent URL changed
  11. #
  12. # Note:
  13. #   I strong recommend you to download an update firmware
  14. #   Save it in public folder
  15. #   If anything goes wrong you can update your firmware to clean the mess using:
  16. #    /usr/local/sbin/updateFirmwareFromFile.sh /DataVolume/shares/Public/apnc-024310-048-20150507.deb
  17. #
  18. # References:
  19. #https://trac.transmissionbt.com/wiki/Building#DebianSqueeze
  20. #https://trac.transmissionbt.com/wiki/Scripts/initd
  21. #http://falkhusemann.de/blog/2012/05/compiling-transmission-bittorrent-for-debiand/
  22. #http://community.wd.com/t5/My-Book-Live/GUIDE-How-to-unbrick-a-totally-dead-MBL/td-p/435724
  23. #http://support.wd.com/product/download.asp?groupid=902&sid=132&lang=en
  24. start=$SECONDS
  25.  
  26. # CONFIGURATION TRANSMISSION VERSION
  27. TRANSMISSIONSOURCE='http://download.transmissionbt.com/files/transmission-2.84.tar.xz'
  28.  
  29. # EXTRA CONFIGURATIONS
  30. #TMPFOLDER='/root/temp'
  31. #LIBEVENTSOURCE='http://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.18-stable.tar.gz'
  32. LIBEVENTSOURCE='https://github.com/libevent/libevent/archive/release-2.0.18-stable.tar.gz'
  33. LIBEVENTEXTRACTNAME='libevent-release-2.0.18-stable.tar.gz'
  34.  
  35. #Change TMP Folder to have more space!
  36. TMPFOLDER='/shares/Public/tmpCompile'
  37. TMP=$TMPFOLDER
  38. TEMP=$TMPFOLDER
  39. TMPDIR=$TMPFOLDER
  40. export TMPDIR TMP TEMP
  41.  
  42. clear
  43. echo "Welcome! Compile and Install Transmission 2.84"
  44. echo "Created by Proglin v2015-09-10"
  45. echo "      Last Update: v2016-02-26"
  46. echo "ALWAYS back up your data before proceeding."
  47. echo "This script was only tested with MyBookLive firmware 02.43.10-048"
  48. printf "Your firmware version is: ";tail -1 /var/log/version.log
  49. echo ""
  50. echo "We are going to change some configs to install Tranmission"
  51. read -p "This process takes around 30 minutes. Are you sure? (Y/N)" -n 1 -r
  52. echo    # (optional) move to a new line
  53. if [[ $REPLY =~ ^[Nn]$ ]]
  54. then
  55.     echo "OK. Exiting."
  56.     exit
  57. fi
  58.  
  59. mkdir -p $TMPFOLDER
  60. if [[ $? > 0 ]]
  61. then
  62.     echo "The command failed, exiting." ; exit
  63. fi
  64.  
  65. rm -f /var/lib/dpkg/info/wd-nas.*
  66. cp /etc/apt/sources.list $TMPFOLDER/sources.list.bak
  67. echo ""
  68. printf "1/22 Configuring repositories... (part 1/3)"
  69. APTSOURCESOLD="#Modified to install Transmission (old packages)
  70. deb http://archive.debian.org/debian/ squeeze main
  71. deb-src http://archive.debian.org/debian/ squeeze main
  72. #deb http://ftp.br.debian.org/debian/ wheezy main
  73. #deb-src http://ftp.br.debian.org/debian/ wheezy main\n"
  74. printf "$APTSOURCESOLD" > /etc/apt/sources.list
  75.  
  76. apt-get -qq clean
  77. apt-get -qq update >/dev/null 2>&1
  78. if [[ $? > 0 ]]
  79. then
  80.     echo "The command failed, exiting." ; exit
  81. else
  82.     echo " OK!"
  83. fi
  84.  
  85. printf "2/22 Installing packages... (part 1/7)"
  86. apt-get -q -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install tar >/dev/null 2>&1
  87. if [[ $? > 0 ]]
  88. then
  89.     echo "The command failed, exiting." ; exit
  90. else
  91.     echo " OK!"
  92. fi
  93.  
  94. printf "3/22 Installing packages... (part 2/7)"
  95. apt-get -q -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install ca-certificates >/dev/null 2>&1
  96. if [[ $? > 0 ]]
  97. then
  98.     echo "The command failed, exiting." ; exit
  99. else
  100.     echo " OK!"
  101. fi
  102.  
  103. printf "4/22 Installing packages... (part 3/7)"
  104. apt-get -q -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install intltool >/dev/null 2>&1
  105. if [[ $? > 0 ]]
  106. then
  107.     echo "The command failed, exiting." ; exit
  108. else
  109.     echo " OK!"
  110. fi
  111.  
  112. printf "5/22 Installing packages... (part 4/7)"
  113. apt-get -q -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install build-essential >/dev/null 2>&1
  114. if [[ $? > 0 ]]
  115. then
  116.     echo "The command failed, exiting." ; exit
  117. else
  118.     echo " OK!"
  119. fi
  120.  
  121. printf "6/22 Installing packages... (part 5/7)"
  122. apt-get -q -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install libtool >/dev/null 2>&1
  123. if [[ $? > 0 ]]
  124. then
  125.     echo "The command failed, exiting." ; exit
  126. else
  127.     echo " OK!"
  128. fi
  129.  
  130. printf "7/22 Configuring repositories... (part 2/3)"
  131. APTSOURCESNEW="#Modified to install Transmission (new packages)
  132. #deb http://archive.debian.org/debian/ squeeze main
  133. #deb-src http://archive.debian.org/debian/ squeeze main
  134. deb http://ftp.br.debian.org/debian/ wheezy main
  135. deb-src http://ftp.br.debian.org/debian/ wheezy main\n"
  136. printf "$APTSOURCESNEW" > /etc/apt/sources.list
  137. apt-get -qq clean
  138. apt-get -qq update 2>/dev/null
  139. if [[ $? > 0 ]]
  140. then
  141.     echo "The command failed, exiting." ; exit
  142. else
  143.     echo " OK!"
  144. fi
  145.  
  146. printf "8/22 Installing packages... (part 6/7)"
  147. export DEBIAN_FRONTEND=noninteractive
  148. apt-get -qq -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" -o Dpkg::Options::="--force-confdef" install libssl-dev >/dev/null 2>&1
  149. if [[ $? > 0 ]]
  150. then
  151.     echo "The command failed, exiting." ; exit
  152. else
  153.     echo " OK!"
  154. fi
  155.  
  156. printf "9/22 Configuring repositories... (part 3/3)"
  157. APTSOURCESOLD="#Modified to install Transmission (old packages)
  158. deb http://archive.debian.org/debian/ squeeze main
  159. deb-src http://archive.debian.org/debian/ squeeze main
  160. #deb http://ftp.br.debian.org/debian/ wheezy main
  161. #deb-src http://ftp.br.debian.org/debian/ wheezy main\n"
  162. printf "$APTSOURCESOLD" > /etc/apt/sources.list
  163.  
  164. apt-get -qq clean
  165. apt-get -qq update >/dev/null 2>&1
  166. if [[ $? > 0 ]]
  167. then
  168.     echo "The command failed, exiting." ; exit
  169. else
  170.     echo " OK!"
  171. fi
  172.  
  173. printf "10/22 Installing packages... (part 7/7)"
  174. apt-get -q -y --force-yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install libcurl4-openssl-dev >/dev/null 2>&1
  175. if [[ $? > 0 ]]
  176. then
  177.     echo "The command failed, exiting." ; exit
  178. else
  179.     echo " OK!"
  180. fi
  181.  
  182. printf "11/22 Downloading sources of LIBEVENT..."
  183. #Getting sources of Transmission and LibEvent
  184. #wget -q $LIBEVENTSOURCE -O $TMPFOLDER/${LIBEVENTSOURCE##*/} >/dev/null 2>&1
  185. wget -q $LIBEVENTSOURCE -O $TMPFOLDER/$LIBEVENTEXTRACTNAME >/dev/null 2>&1
  186. if [[ $? > 0 ]]
  187. then
  188.     echo "The command failed, exiting." ; exit
  189. fi
  190. #extract
  191. #tar xf $TMPFOLDER/${LIBEVENTSOURCE##*/} -C $TMPFOLDER >/dev/null 2>&1
  192. tar xf $TMPFOLDER/$LIBEVENTEXTRACTNAME -C $TMPFOLDER >/dev/null 2>&1
  193. if [[ $? > 0 ]]
  194. then
  195.     echo "The command failed, exiting." ; exit
  196. else
  197.     echo " OK!"
  198. fi
  199.  
  200. printf "12/22 Downloading sources of TRANSMISSION"
  201. #Getting sources of Transmission and LibEvent
  202. #wget -q $TRANSMISSIONSOURCE -O $TMPFOLDER/${TRANSMISSIONSOURCE##*/} >/dev/null 2>&1
  203. wget --no-check-certificate  $TRANSMISSIONSOURCE -O $TMPFOLDER/${TRANSMISSIONSOURCE##*/} >/dev/null 2>&1
  204. if [[ $? > 0 ]]
  205. then
  206.     echo "The command failed, exiting." ; exit
  207. fi
  208. #extract
  209. tar xf $TMPFOLDER/${TRANSMISSIONSOURCE##*/} -C $TMPFOLDER >/dev/null 2>&1
  210. if [[ $? > 0 ]]
  211. then
  212.     echo "The command failed, exiting." ; exit
  213. else
  214.     echo " OK!"
  215. fi
  216.  
  217. #clean cache
  218. apt-get clean
  219.  
  220. #Getfilenames of directories
  221. #AFTER_SLASH=${LIBEVENTSOURCE##*/}
  222. #file="${AFTER_SLASH%%\?*}"
  223. file=${LIBEVENTEXTRACTNAME}
  224. DIRLIBEVENTSOURCE=${file%.tar.xz}
  225. DIRLIBEVENTSOURCE=${DIRLIBEVENTSOURCE%.tar.gz}
  226.  
  227. #Configure LIBEVENT
  228. cd $TMPFOLDER/$DIRLIBEVENTSOURCE
  229. printf "13/22 Configuring LIBEVENT to compile..."
  230. ./autogen.sh >/dev/null 2>&1
  231. if [[ $? > 0 ]]
  232. then
  233.     echo "The command failed, exiting." ; exit
  234. fi
  235. ./configure --prefix=/usr >/dev/null 2>&1
  236. if [[ $? > 0 ]]
  237. then
  238.     echo "The command failed, exiting." ; exit
  239. else
  240.     echo " OK!"
  241. fi
  242.  
  243. #Compile LIBEVENT
  244. printf "14/22 Compiling LIBEVENT..."
  245. make >/dev/null 2>&1
  246. if [[ $? > 0 ]]
  247. then
  248.     echo "The command failed, exiting." ; exit
  249. else
  250.     echo " OK!"
  251. fi
  252.  
  253. #Install LIBEVENT
  254. printf "15/22 Installing LIBEVENT..."
  255. make install >/dev/null 2>&1
  256. if [[ $? > 0 ]]
  257. then
  258.     echo "The command failed, exiting." ; exit
  259. else
  260.     echo " OK!"
  261. fi
  262.  
  263. #Configure TRANSMISSION
  264. AFTER_SLASH=${TRANSMISSIONSOURCE##*/}
  265. file="${AFTER_SLASH%%\?*}"
  266. DIRTRANSMISSION=${file%.tar.xz}
  267. DIRTRANSMISSION=${DIRTRANSMISSION%.tar.gz}
  268.  
  269. cd $TMPFOLDER/$DIRTRANSMISSION
  270. printf "16/22 Configuring TRANSMISSION to compile..."
  271. ./configure --prefix=/usr --enable-lightweight --enable-daemon --enable-utp >/dev/null 2>&1
  272. if [[ $? > 0 ]]
  273. then
  274.     echo "The command failed, exiting." ; exit
  275. else
  276.     echo " OK!"
  277. fi
  278.  
  279. #Compile TRANSMISSION
  280. printf "17/22 Compiling TRANSMISSION..."
  281. make >/dev/null 2>&1
  282. if [[ $? > 0 ]]
  283. then
  284.     echo "The command failed, exiting." ; exit
  285. else
  286.     echo " OK!"
  287. fi
  288.  
  289. #Install TRANSMISSION
  290. printf "18/22 Installing TRANSMISSION..."
  291. #mkdir -p /root/.config/transmissiond
  292. make install >/dev/null 2>&1
  293. if [[ $? > 0 ]]
  294. then
  295.     echo "The command failed, exiting." ; exit
  296. else
  297.     echo " OK!"
  298. fi
  299.  
  300.  
  301. #settings.json
  302. read -d '' SETTINGSJSON <<"EOF"
  303. {
  304.     "alt-speed-down": 300,
  305.     "alt-speed-enabled": true,
  306.     "alt-speed-time-begin": 420,
  307.     "alt-speed-time-day": 127,
  308.     "alt-speed-time-enabled": true,
  309.     "alt-speed-time-end": 30,
  310.     "alt-speed-up": 10,
  311.     "bind-address-ipv4": "0.0.0.0",
  312.     "bind-address-ipv6": "::",
  313.     "blocklist-enabled": true,
  314.     "blocklist-url": "http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz",
  315.     "cache-size-mb": 8,
  316.     "dht-enabled": true,
  317.     "download-dir": "/DataVolume/shares/Public/Torrents/Completed",
  318.     "download-queue-enabled": true,
  319.     "download-queue-size": 5,
  320.     "encryption": 2,
  321.     "idle-seeding-limit": 30,
  322.     "idle-seeding-limit-enabled": true,
  323.     "incomplete-dir": "/DataVolume/shares/Public/Torrents/Incomplete",
  324.     "incomplete-dir-enabled": true,
  325.     "lazy-bitfield-enabled": true,
  326.     "lpd-enabled": false,
  327.     "message-level": 2,
  328.     "peer-congestion-algorithm": "lp",
  329.     "peer-id-ttl-hours": 6,
  330.     "peer-limit-global": 260,
  331.     "peer-limit-per-torrent": 80,
  332.     "peer-port": 51003,
  333.     "peer-port-random-high": 65535,
  334.     "peer-port-random-low": 49152,
  335.     "peer-port-random-on-start": false,
  336.     "peer-socket-tos": "lowcost",
  337.     "pex-enabled": true,
  338.     "port-forwarding-enabled": false,
  339.     "preallocation": 2,
  340.     "prefetch-enabled": 0,
  341.     "queue-stalled-enabled": true,
  342.     "queue-stalled-minutes": 60,
  343.     "ratio-limit": 0.1000,
  344.     "ratio-limit-enabled": true,
  345.     "rename-partial-files": true,
  346.     "rpc-authentication-required": false,
  347.     "rpc-bind-address": "0.0.0.0",
  348.     "rpc-enabled": true,
  349.     "rpc-password": "{ee82e7a5337f8d06704c133d83fd69da54bdc785ixojPp6Z",
  350.     "rpc-port": 9091,
  351.     "rpc-url": "/transmission/",
  352.     "rpc-username": "transmission",
  353.     "rpc-whitelist": "127.0.0.1,192.168.*.*",
  354.     "rpc-whitelist-enabled": true,
  355.     "scrape-paused-torrents-enabled": true,
  356.     "script-torrent-done-enabled": false,
  357.     "script-torrent-done-filename": "/DataVolume/shares/Public/Torrents/Scripts/processaTorrent.sh",
  358.     "seed-queue-enabled": true,
  359.     "seed-queue-size": 10,
  360.     "speed-limit-down": 1100,
  361.     "speed-limit-down-enabled": true,
  362.     "speed-limit-up": 85,
  363.     "speed-limit-up-enabled": true,
  364.     "start-added-torrents": true,
  365.     "trash-original-torrent-files": true,
  366.     "umask": 0,
  367.     "upload-slots-per-torrent": 8,
  368.     "utp-enabled": true,
  369.     "watch-dir": "/DataVolume/shares/Public/Torrents/Monitora",
  370.     "watch-dir-enabled": false
  371. }
  372.  
  373. EOF
  374.  
  375. #INIT.D file
  376. read -d '' INITD <<"EOF"
  377. #! /bin/sh
  378. ### BEGIN INIT INFO
  379. # Provides:          transmission-daemon
  380. # Required-Start:    networking
  381. # Required-Stop:     networking
  382. # Default-Start:     2 3 5
  383. # Default-Stop:      0 1 6
  384. # Short-Description: Start the transmission BitTorrent daemon client.
  385. ### END INIT INFO
  386.  
  387. # Original Author: Lennart A. Jaette, based on Rob Howell's script
  388. # Modified by Maarten Van Coile & others (on IRC)
  389.  
  390. # Do NOT "set -e"
  391.  
  392. #
  393. # ----- CONFIGURATION -----
  394. #
  395. # For the default location Transmission uses, visit:
  396. # http://trac.transmissionbt.com/wiki/ConfigFiles
  397. # For a guide on how set the preferences, visit:
  398. # http://trac.transmissionbt.com/wiki/EditConfigFiles
  399. # For the available environement variables, visit:
  400. # http://trac.transmissionbt.com/wiki/EnvironmentVariables
  401. #
  402. # The name of the user that should run Transmission.
  403. # It's RECOMENDED to run Transmission in it's own user,
  404. # by default, this is set to 'transmission'.
  405. # For the sake of security you shouldn't set a password
  406. # on this user
  407. USERNAME=root
  408.  
  409.  
  410. # ----- *ADVANCED* CONFIGURATION -----
  411. # Only change these options if you know what you are doing!
  412. #
  413. # The folder where Transmission stores the config & web files.
  414. # ONLY change this you have it at a non-default location
  415. #TRANSMISSION_HOME="/var/config/transmission-daemon"
  416. #TRANSMISSION_WEB_HOME="/usr/share/transmission/web"
  417. #
  418. # The arguments passed on to transmission-daemon.
  419. # ONLY change this you need to, otherwise use the
  420. # settings file as per above.
  421. #TRANSMISSION_ARGS=""
  422.  
  423.  
  424. # ----- END OF CONFIGURATION -----
  425. #
  426. # PATH should only include /usr/* if it runs after the mountnfs.sh script.
  427. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  428. DESC="bittorrent client"
  429. NAME=transmission-daemon
  430. DAEMON=$(which $NAME)
  431. PIDFILE=/var/run/$NAME.pid
  432. SCRIPTNAME=/etc/init.d/$NAME
  433.  
  434. # Exit if the package is not installed
  435. [ -x "$DAEMON" ] || exit 0
  436.  
  437. # Read configuration variable file if it is present
  438. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  439.  
  440. # Load the VERBOSE setting and other rcS variables
  441. [ -f /etc/default/rcS ] && . /etc/default/rcS
  442.  
  443. #
  444. # Function that starts the daemon/service
  445. #
  446.  
  447. do_start()
  448. {
  449.     # Export the configuration/web directory, if set
  450.     if [ -n "$TRANSMISSION_HOME" ]; then
  451.           export TRANSMISSION_HOME
  452.     fi
  453.     if [ -n "$TRANSMISSION_WEB_HOME" ]; then
  454.           export TRANSMISSION_WEB_HOME
  455.     fi
  456.  
  457.     # Return
  458.     #   0 if daemon has been started
  459.     #   1 if daemon was already running
  460.     #   2 if daemon could not be started
  461.     start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
  462.             --exec $DAEMON --background --test -- -f $TRANSMISSION_ARGS > /dev/null \
  463.             || return 1
  464.     start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \
  465.             --exec $DAEMON --background -- -f $TRANSMISSION_ARGS \
  466.             || return 2
  467. }
  468.  
  469. #
  470. # Function that stops the daemon/service
  471. #
  472. do_stop()
  473. {
  474.         # Return
  475.         #   0 if daemon has been stopped
  476.         #   1 if daemon was already stopped
  477.         #   2 if daemon could not be stopped
  478.         #   other if a failure occurred
  479.         start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --exec $DAEMON
  480.         RETVAL="$?"
  481.         [ "$RETVAL" = 2 ] && return 2
  482.  
  483.         # Wait for children to finish too if this is a daemon that forks
  484.         # and if the daemon is only ever run from this initscript.
  485.         # If the above conditions are not satisfied then add some other code
  486.         # that waits for the process to drop all resources that could be
  487.         # needed by services started subsequently.  A last resort is to
  488.         # sleep for some time.
  489.  
  490.         start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  491.         [ "$?" = 2 ] && return 2
  492.  
  493.         # Many daemons don't delete their pidfiles when they exit.
  494.         rm -f $PIDFILE
  495.  
  496.         return "$RETVAL"
  497. }
  498.  
  499. case "$1" in
  500.   start)
  501.         echo "Starting $DESC" "$NAME..."
  502.         do_start
  503.         case "$?" in
  504.                 0|1) echo "   Starting $DESC $NAME succeeded" ;;
  505.                 *)   echo "   Starting $DESC $NAME failed" ;;
  506.         esac
  507.         ;;
  508.   stop)
  509.         echo "Stopping $DESC $NAME..."
  510.         do_stop
  511.         case "$?" in
  512.                 0|1) echo "   Stopping $DESC $NAME succeeded" ;;
  513.                 *)   echo "   Stopping $DESC $NAME failed" ;;
  514.         esac
  515.         ;;
  516.   restart|force-reload)
  517.         #
  518.         # If the "reload" option is implemented then remove the
  519.         # 'force-reload' alias
  520.         #
  521.         echo "Restarting $DESC $NAME..."
  522.         do_stop
  523.         case "$?" in
  524.           0|1)
  525.                 do_start
  526.                 case "$?" in
  527.                     0|1) echo "   Restarting $DESC $NAME succeeded" ;;
  528.                     *)   echo "   Restarting $DESC $NAME failed: couldn't start $NAME" ;;
  529.                 esac
  530.                 ;;
  531.           *)
  532.                 echo "   Restarting $DESC $NAME failed: couldn't stop $NAME" ;;
  533.         esac
  534.         ;;
  535.   *)
  536.         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  537.         exit 3
  538.         ;;
  539. esac
  540.  
  541. EOF
  542.  
  543. #Setting TRANSMISSION to auto startup
  544. printf "19/22 Configuring TRANSMISSION to auto startup"
  545. printf "$INITD" > /etc/init.d/transmission-daemon
  546. chmod +x /etc/init.d/transmission-daemon
  547. chown root:root /etc/init.d/transmission-daemon
  548. #Adding autostart to transmission
  549. update-rc.d transmission-daemon defaults >/dev/null 2>&1
  550. if [[ $? > 0 ]]
  551. then
  552.     echo "The command failed, exiting." ; exit
  553. else
  554.     echo " OK!"
  555. fi
  556.  
  557.  
  558. #Starting TRANSMISSION
  559. printf "20/22 Configuring TRANSMISSION settings.json"
  560. /etc/init.d/transmission-daemon start >/dev/null 2>&1
  561. if [[ $? > 0 ]]
  562. then
  563.     echo "The command failed, exiting." ; exit
  564. fi
  565.  
  566. #Wait transmission to create config files structure
  567. sleep 5
  568.  
  569. /etc/init.d/transmission-daemon stop >/dev/null 2>&1
  570. if [[ $? > 0 ]]
  571. then
  572.     echo "The command failed, exiting." ; exit
  573. fi
  574.  
  575. #configuring SETTINGS.JSON
  576. printf "$SETTINGSJSON" > /root/.config/transmission-daemon/settings.json
  577. echo " OK!"
  578.  
  579. printf "21/22 Cleaning temp files"
  580. #Cleaning temp files
  581. cp /etc/apt/sources.list /etc/apt/sources.list.new
  582. cat $TMPFOLDER/sources.list.bak > /etc/apt/sources.list
  583. rm -rf $TMPFOLDER
  584. apt-get clean
  585. echo " OK!"
  586.  
  587. #Starting TRANSMISSION
  588. printf "22/22 Starting TRANSMISSION"
  589. /etc/init.d/transmission-daemon start >/dev/null 2>&1
  590. if [[ $? > 0 ]]
  591. then
  592.     echo "The command failed, exiting." ; exit
  593. else
  594.     echo " OK!"
  595. fi
  596.  
  597.  
  598. end=$SECONDS
  599. echo "Total time: $((end - start)) secs."
  600. echo "Done!"
  601. echo "Cross your fingers and access http://mybooklive:9091/"
  602. echo "TODO: REMEMBER to configure: settings.json"
  603. echo ""
Add Comment
Please, Sign In to add comment