Guest User

Untitled

a guest
Dec 25th, 2015
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # dummy tox-node compilation and setup script by ru_maniac
  4. # please use with caution, as i'm very unexperienced at scripting
  5. # tested on Debian Jessie and Ubuntu 15.04
  6. # TODO: automate bootstrap nodes' list replacement
  7.  
  8. LINE="\n##############################################\n"
  9.  
  10. # main variables
  11. # for LANDISCOVERY, USEMOTD, VAUUM and TCPRELAY -- only true or false, unless you want for bad things to happen
  12.  
  13. LANDISCOVERY="false"
  14. TCPRELAY="true"
  15. USEMOTD="true"
  16. MOTD="ru_maniac's secondary bootstrap node"
  17. VACUUM="false"
  18.  
  19. service tox-bootstrapd stop && rm /etc/tox-bootstrapd.conf
  20.  
  21. if [ -z "$LANDISCOVERY" ]
  22. then
  23. echo -$LINE
  24. echo "LAN discovery settings variable is not set. Please fix this before running me\n$LINE"
  25. exit 1
  26. fi
  27.  
  28.  
  29. if [ -z "$TCPRELAY" ]
  30. then
  31. echo $LINE
  32. echo "TCP relay settings variable is not set. Please fix this before running me\n$LINE"
  33. exit 1
  34. fi
  35.  
  36.  
  37. if [ -z "$VACUUM" ]
  38. then
  39. echo $LINE
  40. echo "Cleaning option is not set. Please fix this before running me\n$LINE"
  41. exit 1
  42. fi
  43.  
  44. if [ -z "$USEMOTD" ]
  45. then
  46. echo $LINE
  47. echo "MOTD usage variable is not set. Please fix this before running me\n$LINE"
  48. exit 1
  49. fi
  50.  
  51. # installing prerequisites
  52. echo "$LINE"
  53. echo "Downloading and installing necessary packages...\n$LINE"
  54. apt-get -y install git build-essential libtool autotools-dev automake checkinstall check git yasm libsodium13 libsodium-dev libconfig-dev
  55.  
  56. # cloning into repo
  57. echo "$LINE"
  58. echo "Cloning into toxcore repo and downloading latest version...\n$LINE"
  59. git clone https://github.com/irungentoo/toxcore.git
  60. cd toxcore
  61.  
  62. # configuring the build
  63. echo $LINE
  64. echo "Configuring buildscript and compiling from source...\n$LINE"
  65. ./autogen.sh
  66. ./configure --enable-daemon
  67. make
  68. mkdir /usr/local/include
  69. checkinstall
  70. dpkg -i toxcore*.deb
  71.  
  72. # adding our user and creating settings file
  73. echo $LINE
  74. echo "Creating user for daemon and tweaking its privilegies...\n$LINE"
  75. useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "TOX DHT bootstrap daemon" --user-group tox-bootstrapd &> /dev/null
  76.  
  77. # adjusting privilegies
  78. chmod 700 /var/lib/tox-bootstrapd &> /dev/null
  79. cp other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf &> /dev/null
  80.  
  81. # adjusting LAN discovery, TCP relaying and deciding on MOTD usage
  82. if [ "$LANDISCOVERY" = "false" ]
  83.  
  84. then
  85. echo "\nDisabling LAN discovery for this node...\n"
  86. sed -ri 's/^enable_lan_discovery .*/enable_lan_discovery = false/' /etc/tox-bootstrapd.conf
  87. else
  88. echo -en "PLEASE NOTE: LAN discovery is enabled for this node. You can later adjust this by editing /etc/tox-bootstrapd.conf\n"
  89.  
  90. fi
  91.  
  92. if [ "$TCPRELAY" = "false" ]
  93.  
  94. then
  95. echo "\nDisabling fallback for TCP connections...\n"
  96. sed -ri 's/^enable_tcp_relay .*/enable_tcp_relay = false/' /etc/tox-bootstrapd.conf
  97. else
  98. echo -en "PLEASE NOTE: TCP-relaying is enabled for this node. You can later adjust this by editing /etc/tox-bootstrapd.conf\n"
  99.  
  100. fi
  101.  
  102. if [ "$USEMOTD" = "false" ]
  103.  
  104. then
  105. echo -en "\nDisabling MOTD message...\n"
  106. sed -ri 's/^enable_motd .*/enable_motd = false/' /etc/tox-bootstrapd.conf
  107. else
  108. echo -en "Adjusting MOTD as requested..\n."
  109. # adjusting MOTD
  110. sed -ri "s/^motd .*/motd = \"$MOTD\"/" /etc/tox-bootstrapd.conf
  111.  
  112. fi
  113.  
  114. # installing runscript
  115. echo $LINE
  116. echo "Installing runscript and rebuilding defaults file\n$LINE"
  117. cp other/bootstrap_daemon/tox-bootstrapd.sh /etc/init.d/tox-bootstrapd &> /dev/null
  118. chmod 755 /etc/init.d/tox-bootstrapd &> /dev/null
  119. update-rc.d tox-bootstrapd defaults
  120. ldconfig
  121. service tox-bootstrapd start
  122.  
  123. # checking if its running, and print message accordingly
  124. if pgrep "tox-bootstrapd" > /dev/null
  125.  
  126. then
  127. echo "$LINE"
  128. echo "Seems like everything went okay, and Tox bootstrap daemon is now running. Please review its config file located at /etc/tox-bootstrapd.conf, and adjust settings if necessary. Your node's public key can be found in output of tail -f /var/log/syslog|grep tox-bootstrapd command\n$LINE"
  129.  
  130. else
  131. echo $LINE
  132. echo "I couldnt fine Tox bootstrap daemon amongst active processes. Please try to run in manually via commanding service tox-bootstrapd start, while checking output of tail -f /var/log/syslog|grep tox-bootstrapd command\n$LINE"
  133.  
  134. fi
  135.  
  136. # removing toxcore directory with all the garbage left inside
  137.  
  138. if [ "$VACUUM" = "true" ]
  139.  
  140. then
  141. echo $LINE
  142. echo "Removing temporary build directory\n$LINE"
  143. rm -rf toxcore
  144. else
  145. echo $LINE
  146. echo "We are NOT removing toxcore directory with all the build garbage left inside. Please consider removing it manually\n$LINE"
  147.  
  148. fi
  149.  
  150. exit 0
RAW Paste Data