Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.83 KB | None | 0 0
  1. #!/bin/bash
  2. echo "Welcome to dolphin's LynxChan install script!"
  3. script_version="1.0.8"
  4. new_version=$(curl "https://boxeddolphin.com/lynxchan/lynxchan_version_install_script" -s)
  5. script_name=`basename "$0"`
  6. distro_name=$(lsb_release -a | grep "Distributor ID:" > /tmp/distro_ver && sed -i "s/Distributor ID://g" /tmp/distro_ver && sed -i "s/No LSB modules are available.//g" /tmp/distro_ver && cat /tmp/distro_ver | tr -d " \t\n\r")
  7. front_ends=$(curl "https://boxeddolphin.com/lynxchan/front-ends")
  8. if [ "$script_version" != "$new_version" ]; then
  9. echo "Downloading update..."
  10. wget "https://boxeddolphin.com/install_lynxchan.sh" -O $script_name
  11. bash $script_name
  12. fi
  13. echo "What is your domain name, e.g. dolphin.com?"
  14. read domain
  15. echo "Where do you want LynxChan to be stored? I recommend /opt/LynxChan."
  16. read lynxchan_dir
  17. echo "What is your chan called?"
  18. read chan_name
  19. echo "Front-ends:"$front_ends
  20. echo "What is your chan's front-end?"
  21. read front_end
  22. echo "Enable tor? Answer 'yes' or 'no'"
  23. read tor_enabled
  24. function install_tor {
  25. mkdir /var/lib/tor/imageboard/ -p
  26. if [ "$distro_name" == "Debian" ]; then
  27. sudo apt install -y tor
  28. chown -R debian-tor:debian-tor /var/lib/tor/imageboard/
  29. chmod -R 700 /var/lib/tor/imageboard/
  30. fi
  31. if [ "$distro_name" == "Ubuntu" ]; then
  32. sudo apt install -y tor
  33. chown -R debian-tor:debian-tor /var/lib/tor/imageboard/
  34. chmod -R 700 /var/lib/tor/imageboard/
  35. fi
  36.  
  37. echo "
  38. HiddenServiceDir /var/lib/tor/imageboard/
  39. HiddenServicePort 80 127.0.0.1:8081
  40. " >> /etc/tor/torrc
  41. sudo systemctl restart tor
  42. }
  43. function install_mongodb {
  44. if [ "$distro_name" == "Debian" ]; then
  45. echo "Installing required packages for MongoDB!"
  46. sudo apt install -y gnupg wget nano
  47. wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
  48. echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
  49. sudo apt update
  50. sudo apt full-upgrade -y
  51. sudo apt install mongodb-org -y
  52. fi
  53. if [ "$distro_name" == "Ubuntu" ]; then
  54. echo "Installing required packages for MongoDB, then I will install MongoDB for you!"
  55. sudo apt install -y gnupg wget nano
  56. wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
  57. echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
  58. sudo apt update
  59. sudo apt full-upgrade -y
  60. sudo apt install mongodb-org -y
  61. sudo systemctl enable mongod && sudo systemctl start mongod
  62. fi
  63. }
  64. function install_nodejs {
  65. if [ "$distro_name" == "Debian" ]; then
  66. echo "Installing NodeJS..."
  67. curl -sL https://deb.nodesource.com/setup_13.x | bash -
  68. apt-get install -y nodejs
  69. apt-get install -y build-essential
  70. fi
  71. if [ "$distro_name" == "Ubuntu" ]; then
  72. echo "Installing NodeJS..."
  73. curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
  74. sudo apt-get install -y nodejs
  75. apt-get install -y build-essential
  76. fi
  77. }
  78. function install_lynxchan {
  79. if [ "$distro_name" == "Debian" ]; then
  80. echo "Installing LynxChan..."
  81. sudo apt install git gcc g++ file exiftool sendmail ffmpeg unzip python make cmake imagemagick libmagick++-dev -y
  82. sudo git clone https://gitgud.io/LynxChan/LynxChan.git $lynxchan_dir
  83. cd $lynxchan_dir
  84. sudo useradd --create-home -d $lynxchan_dir --system --shell /sbin/nologin node
  85. cd aux
  86. sudo cp lynxchan.systemd /etc/systemd/system/lynxchan.service
  87. sudo systemctl daemon-reload && sudo systemctl enable lynxchan.service && sudo systemctl start lynxchan.service
  88. cd ../src/be
  89. npm install
  90. cp -r settings.example settings
  91. if [ "$front_end" == "lynxchan" ]; then
  92. git clone https://gitgud.io/LynxChan/PenumbraLynx.git ../fe
  93. cd ../fe
  94. git checkout master
  95. find $lynxchan_dir/src/fe -type f -print0 | xargs -0 sed -i 's/Insert title here/'$chan_name'/g'
  96. find $lynxchan_dir/src/fe -type f -print0 | xargs -0 sed -i 's/Insert footer here/'$chan_name'/g'
  97. else
  98. mkdir $lynxchan_dir/src/fe -p
  99. wget https://boxeddolphin.com/lynxchan/frontends/$front_end.tar -O $lynxchan_dir/src/fe/$front_end.tar
  100. cd $lynxchan_dir/src/fe
  101. tar xvf $front_end.tar
  102. rm $front_end.tar
  103. find $lynxchan_dir/src/fe -type f -print0 | xargs -0 sed -i 's/DOLFINCHAN/'$chan_name'/g'
  104. fi
  105. sudo ln -s $lynxchan_dir/src/be/boot.js /usr/bin/lynxchan
  106. echo "Almost done installing LynxChan."
  107. echo "Copying config from the root server..."
  108. mkdir $lynxchan_dir/src/be/settings
  109. wget "https://boxeddolphin.com/lynxchan/lynxchan_general.json" -O $lynxchan_dir/src/be/settings/general.json
  110. echo "
  111. {
  112.  \"address\": \"localhost\",
  113.  \"port\": 27017,
  114.  \"db\": \"lynxchan\"
  115. }
  116. " > $lynxchan_dir/src/be/settings/db.json
  117. sudo chown -R node:node $lynxchan_dir
  118. sudo systemctl start mongod
  119. sudo systemctl enable mongod
  120. sudo -u node lynxchan -ca -l root -p "123!" -gr 0 -nd
  121. fi
  122. }
  123. function install_reverse_proxy {
  124. echo "Installed LynxChan. Going to install apache2 for the reverse proxy"
  125. sudo apt install -y apache2
  126. sudo wget "https://boxeddolphin.com/default_lynxchan.conf" -O /etc/apache2/sites-available/lynxchan.conf
  127. sudo a2enmod proxy
  128. sudo a2enmod ssl
  129. sudo a2enmod proxy_http
  130. sudo a2enmod proxy_https
  131. sudo a2enmod remoteip
  132. sudo a2enmod rewrite
  133. sudo a2ensite lynxchan.conf
  134. echo "Getting SSL cert"
  135. sudo apt install -y python3-certbot python-certbot-apache
  136. sudo certbot --manual --preferred-challenges dns certonly -d $domain
  137. sudo sed -i "s/mysite.com/$domain/g" /etc/apache2/sites-available/lynxchan.conf
  138. a2dissite 000-default
  139. sudo systemctl restart apache2.service
  140. }
  141.  
  142. install_mongodb
  143. install_nodejs
  144. install_lynxchan
  145. install_reverse_proxy
  146. if [ "$tor_enabled" == "yes" ]; then
  147. install_tor
  148. sleep 15
  149. tor_address=$(cat /var/lib/tor/imageboard/hostname)
  150. else
  151. tor_address="TOR NOT ENABLED!"
  152. echo "No tor :("
  153. fi
  154. echo "Starting LynxChan. Default login is root/123!"
  155. sudo chown -R node:node $lynxchan_dir
  156. sudo systemctl start lynxchan
  157.  
  158. echo "Tor address: $tor_address"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement