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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. usage() {
  3. echo -e "Usage : $0 instance_name (instance_dir|-u) [install_tpl] [em_file]" 1>&2
  4. echo -e "\n\tIf -u given as first argument update instance's loader.py" 1>&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" 1>&2
  15. usage
  16. fi
  17. name="$1"
  18. instdir="$2"
  19. libdir=[@]PKGPYTHONDIR[@]
  20. install_tpl="$3"
  21. [ -z "$install_tpl" ] && usage
  22. em_file="$4"
  23. [ -z "$em_file" ] && usage
  24. libdir=$(realpath $libdir)
  25. install_tpl=$(realpath $install_tpl)
  26. em_file=$(realpath $em_file)
  27. if test ! -d $install_tpl
  28. then
  29. echo "Install template directory '$install_tpl' not found"
  30. echo ""
  31. usage
  32. fi
  33. loader="$instdir/loader.py"
  34. conf="$instdir/conf.d/lodel2.ini"
  35. if [ $1 = '-u' ]
  36. then
  37. #Update instance
  38. cp_loader
  39. exit 0
  40. fi
  41. if [ -e "$instdir" ]
  42. then
  43. echo "Abording... "$instdir" exists" 1>&2
  44. exit 1
  45. fi
  46. echo "Creating lodel instance directory '$instdir'"
  47. mkdir -pv "$instdir"
  48. mkdir -pv "$instdir/sessions"
  49. chmod 700 "$instdir/sessions"
  50. #cp -Rv $install_tpl/* $instdir
  51. cp -Rv $install_tpl/conf.d $instdir/
  52. cp -Rv $em_file $instdir/editorial_model.pickle
  53. ln -sv $install_tpl/Makefile $instdir/Makefile
  54. ln -sv $install_tpl/lodel_admin.py $instdir/lodel_admin.py
  55. ln -sv $libdir/plugins $instdir/plugins
  56. cp_loader
  57. # Adding instance name to conf
  58. sed -i -E "s#^sitename = noname#sitename = $name#" "$conf"
  59. echo -e "\nInstance successfully created in $instdir"
  60. echo -e "============================\n"
  61. echo "Now you should edit files in '${instdir}/conf.d/' and then run : cd $instdir && make dyncode"