Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

create_instance.sh 2.0KB

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