Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

create_instance.sh 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. usage() {
  3. echo -e "Usage : $0 instance_name (instance_dir|-u) [lodel_libdir]" 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 $libdir/install/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="$3"
  20. libdir="${libdir:=$(realpath $(dirname $0)/..)}/"
  21. loader="$instdir/loader.py"
  22. conf="$instdir/conf.d/lodel2.ini"
  23. if [ $1 = '-u' ]
  24. then
  25. #Update instance
  26. cp_loader
  27. exit 0
  28. fi
  29. if [ -e "$instdir" ]
  30. then
  31. echo "Abording... "$instdir" exists" 1>&2
  32. exit 1
  33. fi
  34. echo "Creating lodel instance directory '$instdir'"
  35. mkdir -pv "$instdir"
  36. mkdir -pv "$instdir/sessions"
  37. chmod 700 "$instdir/sessions"
  38. #cp -Rv $libdir/install/* $instdir
  39. cp -Rv $libdir/install/conf.d $instdir/
  40. cp -Rv $libdir/examples/em_test.pickle $instdir/editorial_model.pickle
  41. ln -sv $libdir/install/Makefile $instdir/Makefile
  42. ln -sv $libdir/install/lodel_admin.py $instdir/lodel_admin.py
  43. ln -sv $libdir/plugins $instdir/plugins
  44. cp_loader
  45. # Adding instance name to conf
  46. sed -i -E "s#^sitename = noname#sitename = $name#" "$conf"
  47. echo -e "\nInstance successfully created in $instdir"
  48. echo -e "============================\n"
  49. echo "Now you should edit files in '${instdir}/conf.d/' and then run : cd $instdir && make dyncode"