freedombone-config 39KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Interactively creates a configuration file for use with the main
  12. # freedombone command
  13. #
  14. # License
  15. # =======
  16. #
  17. # Copyright (C) 2015-2016 Bob Mottram <bob@freedombone.net>
  18. #
  19. # This program is free software: you can redistribute it and/or modify
  20. # it under the terms of the GNU Affero General Public License as published by
  21. # the Free Software Foundation, either version 3 of the License, or
  22. # (at your option) any later version.
  23. #
  24. # This program is distributed in the hope that it will be useful,
  25. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. # GNU Affero General Public License for more details.
  28. #
  29. # You should have received a copy of the GNU Affero General Public License
  30. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. NO_OF_ARGS=$#
  32. PROJECT_NAME='freedombone'
  33. # username created by default within a debian image
  34. GENERIC_IMAGE_USERNAME='fbone'
  35. export TEXTDOMAIN=${PROJECT_NAME}-config
  36. export TEXTDOMAINDIR="/usr/share/locale"
  37. # Web site
  38. FREEDOMBONE_WEBSITE="https://freedombone.net or http://4fvfozz6g3zmvf76.onion"
  39. # Minimum number of characters in a password
  40. MINIMUM_PASSWORD_LENGTH=$(cat /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-passwords | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
  41. # file containing new password
  42. IMAGE_PASSWORD_FILE=/root/login.txt
  43. MY_USERNAME=
  44. DEFAULT_DOMAIN_NAME=
  45. DEFAULT_DOMAIN_CODE=
  46. MY_EMAIL_ADDRESS=
  47. SYSTEM_TYPE='full'
  48. INSTALLING_ON_BBB="no"
  49. DDNS_PROVIDER=
  50. DDNS_USERNAME=
  51. DDNS_PASSWORD=
  52. MY_NAME=
  53. LOCAL_NETWORK_STATIC_IP_ADDRESS=
  54. ROUTER_IP_ADDRESS=
  55. ENABLE_BATMAN=
  56. DEBIAN_REPO=
  57. NAMESERVER1=
  58. NAMESERVER2=
  59. DOKUWIKI_TITLE=
  60. DOKUWIKI_DOMAIN_NAME=
  61. DOKUWIKI_CODE=
  62. HTMLY_TITLE=
  63. HTMLY_DOMAIN_NAME=
  64. HTMLY_CODE=
  65. HUBZILLA_DOMAIN_NAME=
  66. HUBZILLA_CODE=
  67. GNUSOCIAL_DOMAIN_NAME=
  68. GNUSOCIAL_CODE=
  69. GNUSOCIAL_WELCOME_MESSAGE=$"<h1>Welcome to \$GNUSOCIAL_DOMAIN_NAME – a federated social network</h1><p>Another $PROJECT_NAME site</p>"
  70. GNUSOCIAL_BACKGROUND_IMAGE_URL=
  71. GIT_DOMAIN_NAME=
  72. GIT_CODE=
  73. USB_DRIVE=/dev/sdb1
  74. HWRNG_TYPE=
  75. ENABLE_SOCIAL_KEY_MANAGEMENT=
  76. WIFI_INTERFACE=wlan0
  77. WIFI_TYPE='wpa2-psk'
  78. WIFI_SSID=
  79. WIFI_PASSPHRASE=
  80. WIFI_HOTSPOT=
  81. WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
  82. BATMAN_CELLID='any'
  83. WIFI_CHANNEL=
  84. CONFIGURATION_FILE=
  85. DH_KEYLENGTH=
  86. MINIMAL_INSTALL="yes"
  87. DEFAULT_LANGUAGE='en_GB.UTF-8'
  88. ONION_ONLY="no"
  89. SELECTED_USERNAME=
  90. # Mirrors settings
  91. FRIENDS_MIRRORS_SERVER=
  92. FRIENDS_MIRRORS_SSH_PORT=2222
  93. FRIENDS_MIRRORS_PASSWORD=
  94. MY_MIRRORS_PASSWORD=
  95. VALID_CODE=
  96. PROJECT_INSTALL_DIR=/usr/local/bin
  97. if [ -f /usr/bin/${PROJECT_NAME} ]; then
  98. PROJECT_INSTALL_DIR=/usr/bin
  99. fi
  100. source $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars
  101. UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
  102. for f in $UTILS_FILES
  103. do
  104. source $f
  105. done
  106. APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
  107. for f in $APP_FILES
  108. do
  109. source $f
  110. done
  111. function show_help {
  112. echo ''
  113. echo $"${PROJECT_NAME}-config -f [config filename] -m [min password length]"
  114. echo ''
  115. echo $'Creates an inventory of remote backup locations'
  116. echo ''
  117. echo ''
  118. echo $' -h --help Show help'
  119. echo $' -f --filename Configuration file (usually freedombone.cfg)'
  120. echo $' -m --min Minimum password length (characters)'
  121. echo $' -w --www Freedombone web site'
  122. echo $' -b --bm Freedombone support Bitmessage address'
  123. echo $' -o --onion [yes|no] Whether to only create .onion sites'
  124. echo $' --minimal [yes|no] For minimalistic "consumer grade" installs'
  125. echo ''
  126. exit 0
  127. }
  128. function choose_email_address {
  129. if [[ $ONION_ONLY != "no" ]]; then
  130. EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
  131. else
  132. while [ ${#MY_EMAIL_ADDRESS} -lt 5 ]
  133. do
  134. EMAIL_ADDRESS=$(grep 'MY_EMAIL_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
  135. if [ ! $EMAIL_ADDRESS ]; then
  136. EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
  137. fi
  138. if [ ${#MY_EMAIL_ADDRESS} -lt 5 ]; then
  139. EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
  140. fi
  141. data=$(tempfile 2>/dev/null)
  142. trap "rm -f $data" 0 1 2 5 15
  143. dialog --backtitle $"Freedombone Configuration" \
  144. --inputbox $"Your email address" 10 30 "$EMAIL_ADDRESS" 2> $data
  145. sel=$?
  146. case $sel in
  147. 0) MY_EMAIL_ADDRESS=$(cat $data);;
  148. 1) exit 1;;
  149. 255) exit 1;;
  150. esac
  151. done
  152. fi
  153. save_configuration_values
  154. }
  155. function choose_default_domain_name {
  156. if [[ $ONION_ONLY != "no" ]]; then
  157. DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local"
  158. else
  159. DEFAULT_DOMAIN_DETAILS_COMPLETE=
  160. while [ ! $DEFAULT_DOMAIN_DETAILS_COMPLETE ]
  161. do
  162. data=$(tempfile 2>/dev/null)
  163. trap "rm -f $data" 0 1 2 5 15
  164. if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
  165. dialog --backtitle $"Freedombone Configuration" \
  166. --title $"Your main domain name" \
  167. --form $"\nWhich domain name should your email/XMPP/IRC/Mumble be associated with?" 13 55 5 \
  168. $"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 24 33 40 \
  169. $"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 24 33 255 \
  170. $"mail subdomain Code:" 3 1 "$(grep 'EMAIL_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 3 24 33 255 \
  171. $"XMPP subdomain Code:" 4 1 "$(grep 'XMPP_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 24 33 255 \
  172. 2> $data
  173. sel=$?
  174. case $sel in
  175. 1) exit 1;;
  176. 255) exit 1;;
  177. esac
  178. DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
  179. DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
  180. EMAIL_DOMAIN_CODE=$(cat $data | sed -n 2p)
  181. XMPP_DOMAIN_CODE=$(cat $data | sed -n 2p)
  182. if [ $DEFAULT_DOMAIN_NAME ]; then
  183. validate_freedns_code "$DEFAULT_DOMAIN_CODE"
  184. if [ ! $VALID_CODE ]; then
  185. DEFAULT_DOMAIN_NAME=
  186. fi
  187. fi
  188. if [ $EMAIL_DOMAIN_CODE ]; then
  189. validate_freedns_code "$EMAIL_DOMAIN_CODE"
  190. if [ ! $VALID_CODE ]; then
  191. DEFAULT_DOMAIN_NAME=
  192. EMAIL_DOMAIN_CODE=
  193. else
  194. write_config_param "EMAIL_DOMAIN_CODE" "$EMAIL_DOMAIN_CODE"
  195. fi
  196. fi
  197. if [ $XMPP_DOMAIN_CODE ]; then
  198. validate_freedns_code "$XMPP_DOMAIN_CODE"
  199. if [ ! $VALID_CODE ]; then
  200. DEFAULT_DOMAIN_NAME=
  201. XMPP_DOMAIN_CODE=
  202. else
  203. write_config_param "XMPP_DOMAIN_CODE" "$XMPP_DOMAIN_CODE"
  204. fi
  205. fi
  206. else
  207. dialog --backtitle $"Freedombone Configuration" \
  208. --inputbox $"Which domain name should your email/XMPP/IRC/Mumble be associated with?" 10 45 \
  209. "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
  210. sel=$?
  211. case $sel in
  212. 0) DEFAULT_DOMAIN_NAME=$(cat $data);;
  213. 1) exit 1;;
  214. 255) exit 1;;
  215. esac
  216. fi
  217. if [ $DEFAULT_DOMAIN_NAME ]; then
  218. TEST_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME
  219. validate_domain_name
  220. if [[ $TEST_DOMAIN_NAME != $DEFAULT_DOMAIN_NAME ]]; then
  221. DEFAULT_DOMAIN_NAME=
  222. dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
  223. else
  224. DEFAULT_DOMAIN_DETAILS_COMPLETE="yes"
  225. fi
  226. fi
  227. done
  228. fi
  229. save_configuration_values
  230. }
  231. function choose_dynamic_dns {
  232. if [[ $SYSTEM_TYPE != "mesh"* && $ONION_ONLY == "no" ]]; then
  233. data=$(tempfile 2>/dev/null)
  234. trap "rm -f $data" 0 1 2 5 15
  235. dialog --backtitle $"Freedombone Configuration" \
  236. --radiolist $"Choose Dynamic DNS provider:" 15 40 14 \
  237. 1 dyndns off \
  238. 2 freedns on \
  239. 3 zoneedit off \
  240. 4 no-ip off \
  241. 5 easydns off \
  242. 6 tzo off \
  243. 7 3322 off \
  244. 8 dnsomatic off \
  245. 9 tunnelbroker off \
  246. 10 dns.he.net off \
  247. 11 dynsip off \
  248. 12 sitelutions off \
  249. 13 dnsexit off \
  250. 14 changeip off 2> $data
  251. sel=$?
  252. case $sel in
  253. 1) exit 1;;
  254. 255) exit 1;;
  255. esac
  256. case $(cat $data) in
  257. 1) DDNS_PROVIDER="default@dyndns.org";;
  258. 2) DDNS_PROVIDER="default@freedns.afraid.org";;
  259. 3) DDNS_PROVIDER="default@zoneedit.com";;
  260. 4) DDNS_PROVIDER="default@no-ip.com";;
  261. 5) DDNS_PROVIDER="default@easydns.com";;
  262. 6) DDNS_PROVIDER="default@tzo.com";;
  263. 7) DDNS_PROVIDER="dyndns@3322.org";;
  264. 8) DDNS_PROVIDER="default@dnsomatic.com";;
  265. 9) DDNS_PROVIDER="ipv6tb@he.net";;
  266. 10) DDNS_PROVIDER="dyndns@he.net";;
  267. 11) DDNS_PROVIDER="default@dynsip.org";;
  268. 12) DDNS_PROVIDER="default@sitelutions.com";;
  269. 13) DDNS_PROVIDER="default@dnsexit.com";;
  270. 14) DDNS_PROVIDER="default@changeip.com";;
  271. 255) exit 1;;
  272. esac
  273. save_configuration_values
  274. valid_ddns_username=
  275. while [ ! $valid_ddns_username ]
  276. do
  277. data=$(tempfile 2>/dev/null)
  278. trap "rm -f $data" 0 1 2 5 15
  279. dialog --backtitle $"Freedombone Configuration" \
  280. --inputbox $"Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
  281. sel=$?
  282. case $sel in
  283. 0) possible_username=$(cat $data)
  284. if [ "$possible_username" ]; then
  285. if [ ${#possible_username} -gt 1 ]; then
  286. valid_ddns_username=$(cat $data)
  287. DDNS_USERNAME=$valid_ddns_username
  288. break;
  289. fi
  290. fi
  291. ;;
  292. 1) exit 1;;
  293. 255) exit 1;;
  294. esac
  295. done
  296. save_configuration_values
  297. valid_ddns_password=
  298. while [ ! $valid_ddns_password ]
  299. do
  300. data=$(tempfile 2>/dev/null)
  301. trap "rm -f $data" 0 1 2 5 15
  302. dialog --backtitle $"Freedombone Configuration" \
  303. --clear \
  304. --insecure \
  305. --passwordbox $"Dynamic DNS provider password" 10 30 "$(grep 'DDNS_PASSWORD' temp.cfg | awk -F '=' '{print $2}')" 2> $data
  306. sel=$?
  307. case $sel in
  308. 0) possible_password=$(cat $data)
  309. if [ "$possible_password" ]; then
  310. if [ ${#possible_password} -gt 1 ]; then
  311. valid_ddns_password=$(cat $data)
  312. DDNS_PASSWORD=$valid_ddns_password
  313. break;
  314. fi
  315. fi
  316. ;;
  317. 1) exit 1;;
  318. 255) exit 1;;
  319. esac
  320. if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
  321. dialog --title $"Password quality check" --msgbox $"The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40
  322. DDNS_PASSWORD=""
  323. fi
  324. done
  325. save_configuration_values
  326. fi
  327. }
  328. function choose_dns {
  329. if [[ $MINIMAL_INSTALL == "no" && $ONION_ONLY == "no" ]]; then
  330. data=$(tempfile 2>/dev/null)
  331. trap "rm -f $data" 0 1 2 5 15
  332. dialog --backtitle $"Freedombone Configuration" \
  333. --radiolist $"Pick a domain name service (DNS):" 25 50 16 \
  334. 1 $"Digital Courage" on \
  335. 2 $"German Privacy Foundation 1" off \
  336. 3 $"German Privacy Foundation 2" off \
  337. 4 $"Chaos Computer Club" off \
  338. 5 $"ClaraNet" off \
  339. 6 $"OpenNIC 1" off \
  340. 7 $"OpenNIC 2" off \
  341. 8 $"OpenNIC 3" off \
  342. 9 $"OpenNIC 4" off \
  343. 10 $"OpenNIC 5" off \
  344. 11 $"OpenNIC 6" off \
  345. 12 $"OpenNIC 7" off \
  346. 13 $"PowerNS" off \
  347. 14 $"ValiDOM" off \
  348. 15 $"Freie Unzensierte" off \
  349. 16 $"Google" off 2> $data
  350. sel=$?
  351. case $sel in
  352. 1) exit 1;;
  353. 255) exit 1;;
  354. esac
  355. case $(cat $data) in
  356. 1) NAMESERVER1='85.214.73.63'
  357. NAMESERVER2='213.73.91.35'
  358. ;;
  359. 2) NAMESERVER1='87.118.100.175'
  360. NAMESERVER2='94.75.228.29'
  361. ;;
  362. 3) NAMESERVER1='85.25.251.254'
  363. NAMESERVER2='2.141.58.13'
  364. ;;
  365. 4) NAMESERVER1='213.73.91.35'
  366. NAMESERVER2='85.214.73.63'
  367. ;;
  368. 5) NAMESERVER1='212.82.225.7'
  369. NAMESERVER2='212.82.226.212'
  370. ;;
  371. 6) NAMESERVER1='58.6.115.42'
  372. NAMESERVER2='58.6.115.43'
  373. ;;
  374. 7) NAMESERVER1='119.31.230.42'
  375. NAMESERVER2='200.252.98.162'
  376. ;;
  377. 8) NAMESERVER1='217.79.186.148'
  378. NAMESERVER2='81.89.98.6'
  379. ;;
  380. 9) NAMESERVER1='78.159.101.37'
  381. NAMESERVER2='203.167.220.153'
  382. ;;
  383. 10) NAMESERVER1='82.229.244.191'
  384. NAMESERVER2='82.229.244.191'
  385. ;;
  386. 11) NAMESERVER1='216.87.84.211'
  387. NAMESERVER2='66.244.95.20'
  388. ;;
  389. 12) NAMESERVER1='207.192.69.155'
  390. NAMESERVER2='72.14.189.120'
  391. ;;
  392. 13) NAMESERVER1='194.145.226.26'
  393. NAMESERVER2='77.220.232.44'
  394. ;;
  395. 14) NAMESERVER1='78.46.89.147'
  396. NAMESERVER2='88.198.75.145'
  397. ;;
  398. 15) NAMESERVER1='85.25.149.144'
  399. NAMESERVER2='87.106.37.196'
  400. ;;
  401. 16) NAMESERVER1='8.8.8.8'
  402. NAMESERVER2='4.4.4.4'
  403. ;;
  404. 255) exit 1;;
  405. esac
  406. save_configuration_values
  407. else
  408. # as defaults for a minimal install process these settings are debatable
  409. NAMESERVER1='85.214.73.63'
  410. NAMESERVER2='213.73.91.35'
  411. fi
  412. }
  413. function choose_debian_repo {
  414. if [[ $MINIMAL_INSTALL == "no" ]]; then
  415. data=$(tempfile 2>/dev/null)
  416. trap "rm -f $data" 0 1 2 5 15
  417. dialog --backtitle $"Freedombone Configuration" \
  418. --radiolist $"Where to download Debian packages from:" 25 45 49 \
  419. 1 $"Australia" off \
  420. 2 $"Austria" off \
  421. 3 $"Belarus" off \
  422. 4 $"Belgium" off \
  423. 5 $"Bosnia and Herzegovina" off \
  424. 6 $"Brazil" off \
  425. 7 $"Bulgaria" off \
  426. 8 $"Canada" off \
  427. 9 $"Chile" off \
  428. 10 $"China" off \
  429. 11 $"Croatia" off \
  430. 12 $"Czech Republic" off \
  431. 13 $"Denmark" off \
  432. 14 $"El Salvador" off \
  433. 15 $"Estonia" off \
  434. 16 $"Finland" off \
  435. 17 $"France 1" off \
  436. 18 $"France 2" off \
  437. 19 $"Germany 1" off \
  438. 20 $"Germany 2" off \
  439. 21 $"Greece" off \
  440. 22 $"Hungary" off \
  441. 23 $"Iceland" off \
  442. 24 $"Iran" off \
  443. 25 $"Ireland" off \
  444. 26 $"Italy" off \
  445. 27 $"Japan" off \
  446. 28 $"Korea" off \
  447. 29 $"Lithuania" off \
  448. 30 $"Mexico" off \
  449. 31 $"Netherlands" off \
  450. 32 $"New Caledonia" off \
  451. 33 $"New Zealand" off \
  452. 34 $"Norway" off \
  453. 35 $"Poland" off \
  454. 36 $"Portugal" off \
  455. 37 $"Romania" off \
  456. 38 $"Russia" off \
  457. 39 $"Slovakia" off \
  458. 40 $"Slovenia" off \
  459. 41 $"Spain" off \
  460. 42 $"Sweden" off \
  461. 43 $"Switzerland" off \
  462. 44 $"Taiwan" off \
  463. 45 $"Thailand" off \
  464. 46 $"Turkey" off \
  465. 47 $"Ukraine" off \
  466. 48 $"United Kingdom" off \
  467. 49 $"United States" on 2> $data
  468. sel=$?
  469. case $sel in
  470. 1) exit 1;;
  471. 255) exit 1;;
  472. esac
  473. case $(cat $data) in
  474. 1) DEBIAN_REPO='ftp.au.debian.org';;
  475. 2) DEBIAN_REPO='ftp.at.debian.org';;
  476. 3) DEBIAN_REPO='ftp.by.debian.org';;
  477. 4) DEBIAN_REPO='ftp.be.debian.org';;
  478. 5) DEBIAN_REPO='ftp.ba.debian.org';;
  479. 6) DEBIAN_REPO='ftp.br.debian.org';;
  480. 7) DEBIAN_REPO='ftp.bg.debian.org';;
  481. 8) DEBIAN_REPO='ftp.ca.debian.org';;
  482. 9) DEBIAN_REPO='ftp.cl.debian.org';;
  483. 10) DEBIAN_REPO='ftp.cn.debian.org';;
  484. 11) DEBIAN_REPO='ftp.hr.debian.org';;
  485. 12) DEBIAN_REPO='ftp.cz.debian.org';;
  486. 13) DEBIAN_REPO='ftp.dk.debian.org';;
  487. 14) DEBIAN_REPO='ftp.sv.debian.org';;
  488. 15) DEBIAN_REPO='ftp.ee.debian.org';;
  489. 16) DEBIAN_REPO='ftp.fi.debian.org';;
  490. 17) DEBIAN_REPO='ftp2.fr.debian.org';;
  491. 18) DEBIAN_REPO='ftp.fr.debian.org';;
  492. 19) DEBIAN_REPO='ftp2.de.debian.org';;
  493. 20) DEBIAN_REPO='ftp.de.debian.org';;
  494. 21) DEBIAN_REPO='ftp.gr.debian.org';;
  495. 22) DEBIAN_REPO='ftp.hu.debian.org';;
  496. 23) DEBIAN_REPO='ftp.is.debian.org';;
  497. 24) DEBIAN_REPO='ftp.ir.debian.org';;
  498. 25) DEBIAN_REPO='ftp.ie.debian.org';;
  499. 26) DEBIAN_REPO='ftp.it.debian.org';;
  500. 27) DEBIAN_REPO='ftp.jp.debian.org';;
  501. 28) DEBIAN_REPO='ftp.kr.debian.org';;
  502. 29) DEBIAN_REPO='ftp.lt.debian.org';;
  503. 30) DEBIAN_REPO='ftp.mx.debian.org';;
  504. 31) DEBIAN_REPO='ftp.nl.debian.org';;
  505. 32) DEBIAN_REPO='ftp.nc.debian.org';;
  506. 33) DEBIAN_REPO='ftp.nz.debian.org';;
  507. 34) DEBIAN_REPO='ftp.no.debian.org';;
  508. 35) DEBIAN_REPO='ftp.pl.debian.org';;
  509. 36) DEBIAN_REPO='ftp.pt.debian.org';;
  510. 37) DEBIAN_REPO='ftp.ro.debian.org';;
  511. 38) DEBIAN_REPO='ftp.ru.debian.org';;
  512. 39) DEBIAN_REPO='ftp.sk.debian.org';;
  513. 40) DEBIAN_REPO='ftp.si.debian.org';;
  514. 41) DEBIAN_REPO='ftp.es.debian.org';;
  515. 42) DEBIAN_REPO='ftp.se.debian.org';;
  516. 43) DEBIAN_REPO='ftp.ch.debian.org';;
  517. 44) DEBIAN_REPO='ftp.tw.debian.org';;
  518. 45) DEBIAN_REPO='ftp.th.debian.org';;
  519. 46) DEBIAN_REPO='ftp.tr.debian.org';;
  520. 47) DEBIAN_REPO='ftp.ua.debian.org';;
  521. 48) DEBIAN_REPO='ftp.uk.debian.org';;
  522. 49) DEBIAN_REPO='ftp.us.debian.org';;
  523. 255) exit 1;;
  524. esac
  525. save_configuration_values
  526. else
  527. DEBIAN_REPO='ftp.de.debian.org'
  528. fi
  529. }
  530. function choose_rng {
  531. if [[ $MINIMAL_INSTALL == "no" ]]; then
  532. data=$(tempfile 2>/dev/null)
  533. trap "rm -f $data" 0 1 2 5 15
  534. if [[ $INSTALLING_ON_BBB != "yes" ]]; then
  535. dialog --backtitle $"Freedombone Configuration" \
  536. --radiolist $"Type of Random Number Generator:" 10 40 2 \
  537. 1 Haveged on \
  538. 2 OneRNG off 2> $data
  539. sel=$?
  540. case $sel in
  541. 1) exit 1;;
  542. 255) exit 1;;
  543. esac
  544. case $(cat $data) in
  545. 2) HWRNG_TYPE="onerng"
  546. dialog --title $"OneRNG Device" \
  547. --msgbox $"Please ensure that the OneRNG device is disconnected. You can reconnect it later during the installation" 8 60
  548. ;;
  549. 255) exit 1;;
  550. esac
  551. else
  552. HWRNG_TYPE="beaglebone"
  553. fi
  554. save_configuration_values
  555. fi
  556. }
  557. function choose_social_key_management {
  558. if [[ $MINIMAL_INSTALL == "no" ]]; then
  559. interactive_gpg
  560. data=$(tempfile 2>/dev/null)
  561. trap "rm -f $data" 0 1 2 5 15
  562. SOCIAL_KEY_STR=$"\nDo you wish to enable social key management, otherwise known as \"the unforgettable key\"?\n\nThis means that fragments of your GPG key will be included with any remote backups so that if you later lose your key then it can be reconstructed from your friends servers. If you select \"no\" then you can still do social key management, but offline using physical USB thumb drives, which is more secure but less convenient."
  563. if [[ $(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
  564. dialog --title $"Social Key Management" \
  565. --backtitle $"Freedombone Configuration" \
  566. --yesno "$SOCIAL_KEY_STR" 15 60
  567. else
  568. dialog --title $"Social Key Management" \
  569. --backtitle $"Freedombone Configuration" \
  570. --defaultno \
  571. --yesno "$SOCIAL_KEY_STR" 15 60
  572. fi
  573. sel=$?
  574. case $sel in
  575. 0) ENABLE_SOCIAL_KEY_MANAGEMENT="yes";;
  576. 255) exit 1;;
  577. esac
  578. save_configuration_values
  579. else
  580. # enable for the minimal case
  581. ENABLE_SOCIAL_KEY_MANAGEMENT="yes"
  582. fi
  583. }
  584. function choose_username {
  585. if [ -d /home/$GENERIC_IMAGE_USERNAME ]; then
  586. if [ ! -f $IMAGE_PASSWORD_FILE ]; then
  587. echo 'Cannot find the password file for the admin user'
  588. exit 62753
  589. fi
  590. # when installing from an image which comes with a known default user account
  591. SELECTED_USERNAME=
  592. while [ ! $SELECTED_USERNAME ]
  593. do
  594. if [ ! $SELECTED_USERNAME ]; then
  595. SELECTED_USERNAME=$(grep 'MY_USERNAME' temp.cfg | awk -F '=' '{print $2}')
  596. fi
  597. data=$(tempfile 2>/dev/null)
  598. trap "rm -f $data" 0 1 2 5 15
  599. dialog --backtitle $"Freedombone Configuration" \
  600. --title $"Username" \
  601. --inputbox $"Set your username for the system\n\nYour username should not contain any spaces" 12 60 "$SELECTED_USERNAME" 2> $data
  602. sel=$?
  603. case $sel in
  604. 0) possible_username=$(cat $data)
  605. SELECTED_USERNAME=
  606. if [[ $possible_username != *' '* && $possible_username != *'/'* && $possible_username != *'\'* && $possible_username != *'*'* ]]; then
  607. if [ $possible_username ]; then
  608. if [ ${#possible_username} -gt 1 ]; then
  609. if [[ $possible_username != $GENERIC_IMAGE_USERNAME ]]; then
  610. MY_USERNAME=$(cat $data)
  611. useradd -m -s /bin/bash $MY_USERNAME
  612. if [ -d /home/$MY_USERNAME ]; then
  613. echo "${MY_USERNAME}:$(printf `cat $IMAGE_PASSWORD_FILE`)" | chpasswd
  614. # Add the user as a sudoer - they will be the new admin user
  615. if ! grep -q "$MY_USERNAME ALL=(ALL) ALL" /etc/sudoers; then
  616. echo "$MY_USERNAME ALL=(ALL) ALL" >> /etc/sudoers
  617. # remove the generic image admin user from sudoers
  618. sed -i "s|${GENERIC_IMAGE_USERNAME}.*||g" /etc/sudoers
  619. fi
  620. break
  621. fi
  622. fi
  623. fi
  624. fi
  625. fi
  626. ;;
  627. 1) exit 1;;
  628. 255) exit 1;;
  629. esac
  630. done
  631. else
  632. no_of_users=$(find /home/* -maxdepth 0 -type d | wc -l)
  633. if [ $no_of_users -eq 1 ]; then
  634. # only a single user on the system
  635. MY_USERNAME=$(ls /home)
  636. else
  637. # select one from a number of users
  638. select_user
  639. if [ ! $SELECTED_USERNAME ]; then
  640. echo $'No username selected'
  641. exit 72589
  642. fi
  643. MY_USERNAME="$SELECTED_USERNAME"
  644. fi
  645. fi
  646. if [ ! $MY_USERNAME ]; then
  647. echo $'No user account was selected'
  648. exit 64398
  649. fi
  650. if [[ $MY_USERNAME == '-f' ]]; then
  651. echo $'No user account was selected'
  652. exit 8347
  653. fi
  654. if [[ $MY_USERNAME == 'debian' || $MY_USERNAME == 'fbone' ]]; then
  655. echo $"Don't use the default user account"
  656. exit 9341
  657. fi
  658. if [ ! -d /home/$MY_USERNAME ]; then
  659. echo $"The directory /home/$MY_USERNAME does not exist"
  660. exit 6437
  661. fi
  662. save_configuration_values
  663. }
  664. function choose_full_name {
  665. valid_name=
  666. while [ ! $valid_name ]
  667. do
  668. data=$(tempfile 2>/dev/null)
  669. trap "rm -f $data" 0 1 2 5 15
  670. dialog --backtitle $"Freedombone Configuration" \
  671. --inputbox $"Your full name (or nick)" 10 30 "$(grep 'MY_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
  672. sel=$?
  673. case $sel in
  674. 0) possible_name=$(cat $data)
  675. if [ "$possible_name" ]; then
  676. if [ ${#possible_name} -gt 1 ]; then
  677. valid_name="$possible_name"
  678. MY_NAME="$possible_name"
  679. break;
  680. fi
  681. fi
  682. ;;
  683. 1) exit 1;;
  684. 255) exit 1;;
  685. esac
  686. done
  687. save_configuration_values
  688. }
  689. function choose_system_variant {
  690. available_variants_list=()
  691. available_system_variants
  692. varslist=""
  693. n=1
  694. for a in "${available_variants_list[@]}"
  695. do
  696. varstate='off'
  697. if [[ "$a" == $'full' || "$a" == $'Full' ]]; then
  698. varstate='on'
  699. fi
  700. varslist="$varslist $n $a $varstate"
  701. n=$[n+1]
  702. done
  703. variant_choice=$(dialog --stdout --backtitle $"Freedombone Configuration" \
  704. --title $"Type of Installation" \
  705. --radiolist $'Choose:' \
  706. 27 40 20 $varslist)
  707. if [ $? -eq 0 ]; then
  708. variant_choice=$[variant_choice-1]
  709. SYSTEM_TYPE=${available_variants_list[$variant_choice]}
  710. save_configuration_values
  711. fi
  712. }
  713. function validate_freedns_code {
  714. freedns_code="$1"
  715. FREEDNS_MESSAGE=$"Please enter the FreeDNS code for this domain.\n\nThe code can be found by going to https://freedns.afraid.org, selecting 'Dynamic DNS' and then opening 'Wget example'. The code will consist of letters and numbers and be between the ? and = characters."
  716. if [[ "$freedns_code" == *"."* || "$freedns_code" == "http"* || "$freedns_code" == *"wget "* || "$freedns_code" == *" "* ]]; then
  717. dialog --title $"Invalid FreeDNS Code" --msgbox "$FREEDNS_MESSAGE" 10 70
  718. VALID_CODE=
  719. fi
  720. if [ ${#freedns_code} -lt 30 ]; then
  721. dialog --title $"Invalid FreeDNS Code" --msgbox $'FreeDNS code is too short. Did you enter the entire code?' 6 70
  722. VALID_CODE=
  723. fi
  724. VALID_CODE='yes'
  725. }
  726. # Get the commandline options
  727. while [[ $# > 1 ]]
  728. do
  729. key="$1"
  730. case $key in
  731. -h|--help)
  732. show_help
  733. ;;
  734. # Configuration filename
  735. -f|--filename)
  736. shift
  737. CONFIGURATION_FILE="$1"
  738. ;;
  739. # Minimum password length
  740. -m|--min)
  741. shift
  742. MINIMUM_PASSWORD_LENGTH="$1"
  743. ;;
  744. # Freedombone website
  745. -w|--www)
  746. shift
  747. FREEDOMBONE_WEBSITE="$1"
  748. ;;
  749. --minimal)
  750. shift
  751. MINIMAL_INSTALL="$1"
  752. ;;
  753. -o|--onion)
  754. shift
  755. ONION_ONLY="$1"
  756. ;;
  757. *)
  758. # unknown option
  759. ;;
  760. esac
  761. shift
  762. done
  763. function set_main_repo {
  764. data=$(tempfile 2>/dev/null)
  765. trap "rm -f $data" 0 1 2 5 15
  766. dialog --backtitle $"Freedombone Control Panel" \
  767. --title $"Main Repository (Mirrors)" \
  768. --form $"If you don't know what this means then just select Ok.\n\nIf you don't wish to use the default repositories they can be obtained from mirrored repos on another ${PROJECT_NAME} system.\n\nThe repositories are for applications which are not yet packaged for Debian." 18 65 4 \
  769. $"URL:" 1 1 "$FRIENDS_MIRRORS_SERVER" 1 18 40 18 \
  770. $"SSH Port:" 2 1 "$FRIENDS_MIRRORS_SSH_PORT" 2 18 10 10000 \
  771. $"Password:" 3 1 "$FRIENDS_MIRRORS_PASSWORD" 3 18 40 10000 \
  772. 2> $data
  773. sel=$?
  774. case $sel in
  775. 1) return;;
  776. 255) return;;
  777. esac
  778. new_mirrors_url=$(cat $data | sed -n 1p)
  779. new_mirrors_ssh_port=$(cat $data | sed -n 2p)
  780. new_mirrors_password=$(cat $data | sed -n 3p)
  781. if [ ${#new_mirrors_url} -lt 2 ]; then
  782. return
  783. fi
  784. if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
  785. return
  786. fi
  787. if [ ${#new_mirrors_password} -lt 10 ]; then
  788. dialog --title $"Main Repository" \
  789. --msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
  790. return
  791. fi
  792. if [[ $new_mirrors_url == *"."* ]]; then
  793. FRIENDS_MIRRORS_SERVER=$new_mirrors_url
  794. FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port
  795. FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password
  796. dialog --title $"Main Repository" \
  797. --msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
  798. fi
  799. save_configuration_values
  800. }
  801. function interactive_select_language {
  802. data=$(tempfile 2>/dev/null)
  803. trap "rm -f $data" 0 1 2 5 15
  804. dialog --backtitle $"Freedombone Configuration" \
  805. --radiolist $"Select your language:" 26 40 24 \
  806. 1 $"Afrikaans" off \
  807. 2 $"Albanian" off \
  808. 3 $"Arabic" off \
  809. 4 $"Basque" off \
  810. 5 $"Belarusian" off \
  811. 6 $"Bosnian" off \
  812. 7 $"Bulgarian" off \
  813. 8 $"Catalan" off \
  814. 9 $"Croatian" off \
  815. 10 $"Chinese (Simplified)" off \
  816. 11 $"Chinese (Traditional)" off \
  817. 12 $"Czech" off \
  818. 13 $"Danish" off \
  819. 14 $"Dutch" off \
  820. 15 $"English" on \
  821. 16 $"English (US)" off \
  822. 17 $"Estonian" off \
  823. 18 $"Farsi" off \
  824. 19 $"Filipino" off \
  825. 20 $"Finnish" off \
  826. 21 $"French" off \
  827. 22 $"French (Canada)" off \
  828. 23 $"Gaelic" off \
  829. 24 $"Gallego" off \
  830. 25 $"Georgian" off \
  831. 26 $"German" off \
  832. 27 $"German (Personal)" off \
  833. 28 $"Greek" off \
  834. 29 $"Gujarati" off \
  835. 30 $"Hebrew" off \
  836. 31 $"Hindi" off \
  837. 32 $"Hungarian" off \
  838. 33 $"Icelandic" off \
  839. 34 $"Indonesian" off \
  840. 35 $"Italian" off \
  841. 36 $"Japanese" off \
  842. 37 $"Kannada" off \
  843. 38 $"Khmer" off \
  844. 39 $"Korean" off \
  845. 40 $"Lao" off \
  846. 41 $"Lithuanian" off \
  847. 42 $"Latvian" off \
  848. 43 $"Malayalam" off \
  849. 44 $"Malaysian" off \
  850. 45 $"Maori (Ngai Tahu)" off \
  851. 46 $"Maori (Waikoto Uni)" off \
  852. 47 $"Mongolian" off \
  853. 48 $"Norwegian" off \
  854. 49 $"Norwegian (Primary)" off \
  855. 50 $"Nynorsk" off \
  856. 51 $"Polish" off \
  857. 52 $"Portuguese" off \
  858. 53 $"Portuguese (Brazil)" off \
  859. 54 $"Romanian" off \
  860. 55 $"Russian" off \
  861. 56 $"Samoan" off \
  862. 57 $"Serbian" off \
  863. 58 $"Slovak" off \
  864. 59 $"Slovenian" off \
  865. 60 $"Somali" off \
  866. 61 $"Spanish (International)" off \
  867. 62 $"Swedish" off \
  868. 63 $"Tagalog" off \
  869. 64 $"Tamil" off \
  870. 65 $"Thai" off \
  871. 66 $"Turkish" off \
  872. 67 $"Ukrainian" off \
  873. 68 $"Vietnamese" off 2> $data
  874. sel=$?
  875. case $sel in
  876. 1) exit 1;;
  877. 255) exit 1;;
  878. esac
  879. case $(cat $data) in
  880. 1) DEFAULT_LANGUAGE='af_ZA.UTF-8';;
  881. 2) DEFAULT_LANGUAGE='sq_AL.UTF-8';;
  882. 3) DEFAULT_LANGUAGE='ar_SA.UTF-8';;
  883. 4) DEFAULT_LANGUAGE='eu_ES.UTF-8';;
  884. 5) DEFAULT_LANGUAGE='be_BY.UTF-8';;
  885. 6) DEFAULT_LANGUAGE='bs_BA.UTF-8';;
  886. 7) DEFAULT_LANGUAGE='bg_BG.UTF-8';;
  887. 8) DEFAULT_LANGUAGE='ca_ES.UTF-8';;
  888. 9) DEFAULT_LANGUAGE='hr_HR.UTF-8';;
  889. 10) DEFAULT_LANGUAGE='zh_CN.UTF-8';;
  890. 11) DEFAULT_LANGUAGE='zh_TW.UTF-8';;
  891. 12) DEFAULT_LANGUAGE='cs_CZ.UTF-8';;
  892. 13) DEFAULT_LANGUAGE='da_DK.UTF-8';;
  893. 14) DEFAULT_LANGUAGE='nl_NL.UTF-8';;
  894. 15) DEFAULT_LANGUAGE='en_GB.UTF-8';;
  895. 16) DEFAULT_LANGUAGE='en_US.UTF-8';;
  896. 17) DEFAULT_LANGUAGE='et_EE.UTF-8';;
  897. 18) DEFAULT_LANGUAGE='fa_IR.UTF-8';;
  898. 19) DEFAULT_LANGUAGE='ph_PH.UTF-8';;
  899. 20) DEFAULT_LANGUAGE='fi_FI.UTF-8';;
  900. 21) DEFAULT_LANGUAGE='fr_FR.UTF-8';;
  901. 22) DEFAULT_LANGUAGE='fr_CA.UTF-8';;
  902. 23) DEFAULT_LANGUAGE='ga.UTF-8';;
  903. 24) DEFAULT_LANGUAGE='l_ES.UTF-8';;
  904. 25) DEFAULT_LANGUAGE='ka_GE.UTF-8';;
  905. 26) DEFAULT_LANGUAGE='de_DE.UTF-8';;
  906. 27) DEFAULT_LANGUAGE='de_DE.UTF-8';;
  907. 28) DEFAULT_LANGUAGE='el_GR.UTF-8';;
  908. 29) DEFAULT_LANGUAGE='gu.UTF-8';;
  909. 30) DEFAULT_LANGUAGE='he_IL.utf8';;
  910. 31) DEFAULT_LANGUAGE='hi_IN.UTF-8';;
  911. 32) DEFAULT_LANGUAGE='hu.UTF-8';;
  912. 33) DEFAULT_LANGUAGE='is_IS.UTF-8';;
  913. 34) DEFAULT_LANGUAGE='id_ID.UTF-8';;
  914. 35) DEFAULT_LANGUAGE='it_IT.UTF-8';;
  915. 36) DEFAULT_LANGUAGE='ja_JP.UTF-8';;
  916. 37) DEFAULT_LANGUAGE='kn_IN.UTF-8';;
  917. 38) DEFAULT_LANGUAGE='km_KH.UTF-8';;
  918. 39) DEFAULT_LANGUAGE='ko_KR.UTF-8';;
  919. 40) DEFAULT_LANGUAGE='lo_LA.UTF-8';;
  920. 41) DEFAULT_LANGUAGE='lt_LT.UTF-8';;
  921. 42) DEFAULT_LANGUAGE='lat.UTF-8';;
  922. 43) DEFAULT_LANGUAGE='ml_IN.UTF-8';;
  923. 44) DEFAULT_LANGUAGE='ms_MY.UTF-8';;
  924. 45) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
  925. 46) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
  926. 47) DEFAULT_LANGUAGE='mn.UTF-8';;
  927. 48) DEFAULT_LANGUAGE='no_NO.UTF-8';;
  928. 49) DEFAULT_LANGUAGE='no_NO.UTF-8';;
  929. 50) DEFAULT_LANGUAGE='nn_NO.UTF-8';;
  930. 51) DEFAULT_LANGUAGE='pl.UTF-8';;
  931. 52) DEFAULT_LANGUAGE='pt_PT.UTF-8';;
  932. 53) DEFAULT_LANGUAGE='pt_BR.UTF-8';;
  933. 54) DEFAULT_LANGUAGE='ro_RO.UTF-8';;
  934. 55) DEFAULT_LANGUAGE='ru_RU.UTF-8';;
  935. 56) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
  936. 57) DEFAULT_LANGUAGE='sr_CS.UTF-8';;
  937. 58) DEFAULT_LANGUAGE='sk_SK.UTF-8';;
  938. 59) DEFAULT_LANGUAGE='sl_SI.UTF-8';;
  939. 60) DEFAULT_LANGUAGE='so_SO.UTF-8';;
  940. 61) DEFAULT_LANGUAGE='es_ES.UTF-8';;
  941. 62) DEFAULT_LANGUAGE='sv_SE.UTF-8';;
  942. 63) DEFAULT_LANGUAGE='tl.UTF-8';;
  943. 64) DEFAULT_LANGUAGE='ta_IN.UTF-8';;
  944. 65) DEFAULT_LANGUAGE='th_TH.UTF-8';;
  945. 66) DEFAULT_LANGUAGE='tr_TR.UTF-8';;
  946. 67) DEFAULT_LANGUAGE='uk_UA.UTF-8';;
  947. 68) DEFAULT_LANGUAGE='vi_VN.UTF-8';;
  948. esac
  949. save_configuration_values
  950. locale-gen "${DEFAULT_LANGUAGE}"
  951. update-locale LANG=${DEFAULT_LANGUAGE}
  952. update-locale LANGUAGE=${DEFAULT_LANGUAGE}
  953. update-locale LC_MESSAGES=${DEFAULT_LANGUAGE}
  954. update-locale LC_ALL=${DEFAULT_LANGUAGE}
  955. update-locale LC_CTYPE=${DEFAULT_LANGUAGE}
  956. }
  957. function select_user {
  958. SELECTED_USERNAME=
  959. users_array=($(ls /home))
  960. delete=(mirrors git)
  961. for del in ${delete[@]}
  962. do
  963. users_array=(${users_array[@]/$del})
  964. done
  965. i=0
  966. W=()
  967. name=()
  968. for u in ${users_array[@]}
  969. do
  970. if [[ $(is_valid_user "$u") == "1" ]]; then
  971. i=$((i+1))
  972. W+=($i "$u")
  973. name+=("$u")
  974. fi
  975. done
  976. if [ $i -eq 1 ]; then
  977. SELECTED_USERNAME="${name[0]}"
  978. else
  979. user_index=$(dialog --backtitle $"Freedombone Configuration" --title $"Select User" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
  980. if [ $? -eq 0 ]; then
  981. SELECTED_USERNAME="${name[$((user_index-1))]}"
  982. fi
  983. fi
  984. }
  985. function interactive_config {
  986. # create a temporary copy of the configuration file
  987. # which can be used to pre-populate selections
  988. if [ -f $CONFIGURATION_FILE ]; then
  989. cp $CONFIGURATION_FILE temp.cfg
  990. fi
  991. interactive_select_language
  992. if [[ $ONION_ONLY == "no" ]]; then
  993. INITIAL_MESSAGE=$"Welcome to the Freedombone interactive installer. Communications freedom is only a short time away.\n\nEnsure that you have your domain and dynamic DNS settings ready.\n\nFor more information please visit $FREEDOMBONE_WEBSITE."
  994. else
  995. INITIAL_MESSAGE=$"Welcome to the Freedombone interactive installer. Communications freedom is only a short time away.\n\nWeb sites created will only be viewable within a Tor browser.\n\nFor more information please visit $FREEDOMBONE_WEBSITE."
  996. fi
  997. dialog --title $"Freedombone" --msgbox "$INITIAL_MESSAGE" 15 50
  998. #choose_system_variant
  999. set_main_repo
  1000. choose_username
  1001. choose_full_name
  1002. choose_social_key_management
  1003. choose_rng
  1004. choose_debian_repo
  1005. choose_dns
  1006. ${PROJECT_NAME}-wifi --networksinteractive $WIFI_NETWORKS_FILE
  1007. choose_dynamic_dns
  1008. choose_default_domain_name
  1009. choose_email_address
  1010. interactive_key_recovery
  1011. # delete the temporary configuration file
  1012. if [ -f temp.cfg ]; then
  1013. shred -zu temp.cfg
  1014. fi
  1015. # This file indicates that the configuration happened successfully
  1016. touch $HOME/.${PROJECT_NAME}-interactive
  1017. }
  1018. function show_result {
  1019. #clear
  1020. echo ''
  1021. echo -n $"Configuration filename:"
  1022. echo " $CONFIGURATION_FILE"
  1023. echo ''
  1024. echo $'Contents:'
  1025. echo ''
  1026. cat $CONFIGURATION_FILE
  1027. echo ''
  1028. }
  1029. if [ ! $CONFIGURATION_FILE ]; then
  1030. CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
  1031. fi
  1032. read_configuration_values
  1033. interactive_config
  1034. #show_result
  1035. exit 0