Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # dummy tox-node compilation and setup script by ru_maniac
- # please use with caution, as i'm very unexperienced at scripting
- # tested on Debian Jessie and Ubuntu 15.04
- # TODO: automate bootstrap nodes' list replacement
- LINE="\n##############################################\n"
- # main variables
- # for LANDISCOVERY, USEMOTD, VAUUM and TCPRELAY -- only true or false, unless you want for bad things to happen
- LANDISCOVERY="false"
- TCPRELAY="true"
- USEMOTD="true"
- MOTD="ru_maniac's secondary bootstrap node"
- VACUUM="false"
- service tox-bootstrapd stop && rm /etc/tox-bootstrapd.conf
- if [ -z "$LANDISCOVERY" ]
- then
- echo -$LINE
- echo "LAN discovery settings variable is not set. Please fix this before running me\n$LINE"
- exit 1
- fi
- if [ -z "$TCPRELAY" ]
- then
- echo $LINE
- echo "TCP relay settings variable is not set. Please fix this before running me\n$LINE"
- exit 1
- fi
- if [ -z "$VACUUM" ]
- then
- echo $LINE
- echo "Cleaning option is not set. Please fix this before running me\n$LINE"
- exit 1
- fi
- if [ -z "$USEMOTD" ]
- then
- echo $LINE
- echo "MOTD usage variable is not set. Please fix this before running me\n$LINE"
- exit 1
- fi
- # installing prerequisites
- echo "$LINE"
- echo "Downloading and installing necessary packages...\n$LINE"
- apt-get -y install git build-essential libtool autotools-dev automake checkinstall check git yasm libsodium13 libsodium-dev libconfig-dev
- # cloning into repo
- echo "$LINE"
- echo "Cloning into toxcore repo and downloading latest version...\n$LINE"
- git clone https://github.com/irungentoo/toxcore.git
- cd toxcore
- # configuring the build
- echo $LINE
- echo "Configuring buildscript and compiling from source...\n$LINE"
- ./autogen.sh
- ./configure --enable-daemon
- make
- mkdir /usr/local/include
- checkinstall
- dpkg -i toxcore*.deb
- # adding our user and creating settings file
- echo $LINE
- echo "Creating user for daemon and tweaking its privilegies...\n$LINE"
- useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "TOX DHT bootstrap daemon" --user-group tox-bootstrapd &> /dev/null
- # adjusting privilegies
- chmod 700 /var/lib/tox-bootstrapd &> /dev/null
- cp other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf &> /dev/null
- # adjusting LAN discovery, TCP relaying and deciding on MOTD usage
- if [ "$LANDISCOVERY" = "false" ]
- then
- echo "\nDisabling LAN discovery for this node...\n"
- sed -ri 's/^enable_lan_discovery .*/enable_lan_discovery = false/' /etc/tox-bootstrapd.conf
- else
- echo -en "PLEASE NOTE: LAN discovery is enabled for this node. You can later adjust this by editing /etc/tox-bootstrapd.conf\n"
- fi
- if [ "$TCPRELAY" = "false" ]
- then
- echo "\nDisabling fallback for TCP connections...\n"
- sed -ri 's/^enable_tcp_relay .*/enable_tcp_relay = false/' /etc/tox-bootstrapd.conf
- else
- echo -en "PLEASE NOTE: TCP-relaying is enabled for this node. You can later adjust this by editing /etc/tox-bootstrapd.conf\n"
- fi
- if [ "$USEMOTD" = "false" ]
- then
- echo -en "\nDisabling MOTD message...\n"
- sed -ri 's/^enable_motd .*/enable_motd = false/' /etc/tox-bootstrapd.conf
- else
- echo -en "Adjusting MOTD as requested..\n."
- # adjusting MOTD
- sed -ri "s/^motd .*/motd = \"$MOTD\"/" /etc/tox-bootstrapd.conf
- fi
- # installing runscript
- echo $LINE
- echo "Installing runscript and rebuilding defaults file\n$LINE"
- cp other/bootstrap_daemon/tox-bootstrapd.sh /etc/init.d/tox-bootstrapd &> /dev/null
- chmod 755 /etc/init.d/tox-bootstrapd &> /dev/null
- update-rc.d tox-bootstrapd defaults
- ldconfig
- service tox-bootstrapd start
- # checking if its running, and print message accordingly
- if pgrep "tox-bootstrapd" > /dev/null
- then
- echo "$LINE"
- 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"
- else
- echo $LINE
- 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"
- fi
- # removing toxcore directory with all the garbage left inside
- if [ "$VACUUM" = "true" ]
- then
- echo $LINE
- echo "Removing temporary build directory\n$LINE"
- rm -rf toxcore
- else
- echo $LINE
- echo "We are NOT removing toxcore directory with all the build garbage left inside. Please consider removing it manually\n$LINE"
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement