freedombone-utils-repos 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # Functions to set repositories
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2014-2018 Bob Mottram <bob@freedombone.net>
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. # The Debian package repository to use.
  29. DEBIAN_REPO="ftp.us.debian.org"
  30. function create_repo_sources {
  31. if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
  32. return
  33. fi
  34. rm -rf /var/lib/apt/lists/*
  35. apt-get clean
  36. { echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION} main";
  37. echo "deb-src http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION} main";
  38. echo '';
  39. echo "deb http://security.debian.org/ ${DEBIAN_VERSION}/updates main";
  40. echo "deb-src http://security.debian.org/ ${DEBIAN_VERSION}/updates main";
  41. echo '';
  42. echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-updates main";
  43. echo "deb-src http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-updates main";
  44. echo '';
  45. echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main";
  46. echo "deb-src http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main"; } > /etc/apt/sources.list
  47. apt-get update
  48. apt-get -yq install apt-transport-https
  49. mark_completed "${FUNCNAME[0]}"
  50. }
  51. # A command to create a git repository for a project
  52. function create_git_project {
  53. if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
  54. return
  55. fi
  56. apt-get -yq install git
  57. { echo '#!/bin/bash';
  58. echo '';
  59. echo "GIT_PROJECT_NAME=\$1";
  60. echo "if [ ! \$GIT_PROJECT_NAME ]; then";
  61. echo ' echo "Please specify a project name, without any spaces"';
  62. echo ' exit 1';
  63. echo 'fi';
  64. echo '';
  65. echo "if [ ! -d /home/\$USER/projects/\$GIT_PROJECT_NAME ]; then";
  66. echo " mkdir -p /home/\$USER/projects/\$GIT_PROJECT_NAME";
  67. echo 'fi';
  68. echo '';
  69. echo "cd /home/\$USER/projects/\$GIT_PROJECT_NAME";
  70. echo 'git init --bare';
  71. echo '';
  72. echo -n 'echo "Your project has been created, ';
  73. echo 'use the following command to clone the repository"';
  74. echo -n " git clone ssh://$MY_USERNAME@$DEFAULT_DOMAIN_NAME:$SSH_PORT";
  75. echo "/home/\$USER/projects/\$GIT_PROJECT_NAME";
  76. echo '';
  77. echo 'exit 0'; } > "/usr/bin/$CREATE_GIT_PROJECT_COMMAND"
  78. chmod +x "/usr/bin/$CREATE_GIT_PROJECT_COMMAND"
  79. mark_completed "${FUNCNAME[0]}"
  80. }
  81. # NOTE: deliberately no exit 0