Start-Linux.sh 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #!/bin/bash
  2. exec 0</dev/tty
  3. RED=$(tput setaf 1)
  4. NC=$(tput sgr0) # No Color
  5. function pause() {
  6. read -r -s -n 1 -p "Press any key to continue . . ."
  7. echo ""
  8. }
  9. function start() {
  10. clear
  11. echo ""
  12. echo "OpenRSC: Striving for a replica RSC game and more
  13. What would you like to do?
  14. Choices:
  15. ${RED}1${NC} - Compile and start the game
  16. ${RED}2${NC} - Start the game (faster if already compiled)
  17. ${RED}3${NC} - Change a player's in-game role
  18. ${RED}4${NC} - Change a player's name
  19. ${RED}5${NC} - Backup database
  20. ${RED}6${NC} - Restore database
  21. ${RED}7${NC} - Perform a fresh install
  22. ${RED}8${NC} - Exit"
  23. echo ""
  24. echo "Type the choice number and press enter."
  25. echo ""
  26. read -r action
  27. clear
  28. if [ "$action" == "1" ]; then # Compile and start the game
  29. echo "Starting OpenRSC."
  30. make compile
  31. pause
  32. echo "What would you like to do?
  33. Choices:
  34. ${RED}1${NC} - Start single player edition (launch client and server)
  35. ${RED}2${NC} - Start the server only (public hosting)"
  36. read -r start
  37. if [ "$start" == "1" ]; then
  38. make run-server && sleep 5 && make run-client
  39. elif [ "$start" == "2" ]; then
  40. make run-server
  41. fi
  42. clear
  43. pause
  44. start
  45. elif [ "$action" == "2" ]; then # Start the game (faster if already compiled)
  46. echo "What would you like to do?
  47. Choices:
  48. ${RED}1${NC} - Start single player edition (launch client and server)
  49. ${RED}2${NC} - Start the server only (public hosting)"
  50. read -r start
  51. if [ "$start" == "1" ]; then
  52. make run-server && sleep 5 && make run-client
  53. elif [ "$start" == "2" ]; then
  54. make run-server
  55. fi
  56. echo ""
  57. pause
  58. start
  59. elif [ "$action" == "3" ]; then # Change a player's in-game role
  60. echo "Make sure you are logged out first!"
  61. echo "Type the username of the player you wish to set and press enter."
  62. echo ""
  63. read -r username
  64. clear
  65. echo "What role should the player be set to?
  66. Choices:
  67. ${RED}1${NC} - Admin
  68. ${RED}2${NC} - Mod
  69. ${RED}10${NC} - Player (default)"
  70. read -r group
  71. echo "Type the name of the database where the player is saved."
  72. echo ""
  73. echo "(preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
  74. echo ""
  75. echo "The default player database is named preservation."
  76. echo ""
  77. echo ""
  78. read -r db
  79. clear
  80. echo "Which database are you using?
  81. Choices:
  82. ${RED}1${NC} - SQLite (default)
  83. ${RED}2${NC} - MariaDB (production game hosting)"
  84. read -r sql
  85. if [ "$sql" == "1" ]; then
  86. make rank-sqlite db=$db group=$group username=$username
  87. elif [ "$sql" == "2" ]; then
  88. make rank-mariadb db=$db group=$group username=$username
  89. fi
  90. clear
  91. echo "$username has been made group role $group in database $db!"
  92. pause
  93. start
  94. elif [ "$action" == "4" ]; then # Change a player's name
  95. echo "Make sure you are logged out first!"
  96. echo "What existing player should have their name changed?"
  97. echo ""
  98. read -r oldname
  99. echo ""
  100. echo "What would you like to change $oldname's name to?"
  101. echo ""
  102. read -r newname
  103. clear
  104. echo "Type the name of the database where the player is saved."
  105. echo ""
  106. echo "(preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
  107. echo ""
  108. echo "The default player database is named preservation."
  109. echo ""
  110. echo ""
  111. read -r db
  112. clear
  113. echo "Which database are you using?
  114. Choices:
  115. ${RED}1${NC} - SQLite (default)
  116. ${RED}2${NC} - MariaDB (production game hosting)"
  117. read -r sql
  118. if [ "$sql" == "1" ]; then
  119. make namechange-sqlite db=$db oldname=$oldname newname=$newname
  120. elif [ "$sql" == "2" ]; then
  121. make namechange-mariadb db=$db oldname=$oldname newname=$newname
  122. fi
  123. clear
  124. echo "$oldname has been renamed to $newname!"
  125. pause
  126. start
  127. elif [ "$action" == "5" ]; then # Backup database
  128. echo "Type the name of the database that you wish to backup."
  129. echo ""
  130. echo "(preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
  131. echo ""
  132. echo "The default player database is named preservation."
  133. echo ""
  134. read -r db
  135. clear
  136. echo "Which database are you using?
  137. Choices:
  138. ${RED}1${NC} - SQLite (default)
  139. ${RED}2${NC} - MariaDB (production game hosting)"
  140. read -r sql
  141. if [ "$sql" == "1" ]; then
  142. make backup-sqlite-local db=$db
  143. elif [ "$sql" == "2" ]; then
  144. make backup-mariadb-local db=$db
  145. fi
  146. clear
  147. echo "Database $db backup complete."
  148. pause
  149. start
  150. elif [ "$action" == "6" ]; then # Restore database
  151. echo "==========================================================================="
  152. ls Backups
  153. echo "==========================================================================="
  154. echo ""
  155. echo "Type the filename of the backup file listed above that you wish to restore."
  156. echo "(Copy and paste it exactly, including the .zip file extension)"
  157. echo ""
  158. read -r filename
  159. clear
  160. echo "Which database should this be restored to? (preservation, openrsc, cabbage, uranium, coleslaw, 2001scape, or openpk)"
  161. echo ""
  162. read -r db
  163. clear
  164. echo "Which database are you using?
  165. Choices:
  166. ${RED}1${NC} - SQLite (default)
  167. ${RED}2${NC} - MariaDB (production game hosting)"
  168. read -r sql
  169. if [ "$sql" == "1" ]; then
  170. make restore-sqlite-local name=$filename db=$db
  171. elif [ "$sql" == "2" ]; then
  172. make restore-mariadb-local name=$filename db=$db
  173. fi
  174. clear
  175. echo "File $filename was restored to database $db."
  176. echo ""
  177. pause
  178. start
  179. elif [ "$action" == "7" ]; then # Perform a fresh install
  180. clear
  181. echo "Are you ABSOLUTELY SURE that you want to perform a fresh install and reset any existing game databases?"
  182. echo ""
  183. echo "To confirm the database reset, type yes and press enter."
  184. echo ""
  185. read -r confirmwipe
  186. echo ""
  187. if [ "$confirmwipe" == "yes" ]; then
  188. clear
  189. echo "Which database are you using?
  190. Choices:
  191. ${RED}1${NC} - SQLite (default)
  192. ${RED}2${NC} - MariaDB (production game hosting)"
  193. read -r sql
  194. if [ "$sql" == "1" ]; then
  195. make import-authentic-sqlite db=preservation
  196. make import-authentic-sqlite db=openrsc
  197. make import-authentic-sqlite db=uranium
  198. make import-custom-sqlite db=cabbage
  199. make import-custom-sqlite db=coleslaw
  200. make import-custom-sqlite db=openpk
  201. make import-retro-sqlite db=2001scape
  202. elif [ "$sql" == "2" ]; then
  203. make import-authentic-mariadb db=preservation
  204. make import-authentic-mariadb db=openrsc
  205. make import-authentic-mariadb db=uranium
  206. make import-custom-mariadb db=cabbage
  207. make import-custom-mariadb db=coleslaw
  208. make import-custom-mariadb db=openpk
  209. make import-retro-mariadb db=2001scape
  210. fi
  211. else
  212. echo "Error! $confirmwipe is not a valid option."
  213. pause
  214. start
  215. fi
  216. elif [ "$action" == "8" ]; then # Exits
  217. exit
  218. fi
  219. }
  220. while true; do
  221. start
  222. done