SHARE
TWEET

Install transmission bittorrent client on mybooklive - 2019

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