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.
 
 
 
 
 
 

107 lines
3.5 KiB

  1. #!/bin/bash
  2. set -e
  3. set -x
  4. #load dep exports
  5. #need to switch to game dir for Dockerfile weirdness
  6. original_dir=$PWD
  7. cd "$1"
  8. . dependencies.sh
  9. cd "$original_dir"
  10. #find out what we have (+e is important for this)
  11. set +e
  12. has_git="$(command -v git)"
  13. has_cargo="$(command -v ~/.cargo/bin/cargo)"
  14. has_sudo="$(command -v sudo)"
  15. has_cmake="$(command -v cmake)"
  16. has_gpp="$(command -v g++-6)"
  17. has_grep="$(command -v grep)"
  18. DATABASE_EXISTS="$(mysqlshow --host mariadb --port 3306 --user=root --password=$MYSQL_ROOT_PASSWORD ss13_db| grep -v Wildcard | grep -o ss13_db)"
  19. set -e
  20. # install cargo if needful
  21. if ! [ -x "$has_cargo" ]; then
  22. echo "Installing rust..."
  23. curl https://sh.rustup.rs -sSf | sh -s -- -y --default-host i686-unknown-linux-gnu
  24. . ~/.profile
  25. fi
  26. # apt packages
  27. if ! { [ -x "$has_git" ] && [ -x "$has_cmake" ] && [ -x "$has_gpp" ] && [ -x "$has_grep" ] && [ -f "/usr/lib/i386-linux-gnu/libmariadb.so.3" ] && [ -f "/usr/lib/i386-linux-gnu/libssl.so" ] && [ -d "/usr/share/doc/g++-6-multilib" ] && [ -f "/usr/bin/mysql" ] && [ -d "/usr/include/mysql" ]; }; then
  28. echo "Installing apt dependencies..."
  29. if ! [ -x "$has_sudo" ]; then
  30. dpkg --add-architecture i386
  31. apt-get update
  32. apt-get install -y git cmake libmariadb-dev:i386 libssl-dev:i386 grep g++-6 g++-6-multilib mysql-client
  33. ln -s /usr/include/mariadb /usr/include/mysql
  34. rm -rf /var/lib/apt/lists/*
  35. else
  36. sudo dpkg --add-architecture i386
  37. sudo apt-get update
  38. sudo apt-get install -y git cmake libmariadb-dev:i386 libssl-dev:i386 grep g++-6 g++-6-multilib mysql-client
  39. sudo ln -s /usr/include/mariadb /usr/include/mysql
  40. sudo rm -rf /var/lib/apt/lists/*
  41. fi
  42. fi
  43. #update rust-g
  44. if [ ! -d "rust-g" ]; then
  45. echo "Cloning rust-g..."
  46. git clone https://github.com/tgstation/rust-g
  47. else
  48. echo "Fetching rust-g..."
  49. cd rust-g
  50. git fetch
  51. cd ..
  52. fi
  53. #update BSQL
  54. if [ ! -d "BSQL" ]; then
  55. echo "Cloning BSQL..."
  56. git clone https://github.com/tgstation/BSQL
  57. else
  58. echo "Fetching BSQL..."
  59. cd BSQL
  60. git fetch
  61. cd ..
  62. fi
  63. echo "Deploying rust-g..."
  64. cd rust-g
  65. git checkout "$RUST_G_VERSION"
  66. ~/.cargo/bin/cargo build --release
  67. mv target/release/librust_g.so "$1/rust_g"
  68. cd ..
  69. echo "Deploying BSQL..."
  70. cd BSQL
  71. git checkout "$BSQL_VERSION"
  72. mkdir -p mysql
  73. mkdir -p artifacts
  74. cd artifacts
  75. cmake .. -DCMAKE_CXX_COMPILER=g++-6 -DMARIA_LIBRARY=/usr/lib/i386-linux-gnu/libmariadb.so.3
  76. make
  77. mv src/BSQL/libBSQL.so "$1/"
  78. cp /usr/lib/i386-linux-gnu/libmariadb.so.3 "$1/"
  79. cd ../..
  80. if [ ! -d "../GameStaticFiles/config" ]; then
  81. echo "Creating initial config..."
  82. cp -r "$1/config" "../GameStaticFiles/config"
  83. echo -e "SQL_ENABLED\nFEEDBACK_TABLEPREFIX SS13_\nADDRESS mariadb\nPORT 3306\nFEEDBACK_DATABASE ss13_db\nFEEDBACK_LOGIN root\nFEEDBACK_PASSWORD $MYSQL_ROOT_PASSWORD\nASYNC_QUERY_TIMEOUT 10\nBLOCKING_QUERY_TIMEOUT 5\nBSQL_THREAD_LIMIT 50" > "../GameStaticFiles/config/dbconfig.txt"
  84. echo "$TGS_ADMIN_CKEY = Host" > "../GameStaticFiles/config/admins.txt"
  85. fi
  86. if [ "$DATABASE_EXISTS" != "ss13_db" ]; then
  87. echo "Creating initial SS13 database..."
  88. mysql -u root --password=$MYSQL_ROOT_PASSWORD -h mariadb -P 3306 -e 'CREATE DATABASE IF NOT EXISTS ss13_db;'
  89. cat "$1/$TGS_PREFIXED_SCHEMA_FILE"
  90. mysql -u root --password=$MYSQL_ROOT_PASSWORD -h mariadb -P 3306 ss13_db < "$1/$TGS_PREFIXED_SCHEMA_FILE"
  91. mysql -u root --password=$MYSQL_ROOT_PASSWORD -h mariadb -P 3306 ss13_db -e "INSERT INTO \`SS13_schema_revision\` (\`major\`, \`minor\`) VALUES ($TGS_SCHEMA_MAJOR_VERSION, $TGS_SCHEMA_MINOR_VERSION)"
  92. fi
  93. #just trust me, i nearly lost my shit
  94. rm -rf "$1/byond-extools.dll"