Yu-Gi-Oh! Deck Building and Card Inventory Management web interface written in Common Lisp, utilizing HTMX.
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.

124 lines
3.2KB

  1. #!/bin/bash
  2. # Start some stuff: Sidekiq Web UI, collectd web UI, MariaDB container, Redis container.
  3. #
  4. # Looks like shell scripts are also going into here. You may additionally backup_database.
  5. #
  6. # Hey it's starting to turn into a real deploy script!
  7. set -euox
  8. DOCKER=podman
  9. MARIADB_IMAGE=localhost/alpine-mariadb
  10. REDIS_IMAGE=localhost/redis-7.2-rc-alpine
  11. SCHEMACRAWLER_DIR=$HOME/schemacrawler-16.20.4-bin
  12. function message(){
  13. plus="+"
  14. [[ $1 -ne 0 ]] && plus=-
  15. shift
  16. echo "[${plus}] $@"
  17. }
  18. # This will probably either go away or be moved to mariadb database as we migrate (eventually)
  19. function backup_database() {
  20. shift
  21. running_container=
  22. if [ $# -eq 0 ]
  23. then
  24. running_container=$(${DOCKER} ps --format '{{.Image}} {{.Names}}' | grep cl-deck-builder2 | awk '{print $2}')
  25. else
  26. running_container="$1"
  27. fi
  28. if [ "x$running_container" = "x" ]
  29. then
  30. message 1 "deck builder container not running?"
  31. else
  32. message 0 "found $running_container"
  33. message 0 "copying database $running_container:/home/quicklisp/quicklisp/local-projects/cl-deck-builder2/deck_builder.sqlite3"
  34. $DOCKER cp "$running_container:/home/quicklisp/quicklisp/local-projects/cl-deck-builder2/deck_builder.sqlite3" \
  35. ~/sqlite3/$(date '+%Y-%m-%d')-deck_builder.sqlite3
  36. ls -l ~/sqlite3/$(date '+%Y-%m-%d')-deck_builder.sqlite3
  37. fi
  38. }
  39. function psychiq_up(){
  40. ps -C rackup >/dev/null
  41. if [ $? -ne 0 ]
  42. then
  43. message 0 "Starting Psychiq Web UI"
  44. rackup /home/user/code/cl-deck-builder2/ruby/config.ru &
  45. else
  46. message 1 "Psychiq Web UI already running."
  47. fi
  48. }
  49. function collectd_up() {
  50. ps -C python3 >/dev/null
  51. if [ $? -ne 0 ]
  52. then
  53. message 0 "Starting collectd Web UI"
  54. pushd /home/user/code/alpine-collectd-web/
  55. python3 runserver.py &
  56. popd
  57. else
  58. message 1 "collectd Web UI already running."
  59. fi
  60. }
  61. function mariadb_up (){
  62. mkdir -p ~/mariadb
  63. $DOCKER ps 2>&1| grep 3306 2>&1>/dev/null
  64. if [ $? -ne 0 ]
  65. then
  66. $DOCKER run --restart always -d -P -p 3306:3306 -v $HOME/mariadb:/var/lib/mysql $MARIADB_IMAGE
  67. else
  68. message 1 "mariadb already running."
  69. fi
  70. }
  71. function redis_up(){
  72. mkdir -p ~/redis
  73. $DOCKER ps 2>&1| grep 6379 2>&1>/dev/null
  74. if [ $? -ne 0 ]
  75. then
  76. $DOCKER run --restart always -d -P -p 6379:6379 -v $HOME/redis:/data $REDIS_IMAGE
  77. else
  78. message 1 "redis already running."
  79. fi
  80. }
  81. function schemacrawler(){
  82. ORIG_DIR="$(pwd)"
  83. cd $SCHEMACRAWLER_DIR
  84. # Gentoo Strikes Again!
  85. # https://github.com/schemacrawler/SchemaCrawler/issues/394
  86. _JAVA_OPTIONS=-Djava.io.tmpdir=. \
  87. bash bin/schemacrawler.sh \
  88. --user= \
  89. --password= \
  90. --database "$ORIG_DIR/deck_builder.sqlite3" \
  91. --server sqlite \
  92. --weak-associations=true \
  93. -i standard \
  94. -c schema \
  95. -o ~/www/db.png
  96. chown :www-data ~/www/db.png
  97. }
  98. function main(){
  99. # backup_database
  100. psychiq_up
  101. collectd_up
  102. mariadb_up
  103. redis_up
  104. }
  105. if [ $# -lt 1 ]
  106. then
  107. message 1 "Usage: $0 [main | backup_database | psychiq_up | collectd_up | mariadb_up | redis_up | schemacrawler]"
  108. else
  109. "$1" "$@"
  110. fi