install 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
  3. if [ "$(command -v sqlite3)" == "" ]
  4. then
  5. echo "SQLite3 is not installed. Install it and try again."
  6. exit -1
  7. fi
  8. if [ "$(command -v php)" == "" ]
  9. then
  10. echo "PHP is not installed. Install it and try again."
  11. exit -2
  12. fi
  13. if [ "$(php -m | grep sqlite3)" == "" ]
  14. then
  15. echo "PHP module sqlite3 is not installed. Install it and try again."
  16. exit -3
  17. fi
  18. if [ "$(command -v node)" == "" ]
  19. then
  20. echo "NODE.js is not installed. Install it and try again."
  21. exit -4
  22. fi
  23. # TODO: FIX, not working for this module
  24. #if ! node -r requireg /dev/null 2> /dev/null
  25. #then
  26. # echo "NODE.js module requireg is not installed. Install it and try again."
  27. # exit -5
  28. #fi
  29. if ! node -r dateformat /dev/null 2> /dev/null
  30. then
  31. echo "NODE.js module dateformat is not installed. Install it and try again."
  32. exit -5
  33. fi
  34. if ! node -r request /dev/null 2> /dev/null
  35. then
  36. echo "NODE.js module request is not installed. Install it and try again."
  37. exit -6
  38. fi
  39. if ! node -r querystring /dev/null 2> /dev/null
  40. then
  41. echo "NODE.js module querystring is not installed. Install it and try again."
  42. exit -7
  43. fi
  44. if ! node -r http /dev/null 2> /dev/null
  45. then
  46. echo "NODE.js module http is not installed. Install it and try again."
  47. exit -8
  48. fi
  49. if ! node -r fs /dev/null 2> /dev/null
  50. then
  51. echo "NODE.js module fs is not installed. Install it and try again."
  52. exit -9
  53. fi
  54. clear_keys=0
  55. clear_data=0
  56. for i in "$@"
  57. do
  58. if [[ $i == "--clear-keys" ]] ; then
  59. clear_keys=1;
  60. elif [[ $i == "--clear-data" ]] ; then
  61. clear_data=1;
  62. fi
  63. done
  64. if [ -f $SCRIPTPATH/application/sw.sqlite ] && [ $clear_keys == 0 ]
  65. then
  66. echo "Key database exist. It will not be overwritten. Use the --clear-keys argument to override."
  67. else
  68. echo "Setting up keys..."
  69. rm $SCRIPTPATH/application/sw.sqlite
  70. sqlite3 $SCRIPTPATH/application/sw.sqlite < $SCRIPTPATH/install_data/install_base.sql
  71. fi
  72. if [ -f $SCRIPTPATH/data/sw.sqlite ] && [ $clear_data == 0 ]
  73. then
  74. echo "User data database exist. It will not be overwritten. Use the --clear-data argument to override."
  75. else
  76. echo "Setting up user tables..."
  77. rm $SCRIPTPATH/data/sw.sqlite
  78. sqlite3 $SCRIPTPATH/data/sw.sqlite < $SCRIPTPATH/install_data/install_data.sql
  79. fi
  80. echo "All done. You can start the web server by typing ./start_server or edit the config file for the server options"