daily pastebin goal
17%
SHARE
TWEET

Install transmission bittorrent client on mybooklive - 2019

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