freedombone-utils-config 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Initial reading of the configuration file, typically called freedombone.cfg
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. function read_config_param {
  31. param_name="$1"
  32. if [ $CONFIGURATION_FILE ]; then
  33. if [ -f $CONFIGURATION_FILE ]; then
  34. if grep -q "${param_name}" $CONFIGURATION_FILE; then
  35. ${param_name}=$(cat $CONFIGURATION_FILE | grep "${param_name}=" | head -n 1 | awk -F '=' '{print $2}')
  36. fi
  37. fi
  38. fi
  39. }
  40. function read_configuration {
  41. # if not installing on a Beaglebone then use sdb as the USB drive by default
  42. if [ ! $INSTALLING_ON_BBB ]; then
  43. if [[ $USB_DRIVE == /dev/sda1 ]]; then
  44. USB_DRIVE=/dev/sdb1
  45. fi
  46. fi
  47. if [[ $INSTALLING_FROM_CONFIGURATION_FILE == "yes" ]]; then
  48. if [ ! -f $CONFIGURATION_FILE ]; then
  49. echo $"The configuration file $CONFIGURATION_FILE was not found"
  50. exit 8935
  51. fi
  52. fi
  53. if [ -f $CONFIGURATION_FILE ]; then
  54. read_repo_servers
  55. # Ensure that a copy of the config exists for upgrade purposes
  56. if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
  57. cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
  58. fi
  59. read_config_param "FRIENDS_MIRRORS_SERVER"
  60. read_config_param "FRIENDS_MIRRORS_SSH_PORT"
  61. read_config_param "FRIENDS_MIRRORS_PASSWORD"
  62. read_config_param "MY_MIRRORS_PASSWORD"
  63. read_config_param "SYSTEM_TYPE"
  64. read_config_param "SSL_PROTOCOLS"
  65. read_config_param "SSL_CIPHERS"
  66. read_config_param "SSH_CIPHERS"
  67. read_config_param "SSH_MACS"
  68. read_config_param "SSH_KEX"
  69. read_config_param "SSH_HOST_KEY_ALGORITHMS"
  70. read_config_param "SSH_PASSWORDS"
  71. read_config_param "REFRESH_GPG_KEYS_HOURS"
  72. read_config_param "GPG_KEYSERVER"
  73. read_config_param "ENABLE_SOCIAL_KEY_MANAGEMENT"
  74. read_config_param "MY_USERNAME"
  75. read_config_param "DOMAIN_NAME"
  76. read_config_param "DEFAULT_DOMAIN_NAME"
  77. read_config_param "DEFAULT_DOMAIN_CODE"
  78. read_config_param "NAMESERVER1"
  79. read_config_param "NAMESERVER2"
  80. read_config_param "GET_IP_ADDRESS_URL"
  81. read_config_param "DDNS_PROVIDER"
  82. read_config_param "DDNS_USERNAME"
  83. read_config_param "DDNS_PASSWORD"
  84. read_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS"
  85. read_config_param "ROUTER_IP_ADDRESS"
  86. read_config_param "CPU_CORES"
  87. read_config_param "WEBSERVER_LOG_LEVEL"
  88. read_config_param "ROUTE_THROUGH_TOR"
  89. read_config_param "MY_NAME"
  90. read_config_param "MY_EMAIL_ADDRESS"
  91. read_config_param "INSTALLING_ON_BBB"
  92. read_config_param "SSH_PORT"
  93. read_config_param "INSTALLED_WITHIN_DOCKER"
  94. read_config_param "GPG_ENCRYPT_STORED_EMAIL"
  95. read_config_param "MY_GPG_PUBLIC_KEY"
  96. read_config_param "MY_GPG_PRIVATE_KEY"
  97. read_config_param "MY_GPG_PUBLIC_KEY_ID"
  98. read_config_param "USB_DRIVE"
  99. read_config_param "MAX_PHP_MEMORY"
  100. read_config_param "TLS_TIME_SOURCE1"
  101. read_config_param "TLS_TIME_SOURCE2"
  102. read_config_param "ONION_ONLY"
  103. read_config_param "DEFAULT_LANGUAGE"
  104. read_config_param "MINIMAL_INSTALL"
  105. read_config_param "LETSENCRYPT_SERVER"
  106. read_config_param "WIFI_INTERFACE"
  107. read_config_param "WIFI_SSID"
  108. read_config_param "WIFI_TYPE"
  109. read_config_param "WIFI_PASSPHRASE"
  110. read_config_param "WIFI_HOTSPOT"
  111. read_config_param "WIFI_NETWORKS_FILE"
  112. read_config_param "DEFAULT_SEARCH"
  113. read_config_param "SEARCH_ENGINE_PASSWORD"
  114. read_config_param "PROJECT_WEBSITE"
  115. read_config_param "PROJECT_REPO"
  116. read_config_param "GPGIT_REPO"
  117. read_config_param "GPGIT_COMMIT"
  118. read_config_param "NGINX_ENSITE_REPO"
  119. read_config_param "NGINX_ENSITE_REPO"
  120. read_config_param "NGINX_ENSITE_COMMIT"
  121. read_config_param "CLEANUP_MAILDIR_COMMIT"
  122. read_config_param "CLEANUP_MAILDIR_REPO"
  123. read_config_param "INADYN_REPO"
  124. read_config_param "INADYN_COMMIT"
  125. read_config_param "DH_KEYLENGTH"
  126. read_config_param "WIFI_CHANNEL"
  127. read_config_param "IPV6_NETWORK"
  128. read_config_param "HWRNG_TYPE"
  129. read_config_param "ENABLE_BABEL"
  130. read_config_param "ENABLE_BATMAN"
  131. read_config_param "ENABLE_CJDNS"
  132. read_config_param "PUBLIC_MAILING_LIST"
  133. if grep -q "DEBIAN_REPO" $CONFIGURATION_FILE; then
  134. DEBIAN_REPO=$(grep "DEBIAN_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
  135. CHECK_MESSAGE=$"Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list."
  136. fi
  137. fi
  138. echo "System type: $SYSTEM_TYPE"
  139. }
  140. # check that domain names are sensible
  141. function check_domains {
  142. if [ ${#WIKI_DOMAIN_NAME} -gt 1 ]; then
  143. function_check test_domain_name
  144. test_domain_name "$WIKI_DOMAIN_NAME"
  145. if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
  146. echo $'Wiki domain name is the same as blog domain name. They must be different'
  147. exit 97326
  148. fi
  149. if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
  150. echo $'Wiki domain name is the same as microblog domain name. They must be different'
  151. exit 36827
  152. fi
  153. if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
  154. echo $'Wiki domain name is the same as hubzilla domain name. They must be different'
  155. exit 65848
  156. fi
  157. if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
  158. if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
  159. echo $'Wiki domain name is the same as Gogs domain name. They must be different'
  160. exit 73529
  161. fi
  162. fi
  163. fi
  164. if [ ${#FULLBLOG_DOMAIN_NAME} -gt 1 ]; then
  165. function_check test_domain_name
  166. test_domain_name "$FULLBLOG_DOMAIN_NAME"
  167. if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
  168. echo $'Blog domain name is the same as wiki domain name. They must be different'
  169. exit 62348
  170. fi
  171. if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
  172. echo $'Blog domain name is the same as microblog domain name. They must be different'
  173. exit 38236
  174. fi
  175. if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
  176. echo $'Blog domain name is the same as hubzilla domain name. They must be different'
  177. exit 35483
  178. fi
  179. if [ $GIT_DOMAIN_NAME ]; then
  180. if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
  181. echo $'Blog domain name is the same as Gogs domain name. They must be different'
  182. exit 84695
  183. fi
  184. fi
  185. fi
  186. if [ ${#MICROBLOG_DOMAIN_NAME} -gt 1 ]; then
  187. function_check test_domain_name
  188. test_domain_name "$MICROBLOG_DOMAIN_NAME"
  189. if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
  190. echo $'Microblog domain name is the same as wiki domain name. They must be different'
  191. exit 73924
  192. fi
  193. if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
  194. echo $'Microblog domain name is the same as blog domain name. They must be different'
  195. exit 26832
  196. fi
  197. if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
  198. echo $'Microblog domain name is the same as hubzilla domain name. They must be different'
  199. exit 678382
  200. fi
  201. if [ $GIT_DOMAIN_NAME ]; then
  202. if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
  203. echo $'Microblog domain name is the same as Gogs domain name. They must be different'
  204. exit 684325
  205. fi
  206. fi
  207. fi
  208. if [ $HUBZILLA_DOMAIN_NAME ]; then
  209. function_check test_domain_name
  210. test_domain_name "$HUBZILLA_DOMAIN_NAME"
  211. if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
  212. echo $'Hubzilla domain name is the same as wiki domain name. They must be different'
  213. exit 83682
  214. fi
  215. if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
  216. echo $'Hubzilla domain name is the same as blog domain name. They must be different'
  217. exit 74817
  218. fi
  219. if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
  220. echo $'Hubzilla domain name is the same as microblog domain name. They must be different'
  221. exit 83683
  222. fi
  223. if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
  224. if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
  225. echo $'Hubzilla domain name is the same as Gogs domain name. They must be different'
  226. exit 135523
  227. fi
  228. fi
  229. fi
  230. if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
  231. function_check test_domain_name
  232. test_domain_name "$GIT_DOMAIN_NAME"
  233. if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
  234. echo $'Hubzilla domain name is the same as wiki domain name. They must be different'
  235. exit 83682
  236. fi
  237. if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
  238. echo $'Hubzilla domain name is the same as blog domain name. They must be different'
  239. exit 74817
  240. fi
  241. if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
  242. echo $'Hubzilla domain name is the same as microblog domain name. They must be different'
  243. exit 83683
  244. fi
  245. if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
  246. echo $'Microblog domain name is the same as hubzilla domain name. They must be different'
  247. exit 678382
  248. fi
  249. fi
  250. }
  251. # NOTE: deliberately no exit 0