Auto Ripple Installer. Easily Setup Ripple Server. Mirror: https://github.com/Uniminin/Ripple-Auto-Installer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ripple_installer.sh 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. #!/bin/bash
  2. clear
  3. # THIS SCRIPT IS ORIGINALLY FROM SUNPY #
  4. # Edited and made better by Aoba Suzukaze (Hazuki) with a bit of Uniminin's Edit.
  5. printf "This script has to run in sudo mode.\nIf this isn't the case CTRL+C now.\nAlso please don't install this in /root/ but whatever I installed it but I don't really care anyway.\nThis is also meant to be used on a fresh Ubuntu 16.04 install but you can use other OS anyway because this creates a new database etc.\nThis installer is simplistic as its just something I put together so I could easily recreate the server once things change or when I move server around for testing etc.\n\t- Aoba\n"
  6. server-install () {
  7. valid_domain=0
  8. printf "\nInstall directory "[$(pwd)"/ripple"]": "
  9. read MasterDir
  10. MasterDir=${MasterDir:=$(pwd)"/ripple"}
  11. printf "\n\n..:: NGINX CONFIGS ::.."
  12. while [ $valid_domain -eq 0 ]
  13. do
  14. printf "\nMain domain name: "
  15. read domain
  16. if [ "$domain" = "" ]; then
  17. printf "\n\nYou need to specify the main domain. Example: cookiezi.pw"
  18. else
  19. printf "\n\nFrontend: $domain"
  20. printf "\nBancho: c.$domain"
  21. printf "\nAvatar: a.$domain"
  22. printf "\nBackend: old.$domain"
  23. printf "\n\nIs this configuration correct? [y/n]: "
  24. read q
  25. if [ "$q" = "y" ]; then
  26. valid_domain=1
  27. fi
  28. fi
  29. done
  30. printf "\n\n..:: BANCHO SERVER ::.."
  31. printf "\ncikey [changeme]: "
  32. read peppy_cikey
  33. peppy_cikey=${peppy_cikey:=changeme}
  34. printf "\n\n..:: LETS SERVER::.."
  35. printf "\nosuapi-apikey [YOUR_OSU_API_KEY_HERE]: "
  36. read lets_osuapikey
  37. lets_osuapikey=${lets_osuapikey:=YOUR_OSU_API_KEY_HERE}
  38. printf "\nPP Cap [700]: "
  39. read pp_cap
  40. pp_cap=${pp_cap:=700}
  41. printf "\n\n..:: FRONTEND ::.."
  42. printf "\nPort [6969]: "
  43. read hanayo_port
  44. hanayo_port=${hanayo_port:=6969}
  45. printf "\nAPI Secret [Potato]: "
  46. read hanayo_apisecret
  47. hanayo_apisecret=${hanayo_apisecret:=Potato}
  48. printf "\n\n..:: DATABASE ::.."
  49. printf "\nUsername [root]: "
  50. read mysql_usr
  51. mysql_usr=${mysql_usr:=root}
  52. printf "\nPassword [meme]: "
  53. read mysql_psw
  54. mysql_psw=${mysql_psw:=meme}
  55. printf "\n\nAlright! Let's see what I can do here...\n\n"
  56. # Configuration is done.
  57. # Start installing/downloading/setup
  58. START=$(date +%s)
  59. echo "Installing dependencies..."
  60. apt-get update
  61. ## SOME UPDATES FOR GCP VPSES OR OTHER VPS PROVIDER
  62. sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev -y
  63. sudo add-apt-repository ppa:deadsnakes/ppa -y
  64. sudo apt-get update
  65. apt-get install python3 python3-dev -y
  66. add-apt-repository ppa:ondrej/php -y
  67. add-apt-repository ppa:longsleep/golang-backports -y
  68. apt-get update
  69. apt install git curl python3-pip python3-mysqldb -y
  70. apt-get install python-dev libmysqlclient-dev nginx software-properties-common libssl-dev mysql-server -y
  71. pip3 install --upgrade pip
  72. pip3 install flask
  73. apt-get install php7.0 php7.0-mbstring php7.0-mcrypt php7.0-fpm php7.0-curl php7.0-mysql golang-go -y
  74. apt-get install composer -y
  75. apt-get install zip unzip php7.0-zip -y
  76. echo "Done installing dependencies!"
  77. mkdir ripple
  78. cd ripple
  79. echo "Downloading Bancho server..."
  80. cd $MasterDir
  81. git clone https://zxq.co/ripple/pep.py
  82. cd pep.py
  83. git submodule init && git submodule update
  84. python3.6 -m pip install -r requirements.txt
  85. python3.6 setup.py build_ext --inplace
  86. python3.6 pep.py
  87. sed -i 's#root#'$mysql_usr'#g; s#changeme#'$peppy_cikey'#g'; s#http://.../letsapi#'http://127.0.0.1:5002/letsapi'#g; s#http://cheesegu.ll/api#'https://cg.mxr.lol/api'#g' config.ini
  88. sed -E -i -e 'H;1h;$!d;x' config.ini -e 's#password = #password = '$mysql_psw'#'
  89. cd $MasterDir
  90. echo "Bancho Server setup is done!"
  91. echo "Setting up LETS server & oppai..."
  92. git clone https://zxq.co/ripple/lets
  93. cd lets
  94. python3.6 -m pip install -r requirements.txt
  95. echo "Downloading patches"
  96. cd pp
  97. rm -rf oppai-ng/
  98. git clone https://github.com/Francesco149/oppai-ng
  99. cd oppai-ng
  100. ./build
  101. cd ..
  102. rm -rf catch_the_pp/
  103. git clone https://github.com/osuripple/catch-the-pp
  104. mv catch-the-pp/ catch_the_pp/
  105. rm -rf __init__.py
  106. wget -O __init__.py https://pastebin.com/raw/gKaPU6C6
  107. wget -O wifipiano2.py https://pastebin.com/raw/ZraV7iU9
  108. cd ..
  109. #IT WAS A STUPID IDEA TO COPY COMMON FROM PEP.PY
  110. rm -rf common
  111. git clone https://zxq.co/ripple/ripple-python-common
  112. mv ripple-python-common/ common/
  113. cd $MasterDir/lets/handlers
  114. sed -i 's#700#'$pp_cap'#g' submitModularHandler.pyx
  115. # difficulty_ctb fix
  116. cd $MasterDir/lets/objects
  117. sed -i 's#dataCtb["difficultyrating"]#'dataCtb["diff_aim"]'#g' beatmap.pyx
  118. cd $MasterDir/lets
  119. git clone https://github.com/osufx/secret
  120. cd secret
  121. git submodule init && git submodule update
  122. cd ..
  123. python3.6 setup.py build_ext --inplace
  124. cd helpers
  125. rm -rf config.py
  126. wget -O config.py https://pastebin.com/raw/E0zUvLuU
  127. sed -i 's#root#'$mysql_usr'#g; s#mysqlpsw#'$mysql_psw'#g; s#DOMAIN#'$domain'#g; s#changeme#'$peppy_cikey'#g; s#YOUR_OSU_API_KEY_HERE#'$lets_osuapikey'#g; s#http://cheesegu.ll/api#'https://cg.mxr.lol/api'#g' config.py
  128. cd $MasterDir
  129. echo "LETS Server setup is done!"
  130. echo "Installing Redis..."
  131. apt-get install redis-server -y
  132. echo "REDIS Server setup is done!"
  133. echo "Downloading nginx config..."
  134. mkdir nginx
  135. cd nginx
  136. systemctl restart php7.0-fpm
  137. pkill -f nginx
  138. cd /etc/nginx/
  139. rm -rf nginx.conf
  140. wget -O nginx.conf https://pastebin.com/raw/9aduuq4e
  141. sed -i 's#include /root/ripple/nginx/*.conf\*#include '$MasterDir'/nginx/*.conf#' /etc/nginx/nginx.conf
  142. cd $MasterDir
  143. cd nginx
  144. wget -O nginx.conf https://pastebin.com/raw/B4hWMmZn
  145. sed -i 's#DOMAIN#'$domain'#g; s#DIRECTORY#'$MasterDir'#g; s#6969#'$hanayo_port'#g' nginx.conf
  146. wget -O old-frontend.conf https://pastebin.com/raw/bMXE2m6n
  147. sed -i 's#DOMAIN#'$domain'#g; s#DIRECTORY#'$MasterDir'#g; s#6969#'$hanayo_port'#g' old-frontend.conf
  148. echo "Downloading certificate..."
  149. wget -O cert.pem https://github.com/Uniminin/Ripple-Auto-Installer/blob/master/X/cert.pem
  150. wget -O key.pem https://github.com/Uniminin/Ripple-Auto-Installer/blob/master/X/key.key
  151. echo "Certificate downloaded!"
  152. pkill -f nginx
  153. nginx
  154. cd $MasterDir
  155. echo "NGINX server setup is done!"
  156. echo "Setting up database..."
  157. # Download SQL folder
  158. wget -O ripple.sql https://raw.githubusercontent.com/Uniminin/Ripple-Auto-Installer/master/Database%20files/ripple_database.sql
  159. mysql -u "$mysql_usr" -p"$mysql_psw" -e 'CREATE DATABASE ripple;'
  160. mysql -u "$mysql_usr" -p"$mysql_psw" ripple < ripple.sql
  161. echo "Database setup is done!"
  162. echo "Setting up hanayo..."
  163. mkdir hanayo
  164. cd hanayo
  165. go get -u zxq.co/ripple/hanayo
  166. mv /root/go/bin/hanayo ./
  167. mv /root/go/src/zxq.co/ripple/hanayo/data ./data
  168. mv /root/go/src/zxq.co/ripple/hanayo/scripts ./scripts
  169. mv /root/go/src/zxq.co/ripple/hanayo/static ./static
  170. mv /root/go/src/zxq.co/ripple/hanayo/templates ./templates
  171. mv /root/go/src/zxq.co/ripple/hanayo/website-docs ./website-docs
  172. sed -i 's#ripple.moe#'$domain'#' templates/navbar.html
  173. ./hanayo
  174. sed -i 's#ListenTo=#ListenTo=127.0.0.1:'$hanayo_port'#g; s#AvatarURL=#AvatarURL=https://a.'$domain'#g; s#BaseURL=#BaseURL=https://'$domain'#g; s#APISecret=#APISecret='$hanayo_apisecret'#g; s#BanchoAPI=#BanchoAPI=https://c.'$domain'#g; s#MainRippleFolder=#MainRippleFolder='$MasterDir'#g; s#AvatarFolder=#AvatarFolder='$MasterDir'/nginx/avatar-server/avatars#g; s#RedisEnable=false#RedisEnable=true#g' hanayo.conf
  175. sed -E -i -e 'H;1h;$!d;x' hanayo.conf -e 's#DSN=#DSN='$mysql_usr':'$mysql_psw'@/ripple#'
  176. sed -E -i -e 'H;1h;$!d;x' hanayo.conf -e 's#API=#API=http://localhost:40001/api/v1/#'
  177. cd $MasterDir
  178. echo "Hanayo setup is done!"
  179. echo "Setting up API..."
  180. mkdir rippleapi
  181. cd rippleapi
  182. go get -u zxq.co/ripple/rippleapi
  183. #Ugly fix?
  184. rm -rf /root/go/src/zxq.co/ripple
  185. mv /root/go/src/zxq.co/rippleapi /root/go/src/zxq.co/ripple
  186. go build zxq.co/ripple/rippleapi
  187. mv /root/go/bin/rippleapi ./
  188. ./rippleapi
  189. sed -i 's#root@#'$mysql_usr':'$mysql_psw'@#g; s#Potato#'$hanayo_apisecret'#g; s#OsuAPIKey=#OsuAPIKey='$peppy_cikey'#g' api.conf
  190. cd $MasterDir
  191. echo "API setup is done!"
  192. echo "Setting up avatar server..."
  193. go get -u zxq.co/Sunpy/avatar-server-go
  194. mkdir avatar-server
  195. mkdir avatar-server/avatars
  196. mv /root/go/bin/avatar-server-go ./avatar-server/avatar-server
  197. cd $MasterDir/avatar-server/avatars
  198. # DEFAULT AVATAR
  199. wget -O 0.png https://github.com/Uniminin/Ripple-Auto-Installer/blob/master/X/null.png
  200. # AC AVATAR
  201. wget -O 999.png https://github.com/Uniminin/Ripple-Auto-Installer/blob/master/X/ac.png
  202. cd $MasterDir
  203. echo "Avatar Server setup is done!"
  204. echo "Setting up backend..."
  205. cd /var/www/
  206. git clone https://zxq.co/ripple/old-frontend.git
  207. mv old-frontend osu.ppy.sh
  208. cd osu.ppy.sh
  209. curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  210. cd inc
  211. cp config.sample.php config.php
  212. sed -i 's#root#'$mysql_usr'#g; s#meme#'$mysql_psw'#g; s#allora#ripple#g; s#ripple.moe#'$domain'#g' config.php
  213. cd ..
  214. composer install
  215. rm -rf secret
  216. git clone https://github.com/osufx/secret.git
  217. cd $MasterDir
  218. echo "Backend server is done!"
  219. echo "Setting up PhpMyAdmin..."
  220. apt-get install phpmyadmin -y
  221. cd /var/www/osu.ppy.sh
  222. ln -s /usr/share/phpmyadmin phpmyadmin
  223. echo "PhpMyAdmin setup is done!"
  224. echo "Making up certificate for SSL"
  225. cd /root/
  226. git clone https://github.com/Neilpang/acme.sh
  227. apt-get install socat -y
  228. cd acme.sh/
  229. ./acme.sh --install
  230. ./acme.sh --issue --standalone -d $domain -d c.$domain -d i.$domain -d a.$domain -d old.$domain
  231. echo "Certificate is ready!"
  232. echo "Changing folder and files permissions"
  233. chmod -R 777 ../ripple
  234. END=$(date +%s)
  235. DIFF=$(( $END - $START ))
  236. nginx
  237. echo "Setup is done... but I guess it's still indevelopment. It took $DIFF seconds. To setup the server!"
  238. echo "You can access PhpMyAdmin here... http://old.$domain/phpmyadmin"
  239. printf "\n\nDo you like our installer? [y/n]: "
  240. read q
  241. if [ "$q" = "y" ]; then
  242. printf "\n\nWell... It just a fake message but thanks! You can start the server now.\n\nAlright! See you later in the next server!\n\n"
  243. fi
  244. }
  245. echo ""
  246. echo "IMPORTANT: Ripple is licensed under the GNU AGPL license. This means, if your server is public, that ANY modification made to the original ripple code MUST be publically available."
  247. echo "Also, to run an osu! private server, as well as any sort of server, you need to have minimum knowledge of command line, and programming."
  248. echo "Running this script assumes you know how to use Linux in command line, secure and manage a server, and that you know how to fix errors, as they might happen while running that code."
  249. echo "Do you agree? (y/n)"
  250. read answer
  251. if [ "$answer" != "${answer#[Yy]}" ] ;then
  252. echo Continuing
  253. server-install
  254. else
  255. echo Exiting
  256. fi