freedombone-config 39KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  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. chmod 600 /etc/shadow
  612. chmod 600 /etc/gshadow
  613. useradd -m -s /bin/bash $MY_USERNAME
  614. chmod 0000 /etc/shadow
  615. chmod 0000 /etc/gshadow
  616. if [ -d /home/$MY_USERNAME ]; then
  617. echo "${MY_USERNAME}:$(printf `cat $IMAGE_PASSWORD_FILE`)" | chpasswd
  618. # Add the user as a sudoer - they will be the new admin user
  619. if ! grep -q "$MY_USERNAME ALL=(ALL) ALL" /etc/sudoers; then
  620. echo "$MY_USERNAME ALL=(ALL) ALL" >> /etc/sudoers
  621. # remove the generic image admin user from sudoers
  622. sed -i "s|${GENERIC_IMAGE_USERNAME}.*||g" /etc/sudoers
  623. fi
  624. break
  625. fi
  626. fi
  627. fi
  628. fi
  629. fi
  630. ;;
  631. 1) exit 1;;
  632. 255) exit 1;;
  633. esac
  634. done
  635. else
  636. no_of_users=$(find /home/* -maxdepth 0 -type d | wc -l)
  637. if [ $no_of_users -eq 1 ]; then
  638. # only a single user on the system
  639. MY_USERNAME=$(ls /home)
  640. else
  641. # select one from a number of users
  642. select_user
  643. if [ ! $SELECTED_USERNAME ]; then
  644. echo $'No username selected'
  645. exit 72589
  646. fi
  647. MY_USERNAME="$SELECTED_USERNAME"
  648. fi
  649. fi
  650. if [ ! $MY_USERNAME ]; then
  651. echo $'No user account was selected'
  652. exit 64398
  653. fi
  654. if [[ $MY_USERNAME == '-f' ]]; then
  655. echo $'No user account was selected'
  656. exit 8347
  657. fi
  658. if [[ $MY_USERNAME == 'debian' || $MY_USERNAME == 'fbone' ]]; then
  659. echo $"Don't use the default user account"
  660. exit 9341
  661. fi
  662. if [ ! -d /home/$MY_USERNAME ]; then
  663. echo $"The directory /home/$MY_USERNAME does not exist"
  664. exit 6437
  665. fi
  666. save_configuration_values
  667. }
  668. function choose_full_name {
  669. valid_name=
  670. while [ ! $valid_name ]
  671. do
  672. data=$(tempfile 2>/dev/null)
  673. trap "rm -f $data" 0 1 2 5 15
  674. dialog --backtitle $"Freedombone Configuration" \
  675. --inputbox $"Your full name (or nick)" 10 30 "$(grep 'MY_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
  676. sel=$?
  677. case $sel in
  678. 0) possible_name=$(cat $data)
  679. if [ "$possible_name" ]; then
  680. if [ ${#possible_name} -gt 1 ]; then
  681. valid_name="$possible_name"
  682. MY_NAME="$possible_name"
  683. break;
  684. fi
  685. fi
  686. ;;
  687. 1) exit 1;;
  688. 255) exit 1;;
  689. esac
  690. done
  691. save_configuration_values
  692. }
  693. function choose_system_variant {
  694. available_variants_list=()
  695. available_system_variants
  696. varslist=""
  697. n=1
  698. for a in "${available_variants_list[@]}"
  699. do
  700. varstate='off'
  701. if [[ "$a" == $'full' || "$a" == $'Full' ]]; then
  702. varstate='on'
  703. fi
  704. varslist="$varslist $n $a $varstate"
  705. n=$[n+1]
  706. done
  707. variant_choice=$(dialog --stdout --backtitle $"Freedombone Configuration" \
  708. --title $"Type of Installation" \
  709. --radiolist $'Choose:' \
  710. 27 40 20 $varslist)
  711. if [ $? -eq 0 ]; then
  712. variant_choice=$[variant_choice-1]
  713. SYSTEM_TYPE=${available_variants_list[$variant_choice]}
  714. save_configuration_values
  715. fi
  716. }
  717. function validate_freedns_code {
  718. freedns_code="$1"
  719. 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."
  720. if [[ "$freedns_code" == *"."* || "$freedns_code" == "http"* || "$freedns_code" == *"wget "* || "$freedns_code" == *" "* ]]; then
  721. dialog --title $"Invalid FreeDNS Code" --msgbox "$FREEDNS_MESSAGE" 10 70
  722. VALID_CODE=
  723. fi
  724. if [ ${#freedns_code} -lt 30 ]; then
  725. dialog --title $"Invalid FreeDNS Code" --msgbox $'FreeDNS code is too short. Did you enter the entire code?' 6 70
  726. VALID_CODE=
  727. fi
  728. VALID_CODE='yes'
  729. }
  730. # Get the commandline options
  731. while [[ $# > 1 ]]
  732. do
  733. key="$1"
  734. case $key in
  735. -h|--help)
  736. show_help
  737. ;;
  738. # Configuration filename
  739. -f|--filename)
  740. shift
  741. CONFIGURATION_FILE="$1"
  742. ;;
  743. # Minimum password length
  744. -m|--min)
  745. shift
  746. MINIMUM_PASSWORD_LENGTH="$1"
  747. ;;
  748. # Freedombone website
  749. -w|--www)
  750. shift
  751. FREEDOMBONE_WEBSITE="$1"
  752. ;;
  753. --minimal)
  754. shift
  755. MINIMAL_INSTALL="$1"
  756. ;;
  757. -o|--onion)
  758. shift
  759. ONION_ONLY="$1"
  760. ;;
  761. *)
  762. # unknown option
  763. ;;
  764. esac
  765. shift
  766. done
  767. function set_main_repo {
  768. data=$(tempfile 2>/dev/null)
  769. trap "rm -f $data" 0 1 2 5 15
  770. dialog --backtitle $"Freedombone Control Panel" \
  771. --title $"Main Repository (Mirrors)" \
  772. --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 \
  773. $"URL:" 1 1 "$FRIENDS_MIRRORS_SERVER" 1 18 40 18 \
  774. $"SSH Port:" 2 1 "$FRIENDS_MIRRORS_SSH_PORT" 2 18 10 10000 \
  775. $"Password:" 3 1 "$FRIENDS_MIRRORS_PASSWORD" 3 18 40 10000 \
  776. 2> $data
  777. sel=$?
  778. case $sel in
  779. 1) return;;
  780. 255) return;;
  781. esac
  782. new_mirrors_url=$(cat $data | sed -n 1p)
  783. new_mirrors_ssh_port=$(cat $data | sed -n 2p)
  784. new_mirrors_password=$(cat $data | sed -n 3p)
  785. if [ ${#new_mirrors_url} -lt 2 ]; then
  786. return
  787. fi
  788. if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
  789. return
  790. fi
  791. if [ ${#new_mirrors_password} -lt 10 ]; then
  792. dialog --title $"Main Repository" \
  793. --msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
  794. return
  795. fi
  796. if [[ $new_mirrors_url == *"."* ]]; then
  797. FRIENDS_MIRRORS_SERVER=$new_mirrors_url
  798. FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port
  799. FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password
  800. dialog --title $"Main Repository" \
  801. --msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
  802. fi
  803. save_configuration_values
  804. }
  805. function interactive_select_language {
  806. data=$(tempfile 2>/dev/null)
  807. trap "rm -f $data" 0 1 2 5 15
  808. dialog --backtitle $"Freedombone Configuration" \
  809. --radiolist $"Select your language:" 26 40 24 \
  810. 1 $"Afrikaans" off \
  811. 2 $"Albanian" off \
  812. 3 $"Arabic" off \
  813. 4 $"Basque" off \
  814. 5 $"Belarusian" off \
  815. 6 $"Bosnian" off \
  816. 7 $"Bulgarian" off \
  817. 8 $"Catalan" off \
  818. 9 $"Croatian" off \
  819. 10 $"Chinese (Simplified)" off \
  820. 11 $"Chinese (Traditional)" off \
  821. 12 $"Czech" off \
  822. 13 $"Danish" off \
  823. 14 $"Dutch" off \
  824. 15 $"English" on \
  825. 16 $"English (US)" off \
  826. 17 $"Estonian" off \
  827. 18 $"Farsi" off \
  828. 19 $"Filipino" off \
  829. 20 $"Finnish" off \
  830. 21 $"French" off \
  831. 22 $"French (Canada)" off \
  832. 23 $"Gaelic" off \
  833. 24 $"Gallego" off \
  834. 25 $"Georgian" off \
  835. 26 $"German" off \
  836. 27 $"German (Personal)" off \
  837. 28 $"Greek" off \
  838. 29 $"Gujarati" off \
  839. 30 $"Hebrew" off \
  840. 31 $"Hindi" off \
  841. 32 $"Hungarian" off \
  842. 33 $"Icelandic" off \
  843. 34 $"Indonesian" off \
  844. 35 $"Italian" off \
  845. 36 $"Japanese" off \
  846. 37 $"Kannada" off \
  847. 38 $"Khmer" off \
  848. 39 $"Korean" off \
  849. 40 $"Lao" off \
  850. 41 $"Lithuanian" off \
  851. 42 $"Latvian" off \
  852. 43 $"Malayalam" off \
  853. 44 $"Malaysian" off \
  854. 45 $"Maori (Ngai Tahu)" off \
  855. 46 $"Maori (Waikoto Uni)" off \
  856. 47 $"Mongolian" off \
  857. 48 $"Norwegian" off \
  858. 49 $"Norwegian (Primary)" off \
  859. 50 $"Nynorsk" off \
  860. 51 $"Polish" off \
  861. 52 $"Portuguese" off \
  862. 53 $"Portuguese (Brazil)" off \
  863. 54 $"Romanian" off \
  864. 55 $"Russian" off \
  865. 56 $"Samoan" off \
  866. 57 $"Serbian" off \
  867. 58 $"Slovak" off \
  868. 59 $"Slovenian" off \
  869. 60 $"Somali" off \
  870. 61 $"Spanish (International)" off \
  871. 62 $"Swedish" off \
  872. 63 $"Tagalog" off \
  873. 64 $"Tamil" off \
  874. 65 $"Thai" off \
  875. 66 $"Turkish" off \
  876. 67 $"Ukrainian" off \
  877. 68 $"Vietnamese" off 2> $data
  878. sel=$?
  879. case $sel in
  880. 1) exit 1;;
  881. 255) exit 1;;
  882. esac
  883. case $(cat $data) in
  884. 1) DEFAULT_LANGUAGE='af_ZA.UTF-8';;
  885. 2) DEFAULT_LANGUAGE='sq_AL.UTF-8';;
  886. 3) DEFAULT_LANGUAGE='ar_SA.UTF-8';;
  887. 4) DEFAULT_LANGUAGE='eu_ES.UTF-8';;
  888. 5) DEFAULT_LANGUAGE='be_BY.UTF-8';;
  889. 6) DEFAULT_LANGUAGE='bs_BA.UTF-8';;
  890. 7) DEFAULT_LANGUAGE='bg_BG.UTF-8';;
  891. 8) DEFAULT_LANGUAGE='ca_ES.UTF-8';;
  892. 9) DEFAULT_LANGUAGE='hr_HR.UTF-8';;
  893. 10) DEFAULT_LANGUAGE='zh_CN.UTF-8';;
  894. 11) DEFAULT_LANGUAGE='zh_TW.UTF-8';;
  895. 12) DEFAULT_LANGUAGE='cs_CZ.UTF-8';;
  896. 13) DEFAULT_LANGUAGE='da_DK.UTF-8';;
  897. 14) DEFAULT_LANGUAGE='nl_NL.UTF-8';;
  898. 15) DEFAULT_LANGUAGE='en_GB.UTF-8';;
  899. 16) DEFAULT_LANGUAGE='en_US.UTF-8';;
  900. 17) DEFAULT_LANGUAGE='et_EE.UTF-8';;
  901. 18) DEFAULT_LANGUAGE='fa_IR.UTF-8';;
  902. 19) DEFAULT_LANGUAGE='ph_PH.UTF-8';;
  903. 20) DEFAULT_LANGUAGE='fi_FI.UTF-8';;
  904. 21) DEFAULT_LANGUAGE='fr_FR.UTF-8';;
  905. 22) DEFAULT_LANGUAGE='fr_CA.UTF-8';;
  906. 23) DEFAULT_LANGUAGE='ga.UTF-8';;
  907. 24) DEFAULT_LANGUAGE='l_ES.UTF-8';;
  908. 25) DEFAULT_LANGUAGE='ka_GE.UTF-8';;
  909. 26) DEFAULT_LANGUAGE='de_DE.UTF-8';;
  910. 27) DEFAULT_LANGUAGE='de_DE.UTF-8';;
  911. 28) DEFAULT_LANGUAGE='el_GR.UTF-8';;
  912. 29) DEFAULT_LANGUAGE='gu.UTF-8';;
  913. 30) DEFAULT_LANGUAGE='he_IL.utf8';;
  914. 31) DEFAULT_LANGUAGE='hi_IN.UTF-8';;
  915. 32) DEFAULT_LANGUAGE='hu.UTF-8';;
  916. 33) DEFAULT_LANGUAGE='is_IS.UTF-8';;
  917. 34) DEFAULT_LANGUAGE='id_ID.UTF-8';;
  918. 35) DEFAULT_LANGUAGE='it_IT.UTF-8';;
  919. 36) DEFAULT_LANGUAGE='ja_JP.UTF-8';;
  920. 37) DEFAULT_LANGUAGE='kn_IN.UTF-8';;
  921. 38) DEFAULT_LANGUAGE='km_KH.UTF-8';;
  922. 39) DEFAULT_LANGUAGE='ko_KR.UTF-8';;
  923. 40) DEFAULT_LANGUAGE='lo_LA.UTF-8';;
  924. 41) DEFAULT_LANGUAGE='lt_LT.UTF-8';;
  925. 42) DEFAULT_LANGUAGE='lat.UTF-8';;
  926. 43) DEFAULT_LANGUAGE='ml_IN.UTF-8';;
  927. 44) DEFAULT_LANGUAGE='ms_MY.UTF-8';;
  928. 45) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
  929. 46) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
  930. 47) DEFAULT_LANGUAGE='mn.UTF-8';;
  931. 48) DEFAULT_LANGUAGE='no_NO.UTF-8';;
  932. 49) DEFAULT_LANGUAGE='no_NO.UTF-8';;
  933. 50) DEFAULT_LANGUAGE='nn_NO.UTF-8';;
  934. 51) DEFAULT_LANGUAGE='pl.UTF-8';;
  935. 52) DEFAULT_LANGUAGE='pt_PT.UTF-8';;
  936. 53) DEFAULT_LANGUAGE='pt_BR.UTF-8';;
  937. 54) DEFAULT_LANGUAGE='ro_RO.UTF-8';;
  938. 55) DEFAULT_LANGUAGE='ru_RU.UTF-8';;
  939. 56) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
  940. 57) DEFAULT_LANGUAGE='sr_CS.UTF-8';;
  941. 58) DEFAULT_LANGUAGE='sk_SK.UTF-8';;
  942. 59) DEFAULT_LANGUAGE='sl_SI.UTF-8';;
  943. 60) DEFAULT_LANGUAGE='so_SO.UTF-8';;
  944. 61) DEFAULT_LANGUAGE='es_ES.UTF-8';;
  945. 62) DEFAULT_LANGUAGE='sv_SE.UTF-8';;
  946. 63) DEFAULT_LANGUAGE='tl.UTF-8';;
  947. 64) DEFAULT_LANGUAGE='ta_IN.UTF-8';;
  948. 65) DEFAULT_LANGUAGE='th_TH.UTF-8';;
  949. 66) DEFAULT_LANGUAGE='tr_TR.UTF-8';;
  950. 67) DEFAULT_LANGUAGE='uk_UA.UTF-8';;
  951. 68) DEFAULT_LANGUAGE='vi_VN.UTF-8';;
  952. esac
  953. save_configuration_values
  954. locale-gen "${DEFAULT_LANGUAGE}"
  955. update-locale LANG=${DEFAULT_LANGUAGE}
  956. update-locale LANGUAGE=${DEFAULT_LANGUAGE}
  957. update-locale LC_MESSAGES=${DEFAULT_LANGUAGE}
  958. update-locale LC_ALL=${DEFAULT_LANGUAGE}
  959. update-locale LC_CTYPE=${DEFAULT_LANGUAGE}
  960. }
  961. function select_user {
  962. SELECTED_USERNAME=
  963. users_array=($(ls /home))
  964. delete=(mirrors git)
  965. for del in ${delete[@]}
  966. do
  967. users_array=(${users_array[@]/$del})
  968. done
  969. i=0
  970. W=()
  971. name=()
  972. for u in ${users_array[@]}
  973. do
  974. if [[ $(is_valid_user "$u") == "1" ]]; then
  975. i=$((i+1))
  976. W+=($i "$u")
  977. name+=("$u")
  978. fi
  979. done
  980. if [ $i -eq 1 ]; then
  981. SELECTED_USERNAME="${name[0]}"
  982. else
  983. 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)
  984. if [ $? -eq 0 ]; then
  985. SELECTED_USERNAME="${name[$((user_index-1))]}"
  986. fi
  987. fi
  988. }
  989. function interactive_config {
  990. # create a temporary copy of the configuration file
  991. # which can be used to pre-populate selections
  992. if [ -f $CONFIGURATION_FILE ]; then
  993. cp $CONFIGURATION_FILE temp.cfg
  994. fi
  995. interactive_select_language
  996. if [[ $ONION_ONLY == "no" ]]; then
  997. 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."
  998. else
  999. 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."
  1000. fi
  1001. dialog --title $"Freedombone" --msgbox "$INITIAL_MESSAGE" 15 50
  1002. #choose_system_variant
  1003. set_main_repo
  1004. choose_username
  1005. choose_full_name
  1006. choose_social_key_management
  1007. choose_rng
  1008. choose_debian_repo
  1009. choose_dns
  1010. ${PROJECT_NAME}-wifi --networksinteractive $WIFI_NETWORKS_FILE
  1011. choose_dynamic_dns
  1012. choose_default_domain_name
  1013. choose_email_address
  1014. interactive_key_recovery
  1015. # delete the temporary configuration file
  1016. if [ -f temp.cfg ]; then
  1017. shred -zu temp.cfg
  1018. fi
  1019. # This file indicates that the configuration happened successfully
  1020. touch $HOME/.${PROJECT_NAME}-interactive
  1021. }
  1022. function show_result {
  1023. #clear
  1024. echo ''
  1025. echo -n $"Configuration filename:"
  1026. echo " $CONFIGURATION_FILE"
  1027. echo ''
  1028. echo $'Contents:'
  1029. echo ''
  1030. cat $CONFIGURATION_FILE
  1031. echo ''
  1032. }
  1033. if [ ! $CONFIGURATION_FILE ]; then
  1034. CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
  1035. fi
  1036. read_configuration_values
  1037. interactive_config
  1038. #show_result
  1039. exit 0