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