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 1.9KB

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. cp_loader() {
  8. loader="${install_tpl}/loader.py"
  9. cp -Rv $loader $instdir/
  10. # Adding lib path to loader
  11. sed -i -E "s#^(LODEL2_LIB_ABS_PATH = )None#\1'$libdir'#" "$loader"
  12. }
  13. if [ $# -lt 2 ]
  14. then
  15. echo "Not enough arguments" >&2
  16. usage
  17. fi
  18. name="$1"
  19. instdir="$2"
  20. libdir="$5"
  21. libdir=${libdir:=[@]PKGPYTHONDIR[@]}
  22. install_tpl="$3"
  23. if [ $name == "monosite" ];then
  24. name=""
  25. fi
  26. if [ -z "$install_tpl" ]
  27. then
  28. echo -e "Install template $install_tpl not found.\n" >&2
  29. usage
  30. fi
  31. em_file="$4"
  32. if [ -z "$em_file" ]
  33. then
  34. echo -e "Emfile $emfile not found.\n" >&2
  35. usage
  36. fi
  37. libdir=$(realpath $libdir)
  38. install_tpl=$(realpath $install_tpl)
  39. em_file=$(realpath $em_file)
  40. if test ! -d $install_tpl
  41. then
  42. echo "Install template directory '$install_tpl' not found"
  43. echo ""
  44. usage
  45. fi
  46. conf="$instdir/conf.d/lodel2.ini"
  47. if [ $1 = '-u' ]
  48. then
  49. #Update instance
  50. cp_loader
  51. exit 0
  52. fi
  53. if [ -e "$instdir" ]
  54. then
  55. echo "Abording... "$instdir" exists" 1>&2
  56. exit 1
  57. fi
  58. echo "Creating lodel instance directory '$instdir'"
  59. mkdir -pv "$instdir"
  60. mkdir -pv "$instdir/sessions"
  61. chmod 700 "$instdir/sessions"
  62. #cp -Rv $install_tpl/* $instdir
  63. cp -Rv $install_tpl/conf.d $instdir/
  64. cp -Rv $em_file $instdir/editorial_model.pickle
  65. ln -sv $install_tpl/Makefile $instdir/Makefile
  66. ln -sv $install_tpl/lodel_admin.py $instdir/lodel_admin.py
  67. ln -sv $libdir/plugins $instdir/plugins
  68. cp_loader
  69. echo "BEGIN LS"
  70. ls -la $instdir
  71. echo "END LS"
  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"