postinst 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/sh
  2. httpserver_init() {
  3. db_get movim/httpserver
  4. httpservers="$RET"
  5. for httpserver in $httpservers; do
  6. httpserver=${httpserver%,}
  7. #if [ "$httpserver" = "nginx" ] ; then
  8. # nginx_install
  9. #else
  10. apache_install $1 $httpserver
  11. #fi
  12. done
  13. }
  14. apache_install() {
  15. server="apache2"
  16. CONF="movim"
  17. COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
  18. if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
  19. . /usr/share/apache2/apache2-maintscript-helper
  20. apache2_invoke enconf $CONF || exit $?
  21. elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
  22. [ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
  23. && ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
  24. reload_server $server
  25. fi
  26. }
  27. #nginx_install() {
  28. #server="apache2"
  29. #CONF="movim"
  30. #COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
  31. #if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
  32. #. /usr/share/apache2/apache2-maintscript-helper
  33. #apache2_invoke enconf $CONF || exit $?
  34. #elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
  35. #[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
  36. #&& ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
  37. #reload_server $server
  38. #fi
  39. #}
  40. #
  41. # fixperms 0644 /usr/share/movim
  42. #
  43. fixperms () {
  44. PERMS="$1"
  45. FILE="$2"
  46. chmod ${PERMS} "${FILE}"
  47. }
  48. #
  49. # fixownership user:group /var/cache/movim
  50. #
  51. fixownership ()
  52. {
  53. OWNER="$1"
  54. FILE="$2"
  55. chown ${OWNER} "${FILE}"
  56. }
  57. fixownershipdir ()
  58. {
  59. OWNER="$1"
  60. FILE="$2"
  61. chown -R ${OWNER} "${FILE}"
  62. }
  63. reload_server() {
  64. server=$1
  65. if [ -x /usr/sbin/invoke-rc.d ]; then
  66. invoke-rc.d $server reload 3>/dev/null || true
  67. else
  68. /etc/init.d/$server reload 3>/dev/null || true
  69. fi
  70. }
  71. . /usr/share/debconf/confmodule
  72. db_get movim/debconf_install
  73. if [ "$RET" = false ]; then
  74. exit 0;
  75. fi
  76. . /usr/share/dbconfig-common/dpkg/postinst
  77. dbc_go movim $@
  78. if [ "$dbc_dbtype" == 'mysql' ]; then
  79. dbport='3306'
  80. else
  81. dbport='5432'
  82. fi
  83. # We create the Movim configuration file
  84. #touch /etc/movim/db.inc.php
  85. echo "<?php
  86. # This is the database configuration of Movim
  87. # You need to copy an rename this file to 'db.inc.php' and complete the values
  88. \$conf = array(
  89. # The type can be 'pgsql' or 'mysql'
  90. 'type' => '$dbc_dbtype',
  91. # The database username
  92. 'username' => '$dbc_dbuser',
  93. # The password
  94. 'password' => '$dbc_dbpass',
  95. # Where can we find the database ?
  96. 'host' => 'localhost',
  97. # The port number, 3306 for MySQL and 5432 for PostGreSQL
  98. 'port' => $dbport,
  99. # The database name
  100. 'database' => '$dbc_dbname'
  101. );
  102. " > /etc/movim/db.inc.php
  103. httpserver_init $1
  104. # We create some links
  105. ln -s /etc/movim/ /usr/share/movim/config 2>/dev/null
  106. ln -s /var/lib/movim/lib /usr/share/movim/ 2>/dev/null
  107. ln -s /var/lib/movim/locales /usr/share/movim/ 2>/dev/null
  108. ln -s /var/lib/movim/themes /usr/share/movim/ 2>/dev/null
  109. ln -s /var/lib/movim/vendor /usr/share/movim/ 2>/dev/null
  110. ln -s /var/lib/movim/src /usr/share/movim/ 2>/dev/null
  111. # We create the cache folder
  112. mkdir -p /var/cache/movim/cache 2>/dev/null
  113. ln -s /var/cache/movim/cache /usr/share/movim/cache 2>/dev/null
  114. fixperms 0775 /usr/share/movim/cache
  115. fixownershipdir "www-data:www-data" /var/cache/movim/cache
  116. fixownershipdir "www-data:www-data" /usr/share/movim/cache
  117. # We create the log folder
  118. mkdir /var/log/movim 2>/dev/null
  119. ln -s /var/log/movim /usr/share/movim/log 2>/dev/null
  120. fixperms 0775 /var/log/movim
  121. fixownership "root:www-data" /var/log/movim
  122. # We create the user folder
  123. mkdir /var/cache/movim/users 2>/dev/null
  124. ln -s /var/cache/movim/users /usr/share/movim/users 2>/dev/null
  125. fixperms 0775 /user/share/movim/users
  126. fixownershipdir "www-data:www-data" /var/cache/movim/users
  127. fixownershipdir "www-data:www-data" /usr/share/movim/users
  128. # Fix rights
  129. fixperms 0775 /usr/share/movim
  130. fixownership "root:www-data" /usr/share/movim
  131. fixperms 0775 /usr/share/movim/daemon.php
  132. fixownership "root:www-data" /usr/share/movim/daemon.php
  133. # And we install/update the Movim database
  134. echo "Creating and/or updating the Movim database… please be patient"
  135. chmod +x /usr/share/movim/mud.php
  136. /usr/share/movim/mud.php db set
  137. # We clean some log created by the install to prevent issues
  138. rm -rf /usr/share/movim/log/* /usr/share/movim/cache/*