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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. usage() {
  3. echo -e "Usage : $0 instance_name (instance_dir|-u) [install_tpl] [em_file] [lidir]" >&2
  4. echo -e "\n\tIf -u given as first argument update instance's loader.py" >&2
  5. exit 1
  6. }
  7. loader_update() {
  8. libdir=$1
  9. install_tpl=$2
  10. instdir=$3
  11. cp -Rv $install_tpl/loader.py $instdir/loader.py
  12. # Adding lib path to loader
  13. sed -i -E "s#^(LODEL2_LIB_ABS_PATH = )None#\1'$libdir'#" "$instdir/loader.py"
  14. }
  15. if [ $# -lt 2 ]
  16. then
  17. echo "Not enough arguments" >&2
  18. usage
  19. fi
  20. name="$1"
  21. instdir="$2"
  22. libdir="$5"
  23. libdir=${libdir:=[@]PKGPYTHONDIR[@]}
  24. install_tpl="$3"
  25. if [ $name == "monosite" ];then
  26. name=""
  27. fi
  28. if [ -z "$install_tpl" ]
  29. then
  30. echo -e "Install template $install_tpl not found.\n" >&2
  31. usage
  32. fi
  33. em_file="$4"
  34. if [ -z "$em_file" ]
  35. then
  36. echo -e "Emfile $emfile not found.\n" >&2
  37. usage
  38. fi
  39. libdir=$(realpath $libdir)
  40. install_tpl=$(realpath $install_tpl)
  41. em_file=$(realpath $em_file)
  42. echo "LIBDIR : $libdir"
  43. if test ! -d $install_tpl
  44. then
  45. echo "Install template directory '$install_tpl' not found"
  46. echo ""
  47. usage
  48. fi
  49. conf="$instdir/conf.d/lodel2.ini"
  50. if [ $1 = '-u' ]
  51. then
  52. #Update instance
  53. loader_update "$libdir" "$install_tpl" "$instdir"
  54. exit 0
  55. fi
  56. if [ -e "$instdir" ]
  57. then
  58. echo "Abording... "$instdir" exists" 1>&2
  59. exit 1
  60. fi
  61. echo "Creating lodel instance directory '$instdir'"
  62. mkdir -pv "$instdir"
  63. mkdir -pv "$instdir/sessions"
  64. chmod 700 "$instdir/sessions"
  65. #cp -Rv $install_tpl/* $instdir
  66. cp -Rv $install_tpl/conf.d $instdir/
  67. cp -Rv $em_file $instdir/editorial_model.pickle
  68. ln -sv $install_tpl/Makefile $instdir/Makefile
  69. ln -sv $install_tpl/lodel_admin.py $instdir/lodel_admin.py
  70. ln -sv $libdir/lodel/plugins $instdir/plugins
  71. loader_update "$libdir" "$install_tpl" "$instdir"
  72. # Adding instance name to conf
  73. sed -i -E "s#^sitename = noname#sitename = $name#" "$conf"
  74. echo -e "\nSite successfully created in $instdir"
  75. echo -e "============================\n"
  76. echo "Now you should edit files in '${instdir}/conf.d/' and then run : cd $instdir && make dyncode"