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

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