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.

190 lines
4.3 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
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é et réactualisé.
  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. ServerName cagettepei
  33. DirectoryIndex index.n
  34. DocumentRoot /var/www/cagettepei/www/
  35. CustomLog ${APACHE_LOG_DIR}/cagettepei/access.log combined
  36. ErrorLog ${APACHE_LOG_DIR}/cagettepei/debug.log
  37. ErrorLogFormat "[%{uc}t] %M"
  38. </VirtualHost>
  39. ```
  40. ```bash
  41. sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
  42. a2dissite 000-default.conf
  43. a2ensite cagettepei.conf
  44. a2enmod rewrite
  45. mkdir -p /var/log/apache2/cagettepei
  46. systemctl restart apache2
  47. ```
  48. ## CONFIGURATION
  49. ```bash
  50. cd /var/www/cagettepei
  51. vim config.xml
  52. ```
  53. ```
  54. <config
  55. host = "<DOMAIN.TLD>"
  56. database = "mysql://cagettepei:cagettepei@localhost/cagettepei"
  57. key = "<SECRET_PHRASE>"
  58. default_email = "<EMAIL>"
  59. webmaster_email = "<EMAIL>"
  60. debug = "0"
  61. sqllog = "0"
  62. maintain = "0"
  63. cache = "1"
  64. cachetpl = "0"
  65. />
  66. ```
  67. ADMIN RESET PASSWORD
  68. --------------------
  69. go to http://localhost for ERROR + table regeneration, then
  70. ```
  71. cd /var/www/cagettepei
  72. SECRET=$(grep key config.xml | cut -d= -f2 | cut -d'"' -f2)
  73. 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
  74. ```
  75. then, connect with admin / cagettepei
  76. ### change admin password
  77. ```
  78. echo "update User set pass=MD5('${SECRET}cagettepei') where id=1" | mysql -h localhost -u cagettepei -pcagettepei cagettepei
  79. ```
  80. SYSTEMD-TIMERS
  81. --------------
  82. * vim /var/www/cagettepei-batch
  83. ```
  84. #!/bin/bash
  85. case $1 in
  86. minute);;
  87. daily);;
  88. *) echo "expected [minute|daily]" && exit 1;;
  89. esac
  90. SELECTOR=$1
  91. for i in /var/www/cagettepei* ; do
  92. if [[ -d $i ]]; then
  93. cd $i/www
  94. echo "cron-$SELECTOR in: $i"
  95. neko index.n cron/$SELECTOR
  96. echo
  97. fi
  98. done
  99. ```
  100. * chmod +x /var/www/cagettepei-batch
  101. * vim /etc/systemd/system/cagettepei-batch-minute.service
  102. ```
  103. [Unit]
  104. Description=Run batch cagettepei every minute
  105. [Service]
  106. User=www-data
  107. SyslogIdentifier=cagettepei
  108. ExecStart=/var/www/cagettepei-batch minute
  109. [Install]
  110. WantedBy=multi-user.target
  111. ```
  112. * vim /etc/systemd/system/cagettepei-batch-day.service
  113. ```
  114. [Unit]
  115. Description=Run batch cagettepei every day
  116. [Service]
  117. User=www-data
  118. SyslogIdentifier=cagettepei
  119. ExecStart=/var/www/cagettepei-batch daily
  120. [Install]
  121. WantedBy=multi-user.target
  122. ```
  123. * vim /etc/systemd/system/cagettepei-batch-minute.timer
  124. ```
  125. [Unit]
  126. Description=Timer for batch cagettepei every minute
  127. Requires=apache2.service
  128. [Timer]
  129. OnCalendar=minutely
  130. Unit=cagettepei-batch-minute.service
  131. [Install]
  132. WantedBy=timers.target
  133. ```
  134. * vim /etc/systemd/system/cagettepei-batch-day.timer
  135. ```
  136. [Unit]
  137. Description=Timer for batch cagettepei every day
  138. Requires=apache2.service
  139. [Timer]
  140. OnCalendar=daily
  141. Unit=cagettepei-batch-day.service
  142. [Install]
  143. WantedBy=timers.target
  144. ```
  145. * systemctl daemon-reload
  146. * systemctl edit apache2 # bind the 2 timers to apache2 cagette
  147. ```
  148. [Unit]
  149. BindsTo = cagettepei-batch-minute.timer cagettepei-batch-day.timer
  150. ```
  151. * systemctl enable cagettepei-batch-minute.timer cagettepei-batch-day.timer
  152. * systemctl start cagettepei-batch-minute.timer cagettepei-batch-day.timer