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.

189 lines
4.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. CAGETTE PEI
  2. ===========
  3. Cagette Péi est un logiciel libre qui favorise les circuits courts.
  4. Il a été adapté pour les besoins des AMAPs sur le marché réunionnais.
  5. > <french>
  6. > Fourche du logiciel [Cagette.net](https://github.com/CagetteNet) à partir de la version 0.9.2 Novembre 2018. Certaines portions de code n'étant plus disponibles en téléchargement à partir de cette date, le logiciel a été repris, adapté puis réactualisé. Pour plus d'information, contact@artcode.re
  7. > </french>
  8. ![Screenshot](www/img/screenshot.png)
  9. ## PREREQUISITE MARIADB
  10. ```bash
  11. apt install -y mariadb-server
  12. mysql -u root <<EOF
  13. CREATE DATABASE cagettepei;
  14. GRANT ALL ON cagettepei.* TO 'cagettepei'@'%' IDENTIFIED BY 'cagettepei';
  15. EOF
  16. ```
  17. ## INSTALL FROM SCRATCH
  18. Rk: Works on any Debian (>=Buster) compatible server!
  19. ```
  20. apt install -y curl
  21. curl -L https://deb.nodesource.com/setup_8.x | bash -
  22. apt install -y nodejs=8.17.0-1nodesource1
  23. apt install -y sudo haxe apache2 make git imagemagick gettext libapache2-mod-neko mariadb-server sendemail libio-socket-ssl-perl libnet-ssleay-perl
  24. cd /var/www
  25. git clone https://git.artcode.re/cagetters/cagettepei.git
  26. cd cagettepei
  27. make install ENV=dev
  28. vim /etc/apache2/sites-available/cagettepei.conf
  29. ```
  30. ```
  31. <VirtualHost *:80>
  32. DocumentRoot /var/www/cagettepei/www
  33. DirectoryIndex index.n
  34. CustomLog ${APACHE_LOG_DIR}/cagettepei/access.log combined
  35. </VirtualHost>
  36. ```
  37. ```bash
  38. sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
  39. a2dissite 000-default.conf
  40. a2ensite cagettepei.conf
  41. a2enmod rewrite
  42. mkdir -p /var/log/apache2/cagettepei
  43. systemctl restart apache2
  44. ```
  45. ## CONFIGURATION
  46. ```bash
  47. cd /var/www/cagettepei
  48. vim config.xml
  49. ```
  50. ```
  51. <config
  52. host = "<DOMAIN.TLD>"
  53. database = "mysql://cagettepei:cagettepei@localhost/cagettepei"
  54. key = "<SECRET_PHRASE>"
  55. default_email = "<EMAIL>"
  56. webmaster_email = "<EMAIL>"
  57. debug = "0"
  58. sqllog = "0"
  59. maintain = "0"
  60. cache = "1"
  61. cachetpl = "0"
  62. />
  63. ```
  64. ADMIN RESET PASSWORD
  65. --------------------
  66. go to http://localhost for ERROR + table regeneration, then
  67. ```
  68. cd /var/www/cagettepei
  69. SECRET=$(grep key config.xml | cut -d= -f2 | cut -d'"' -f2)
  70. echo "insert into User values (1,'fr',MD5('${SECRET}cagettepei'),1,'Administrateur','Cagette Péi', 'admin', null, null, null, null, null, null, null, null, null, now(), now(),6,null, null)" | mysql -h localhost -u cagettepei -pcagettepei cagettepei
  71. ```
  72. then, connect with admin / cagettepei
  73. ### change admin password
  74. ```
  75. echo "update User set pass=MD5('${SECRET}cagettepei') where id=1" | mysql -h localhost -u cagettepei -pcagettepei cagettepei
  76. ```
  77. SYSTEMD-TIMERS
  78. --------------
  79. * vim /var/www/cagettepei-batch
  80. ```
  81. #!/bin/bash
  82. case $1 in
  83. minute);;
  84. daily);;
  85. *) echo "expected [minute|daily]" && exit 1;;
  86. esac
  87. SELECTOR=$1
  88. for i in /var/www/cagettepei* ; do
  89. if [[ -d $i ]]; then
  90. cd $i/www
  91. echo "cron-$SELECTOR in: $i"
  92. neko index.n cron/$SELECTOR
  93. echo
  94. fi
  95. done
  96. ```
  97. * chmod +x /var/www/cagettepei-batch
  98. * vim /etc/systemd/system/cagettepei-batch-minute.service
  99. ```
  100. [Unit]
  101. Description=Run batch cagettepei every minute
  102. [Service]
  103. User=www-data
  104. SyslogIdentifier=cagettepei
  105. ExecStart=/var/www/cagettepei-batch minute
  106. [Install]
  107. WantedBy=multi-user.target
  108. ```
  109. * vim /etc/systemd/system/cagettepei-batch-day.service
  110. ```
  111. [Unit]
  112. Description=Run batch cagettepei every day
  113. [Service]
  114. User=www-data
  115. SyslogIdentifier=cagettepei
  116. ExecStart=/var/www/cagettepei-batch daily
  117. [Install]
  118. WantedBy=multi-user.target
  119. ```
  120. * vim /etc/systemd/system/cagettepei-batch-minute.timer
  121. ```
  122. [Unit]
  123. Description=Timer for batch cagettepei every minute
  124. Requires=apache2.service
  125. [Timer]
  126. OnCalendar=minutely
  127. Unit=cagettepei-batch-minute.service
  128. [Install]
  129. WantedBy=timers.target
  130. ```
  131. * vim /etc/systemd/system/cagettepei-batch-day.timer
  132. ```
  133. [Unit]
  134. Description=Timer for batch cagettepei every day
  135. Requires=apache2.service
  136. [Timer]
  137. OnCalendar=daily
  138. Unit=cagettepei-batch-day.service
  139. [Install]
  140. WantedBy=timers.target
  141. ```
  142. * systemctl daemon-reload
  143. * systemctl edit apache2 # bind the 2 timers to apache2 cagette
  144. ```
  145. [Unit]
  146. BindsTo = cagettepei-batch-minute.timer cagettepei-batch-day.timer
  147. ```
  148. * systemctl enable cagettepei-batch-minute.timer cagettepei-batch-day.timer
  149. * systemctl start cagettepei-batch-minute.timer cagettepei-batch-day.timer