eiru-bootup.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/bash
  2. NET_NAME="eiru"
  3. ODOO_IMAGE="odoo/eiru:1.4"
  4. ODOO_PATH="/srv/odoo"
  5. DB_CONTAINER="database"
  6. DB_CONTAINER_PROXY="pgbouncer"
  7. ODOO_SYSTEMS="golden \
  8. athletic \
  9. topjeans \
  10. kava \
  11. amojeans \
  12. world \
  13. clasi_calse \
  14. tuspasos"
  15. start_database_system()
  16. {
  17. # start postgresql
  18. docker start $DB_CONTAINER
  19. # start pgbouncer
  20. docker run \
  21. --name $DB_CONTAINER_PROXY \
  22. --volume /srv/pgbouncer/config:/etc/pgbouncer \
  23. --volume /srv/pgbouncer/log:/var/log/pgbouncer \
  24. --net $NET_NAME \
  25. --ip 172.19.0.3 \
  26. --tty pgbouncer:alpine
  27. }
  28. start_odoo_system()
  29. {
  30. docker rm $1 -f
  31. docker run \
  32. --name $1 \
  33. --publish "$2:8069" \
  34. --volume "$ODOO_PATH/$1/conf:/etc/odoo" \
  35. --volume "$ODOO_PATH/$1/custom-addons:/mnt/extra-addons" \
  36. --volume "$ODOO_PATH/$1/files:/var/lib/odoo" \
  37. --link "$DB_CONTAINER:db" \
  38. --net $NET_NAME \
  39. --ip $3 \
  40. --tty $ODOO_IMAGE
  41. }
  42. start_odoo_systems()
  43. {
  44. start_odoo_system golden 10000 "172.19.0.100"
  45. start_odoo_system athletic 10500 "172.19.0.101"
  46. start_odoo_system topjeans 11000 "172.19.0.102"
  47. start_odoo_system kava 11500 "172.19.0.103"
  48. start_odoo_system amojeans 12500 "172.19.0.105"
  49. start_odoo_system world 13000 "172.19.0.106"
  50. start_odoo_system clasi_calse 13500 "172.19.0.107"
  51. start_odoo_system tuspasos 15000 "172.19.0.108"
  52. }
  53. start_monitor_systems()
  54. {
  55. docker start influxdb
  56. docker start telegraf
  57. docker start grafana
  58. docker start portainer
  59. }
  60. mount_backup_drives()
  61. {
  62. mount --type ext4 /dev/sdb /mnt/backup/primary_local_bkp
  63. mount --type ext4 /dev/sdc /mnt/backup/secondary_local_bkp
  64. }
  65. stop_odoo_systems()
  66. {
  67. for ODOO_NAME in $ODOO_SYSTEMS; do
  68. docker stop $ODOO_NAME
  69. done
  70. }
  71. stop_database_system()
  72. {
  73. docker stop pgbouncer
  74. docker rm pgbouncer -f
  75. docker stop database
  76. }
  77. stop_monitor_systems()
  78. {
  79. docker stop grafana
  80. docker stop telegraf
  81. docker stop influxdb
  82. }
  83. if [ ! -x "$(command -v docker)" ]; then
  84. echo "cannot bootup systems"
  85. exit 1
  86. fi
  87. if [ "$1" = "stop" ]; then
  88. stop_monitor_systems
  89. stop_odoo_systems
  90. stop_database_system
  91. exit 0
  92. fi
  93. start_database_system
  94. start_odoo_systems
  95. start_monitor_systems
  96. mount_backup_drives
  97. exit 0