Proglin

Compile and Install transmission bittorrent client on mybook

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