firstrun.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. if [ $pull = "true" ]; then
  3. if [ -f /var/www/html/configurations/ossn.config.db.php ]; then
  4. mv -f /var/www/html/configurations/ossn.config.db.php /tmp/ossn.config.db.php
  5. fi
  6. if [ -f /var/www/html/configurations/ossn.config.site.php ]; then
  7. mv -f /var/www/html/configurations/ossn.config.site.php /tmp/ossn.config.site.php
  8. fi
  9. rm -R /var/www/html
  10. fi
  11. # Check if config exists. If not, copy in the sample config
  12. if [ -f /config/proxy-config.conf ]; then
  13. echo "Using saved config file."
  14. else
  15. echo "Creating config from template."
  16. sed -i "s/admin@example.com/${adminlogin}/g" /etc/apache2/000-default.conf
  17. sed -i "s/example.com/${servername}/g" /etc/apache2/000-default.conf
  18. cp -f /etc/apache2/000-default.conf /config/proxy-config.conf
  19. cp /root/.htpasswd /config/.htpasswd
  20. fi
  21. # Add Persistent Cron Configuration Capability
  22. if [ -f /config/crons.conf ]; then
  23. echo "Using existing Cron config file."
  24. # crontab /config/crons.conf
  25. # cron
  26. else
  27. echo "Copying blank Cron config file."
  28. cp /root/crons.conf /config/crons.conf
  29. # crontab /config/crons.conf
  30. # cron
  31. fi
  32. # Check for OSSN folder
  33. if [ -d /var/www/html ]; then
  34. echo "Using OSSN folder found."
  35. else
  36. echo "Populating OSSN folder."
  37. wget https://www.opensource-socialnetwork.org/download_ossn/latest/build.zip -P /tmp/
  38. unzip /tmp/build.zip -d /tmp
  39. rm /tmp/build.zip
  40. if [ -d /var/www/html ]; then
  41. echo "mkdir /var/www/html"
  42. mkdir -p -v /var/www/html
  43. fi
  44. echo "moving ossn"
  45. mv -v -f /tmp/ossn /var/www/html/
  46. fi
  47. if [ -f /tmp/ossn.config.db.php ]; then
  48. mv -f /tmp/ossn.config.db.php /var/www/html/configurations/ossn.config.db.php
  49. fi
  50. if [ -f /tmp/ossn.config.site.php ]; then
  51. mv -f /tmp/ossn.config.site.php /var/www/html/configurations/ossn.config.site.php
  52. fi