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.

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