No Description
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.

create_instance.sh 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/bash
  2. #
  3. # This file is part of Lodel 2 (https://github.com/OpenEdition)
  4. #
  5. # Copyright (C) 2015-2017 Cléo UMS-3287
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published
  9. # by the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. usage() {
  21. echo -e "Usage : $0 instance_name (instance_dir|-u) [install_tpl] [em_file] [lidir]" >&2
  22. echo -e "\n\tIf -u given as first argument update instance's loader.py" >&2
  23. exit 1
  24. }
  25. loader_update() {
  26. libdir=$1
  27. install_tpl=$2
  28. instdir=$3
  29. lib_abs_path=$(dirname $libdir)
  30. cp -Rv $install_tpl/loader.py $instdir/loader.py
  31. # Adding lib path to loader
  32. sed -i -E "s#^(LODEL2_LIB_ABS_PATH = )None#\1'$lib_abs_path'#" "$instdir/loader.py"
  33. }
  34. if [ $# -lt 2 ]
  35. then
  36. echo "Not enough arguments" >&2
  37. usage
  38. fi
  39. name="$1"
  40. instdir="$2"
  41. libdir="$5"
  42. libdir=${libdir:=[@]PKGPYTHONDIR[@]}
  43. install_tpl="$3"
  44. if [ $name == "monosite" ];then
  45. name=""
  46. fi
  47. if [ -z "$install_tpl" ]
  48. then
  49. echo -e "Install template $install_tpl not found.\n" >&2
  50. usage
  51. fi
  52. em_file="$4"
  53. if [ -z "$em_file" ]
  54. then
  55. echo -e "Emfile $emfile not found.\n" >&2
  56. usage
  57. fi
  58. libdir=$(realpath $libdir)
  59. install_tpl=$(realpath $install_tpl)
  60. em_file=$(realpath $em_file)
  61. echo "LIBDIR : $libdir"
  62. if test ! -d $install_tpl
  63. then
  64. echo "Install template directory '$install_tpl' not found"
  65. echo ""
  66. usage
  67. fi
  68. conf="$instdir/conf.d/lodel2.ini"
  69. if [ $1 = '-u' ]
  70. then
  71. #Update instance
  72. loader_update "$libdir" "$install_tpl" "$instdir"
  73. exit 0
  74. fi
  75. if [ -e "$instdir" ]
  76. then
  77. echo "Abording... "$instdir" exists" 1>&2
  78. exit 1
  79. fi
  80. echo "Creating lodel instance directory '$instdir'"
  81. mkdir -pv "$instdir"
  82. mkdir -pv "$instdir/sessions"
  83. chmod 700 "$instdir/sessions"
  84. #cp -Rv $install_tpl/* $instdir
  85. cp -Rv $install_tpl/conf.d $instdir/
  86. cp -Rv $em_file $instdir/editorial_model.pickle
  87. ln -sv $install_tpl/Makefile $instdir/Makefile
  88. ln -sv $install_tpl/lodel_admin.py $instdir/lodel_admin.py
  89. ln -sv $libdir/plugins $instdir/plugins
  90. loader_update "$libdir" "$install_tpl" "$instdir"
  91. # Adding instance name to conf
  92. sed -i -E "s#^sitename = noname#sitename = $name#" "$conf"
  93. echo -e "\nSite successfully created in $instdir"
  94. echo -e "============================\n"
  95. echo "Now you should edit files in '${instdir}/conf.d/' and then run : cd $instdir && make dyncode"