Guest User

Untitled

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