freedombone-image-customise 46KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Based on bin/freedombox-customize from freedom-maker
  12. #
  13. # License
  14. # =======
  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. set -e
  29. set -x
  30. PROJECT_NAME='freedombone'
  31. INSTALL_DIR=/root/build
  32. COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
  33. PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
  34. VARIANT='full'
  35. # username created by default within a debian image
  36. GENERIC_IMAGE_USERNAME='fbone'
  37. export TEXTDOMAIN=${PROJECT_NAME}-image-customise
  38. export TEXTDOMAINDIR="/usr/share/locale"
  39. # Whether to minimise the number of decisions during interactive install
  40. MINIMAL_INSTALL="yes"
  41. MY_USERNAME='debian'
  42. MY_PASSWORD="${PROJECT_NAME}"
  43. # Minimum number of characters in a password
  44. MINIMUM_PASSWORD_LENGTH=10
  45. # IP address of the router (gateway)
  46. ROUTER_IP_ADDRESS="192.168.1.254"
  47. # The fixed IP address of the Beaglebone Black on your local network
  48. BOX_IP_ADDRESS="192.168.1.55"
  49. # DNS
  50. NAMESERVER1='213.73.91.35'
  51. NAMESERVER2='85.214.20.141'
  52. # optional configuration file containing freedombone settings
  53. CONFIG_FILENAME=
  54. # Optional ssh public key to allow
  55. SSH_PUBKEY="no"
  56. # Whether this is a generic image for mass redistribution on the interwebs
  57. GENERIC_IMAGE="no"
  58. # default SSH port
  59. SSH_PORT=2222
  60. # for mesh installs
  61. TRACKER_PORT=6969
  62. # Whether sites are accessible only within a Tor browser
  63. ONION_ONLY="no"
  64. # Whether to only install debian and nothing else
  65. DEBIAN_INSTALL_ONLY="no"
  66. # wifi settings
  67. WIFI_INTERFACE='wlan0'
  68. WIFI_SSID=
  69. WIFI_TYPE='wpa2-psk'
  70. WIFI_PASSPHRASE=
  71. WIFI_HOTSPOT='no'
  72. WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
  73. enable_eatmydata_override() {
  74. chroot $rootdir apt-get install --no-install-recommends -y eatmydata
  75. if [ -x $rootdir/usr/bin/eatmydata ] && \
  76. [ ! -f $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata ]; then
  77. echo $"info: Adding apt config to call dpkg via eatmydata"
  78. printf "#!/bin/sh\nexec eatmydata dpkg \"\$@\"\n" \
  79. > $rootdir/var/tmp/dpkg-eatmydata
  80. chmod 755 $rootdir/var/tmp/dpkg-eatmydata
  81. cat > $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata <<EOF
  82. Dir::Bin::dpkg "/var/tmp/dpkg-eatmydata";
  83. EOF
  84. else
  85. echo $"error: unable to find /usr/bin/eatmydata after installing the eatmydata package"
  86. fi
  87. }
  88. disable_eatmydata_override() {
  89. for override in \
  90. /etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata \
  91. /var/tmp/dpkg-eatmydata ; do
  92. echo $"info: Removing apt config to call dpkg via eatmydata"
  93. if [ -f $rootdir$override ] ; then
  94. rm -f $rootdir$override
  95. else
  96. echo $"warning: missing $rootdir$override"
  97. fi
  98. done
  99. sync # Flush file buffers before continuing
  100. }
  101. set_apt_sources() {
  102. NEW_MIRROR="$1"
  103. COMPONENTS="main"
  104. cat <<EOF > etc/apt/sources.list
  105. deb $NEW_MIRROR $SUITE $COMPONENTS
  106. deb-src $NEW_MIRROR $SUITE $COMPONENTS
  107. #deb http://security.debian.org/ $SUITE/updates main
  108. #deb-src http://security.debian.org/ $SUITE/updates main
  109. EOF
  110. }
  111. configure_networking() {
  112. if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
  113. return
  114. fi
  115. if [[ $GENERIC_IMAGE == "no" ]]; then
  116. echo "# This file describes the network interfaces available on your system
  117. # and how to activate them. For more information, see interfaces(5).
  118. # The loopback network interface
  119. auto lo
  120. iface lo inet loopback
  121. # The primary network interface
  122. auto eth0
  123. iface eth0 inet static
  124. address $BOX_IP_ADDRESS
  125. netmask 255.255.255.0
  126. gateway $ROUTER_IP_ADDRESS
  127. dns-nameservers $NAMESERVER1 $NAMESERVER2
  128. # Example to keep MAC address between reboots
  129. #hwaddress ether B5:A2:BE:3F:1A:FE
  130. # The secondary network interface
  131. #auto eth1
  132. #iface eth1 inet dhcp
  133. # WiFi Example
  134. #auto wlan0
  135. #iface wlan0 inet dhcp
  136. # wpa-ssid \"essid\"
  137. # wpa-psk \"password\"
  138. # Ethernet/RNDIS gadget (g_ether)
  139. # ... or on host side, usbnet and random hwaddr
  140. # Note on some boards, usb0 is automaticly setup with an init script
  141. #iface usb0 inet static
  142. # address 192.168.7.2
  143. # netmask 255.255.255.0
  144. # network 192.168.7.0
  145. # gateway 192.168.7.1" > $rootdir/etc/network/interfaces
  146. hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
  147. a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  148. b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  149. c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  150. d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  151. e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  152. sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \
  153. $rootdir/etc/network/interfaces
  154. fi
  155. sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
  156. sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
  157. # change the motd to show further install instructions
  158. echo $"
  159. .---. . .
  160. | | |
  161. |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  162. | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  163. ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  164. Initial base install
  165. Your system is not yet installed. To complete the process run the
  166. following commands, then enter your details.
  167. sudo su
  168. ${PROJECT_NAME} menuconfig
  169. " > $rootdir/etc/motd
  170. }
  171. configure_ssh() {
  172. sed -i "s/Port .*/Port ${SSH_PORT}/g" $rootdir/etc/ssh/sshd_config
  173. if [[ "$SSH_PUBKEY" != "no" ]]; then
  174. if [ ! -d $rootdir/home/$MY_USERNAME/.ssh ]; then
  175. mkdir $rootdir/home/$MY_USERNAME/.ssh
  176. fi
  177. echo "$SSH_PUBKEY" > $rootdir/home/$MY_USERNAME/.ssh/authorized_keys
  178. chroot $rootdir chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
  179. sed -i 's|PasswordAuthentication.*|PasswordAuthentication no|g' $rootdir/etc/ssh/sshd_config
  180. echo $"Using ssh public key:"
  181. echo $SSH_PUBKEY
  182. echo $'Password ssh authentication turned off'
  183. fi
  184. }
  185. admin_user_sudo() {
  186. echo "$MY_USERNAME ALL=(ALL) ALL" >> $rootdir/etc/sudoers
  187. }
  188. create_generic_image() {
  189. if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
  190. return
  191. fi
  192. if [[ $GENERIC_IMAGE == "no" ]]; then
  193. return
  194. fi
  195. if [ $CONFIG_FILENAME ]; then
  196. if [[ "$CONFIG_FILENAME" == *"mesh.cfg"* ]]; then
  197. VARIANT="mesh"
  198. fi
  199. fi
  200. # Don't install any configuration. This will be a base system
  201. if [[ $VARIANT != "mesh" && $VARIANT != "meshclient" ]]; then
  202. CONFIG_FILENAME=
  203. else
  204. touch $rootdir/root/.initial_mesh_setup
  205. fi
  206. # The presence of this file indicates that the initial
  207. # setup has not yet been completed
  208. touch $rootdir/home/$MY_USERNAME/.initial_setup
  209. chroot $rootdir chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.initial_setup
  210. touch $rootdir/root/.initial_setup
  211. cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF
  212. # initial setup of the system
  213. if [ -f ~/.initial_setup ]; then
  214. clear
  215. echo "
  216. .---. . .
  217. | | |
  218. |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  219. | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  220. ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  221. Initial setup process
  222. Please enter your password a second time.
  223. "
  224. sudo su
  225. fi
  226. EOF
  227. echo '# initial setup of the system' >> $rootdir/root/.bashrc
  228. echo 'if [ -f ~/.initial_setup ]; then' >> $rootdir/root/.bashrc
  229. echo ' if [ -f ~/login.txt ]; then' >> $rootdir/root/.bashrc
  230. echo ' NEW_USER_PASSWORD=$(printf `cat ~/login.txt`)' >> $rootdir/root/.bashrc
  231. echo ' else' >> $rootdir/root/.bashrc
  232. echo ' ENTROPY=$(cat /proc/sys/kernel/random/entropy_avail)' >> $rootdir/root/.bashrc
  233. echo ' if [ $ENTROPY -lt 500 ]; then' >> $rootdir/root/.bashrc
  234. ENTROPY_MESSAGE1=$'Initial setup process'
  235. ENTROPY_MESSAGE2=$'Password Generation'
  236. ENTROPY_MESSAGE3=$'WARNING: The entropy available on this system is too low to generate a password.\n\nThe installation process cannot continue.'
  237. echo " dialog --backtitle \"${ENTROPY_MESSAGE1}\" --title \"${ENTROPY_MESSAGE2}\" --msgbox \"${ENTROPY_MESSAGE3}\" 8 50" >> $rootdir/root/.bashrc
  238. echo ' exit' >> $rootdir/root/.bashrc
  239. echo ' fi' >> $rootdir/root/.bashrc
  240. echo -n ' NEW_USER_PASSWORD="$(openssl rand -base64 30 | cut -c1-' >> $rootdir/root/.bashrc
  241. echo "${MINIMUM_PASSWORD_LENGTH})\"" >> $rootdir/root/.bashrc
  242. echo ' fi' >> $rootdir/root/.bashrc
  243. echo ' echo "${NEW_USER_PASSWORD}" > ~/login.txt' >> $rootdir/root/.bashrc
  244. echo ' clear' >> $rootdir/root/.bashrc
  245. echo ' echo ""' >> $rootdir/root/.bashrc
  246. NEW_LOGIN_PASSWORD_MESSAGE1=$'Your new login password is:'
  247. NEW_LOGIN_PASSWORD_MESSAGE2=$'Use it whenever you wish to ssh into this system.'
  248. NEW_LOGIN_PASSWORD_MESSAGE3=$'IMPORTANT: Please take a moment to enter the above password into a\npassword manager or write it down somewhere.'
  249. PRESS_KEY_MESSAGE=$'Press any key to continue...'
  250. echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE1}\"" >> $rootdir/root/.bashrc
  251. echo ' echo ""' >> $rootdir/root/.bashrc
  252. echo ' toilet "${NEW_USER_PASSWORD}"' >> $rootdir/root/.bashrc
  253. echo ' echo ""' >> $rootdir/root/.bashrc
  254. echo ' echo " ${NEW_USER_PASSWORD}"' >> $rootdir/root/.bashrc
  255. echo ' echo ""' >> $rootdir/root/.bashrc
  256. echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE2}\"" >> $rootdir/root/.bashrc
  257. echo ' echo ""' >> $rootdir/root/.bashrc
  258. echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE3}\"" >> $rootdir/root/.bashrc
  259. echo ' echo ""' >> $rootdir/root/.bashrc
  260. echo " read -n1 -r -p \"${PRESS_KEY_MESSAGE}\" key" >> $rootdir/root/.bashrc
  261. # change the password for the admin user
  262. echo -n " echo \"${MY_USERNAME}:" >> $rootdir/root/.bashrc
  263. echo '$(printf `cat ~/login.txt`)"|chpasswd' >> $rootdir/root/.bashrc
  264. # update before continuing
  265. echo " cd /root/${PROJECT_NAME}" >> $rootdir/root/.bashrc
  266. echo " git stash" >> $rootdir/root/.bashrc
  267. echo " git pull" >> $rootdir/root/.bashrc
  268. echo " make install" >> $rootdir/root/.bashrc
  269. if [[ $VARIANT != "mesh" && $VARIANT != "meshclient" && $VARIANT != "usb" ]]; then
  270. if [[ $ONION_ONLY == "no" ]]; then
  271. if [[ $MINIMAL_INSTALL == "no" ]]; then
  272. echo " ${PROJECT_NAME} menuconfig-full" >> $rootdir/root/.bashrc
  273. else
  274. echo " ${PROJECT_NAME} menuconfig" >> $rootdir/root/.bashrc
  275. fi
  276. else
  277. echo " ${PROJECT_NAME} menuconfig-onion" >> $rootdir/root/.bashrc
  278. fi
  279. else
  280. echo " echo ''" >> $rootdir/root/.bashrc
  281. fi
  282. echo ' if [ "$?" = "0" ]; then' >> $rootdir/root/.bashrc
  283. echo " if [ -f ~/${PROJECT_NAME}-completed.txt ]; then" >> $rootdir/root/.bashrc
  284. # Remove the initial setup files
  285. echo ' rm /root/.initial_setup' >> $rootdir/root/.bashrc
  286. echo " rm /home/${MY_USERNAME}/.initial_setup" >> $rootdir/root/.bashrc
  287. echo " touch /root/.remove_${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
  288. echo ' shred -zu ~/login.txt' >> $rootdir/root/.bashrc
  289. END_MESSAGE1=$'Congratulations!'
  290. if [[ $VARIANT != "mesh" && $VARIANT != "meshclient" && $VARIANT != "usb" ]]; then
  291. END_MESSAGE2=$'\nYour system has now installed\n\nThe onion ssh service is at $SSH_ONION_HOSTNAME\n\nPress any key to reboot and begin using it'
  292. echo ' SSH_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_ssh/hostname)' >> $rootdir/root/.bashrc
  293. else
  294. END_MESSAGE2=$'\nYour system has now installed\n\nPress any key to reboot and begin using it'
  295. fi
  296. echo " dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" 9 50" >> $rootdir/root/.bashrc
  297. echo ' reboot' >> $rootdir/root/.bashrc
  298. echo ' fi' >> $rootdir/root/.bashrc
  299. echo ' else' >> $rootdir/root/.bashrc
  300. echo ' key=' >> $rootdir/root/.bashrc
  301. echo ' while [[ $key != "x" ]]; do' >> $rootdir/root/.bashrc
  302. INSTALL_FAIL_MESSAGE=$"Install failed. Press x to continue..."
  303. echo " read -n1 -r -p \"${INSTALL_FAIL_MESSAGE}\" key" >> $rootdir/root/.bashrc
  304. echo ' done' >> $rootdir/root/.bashrc
  305. echo ' fi' >> $rootdir/root/.bashrc
  306. echo ' exit' >> $rootdir/root/.bashrc
  307. echo 'else' >> $rootdir/root/.bashrc
  308. echo ' # Remove default account after install' >> $rootdir/root/.bashrc
  309. echo " if [ -f /root/.remove_${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
  310. echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
  311. echo " userdel -r ${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
  312. echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
  313. echo " rm -rf /home/${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
  314. echo " rm /root/.remove_${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
  315. echo ' fi' >> $rootdir/root/.bashrc
  316. echo ' fi' >> $rootdir/root/.bashrc
  317. echo ' fi' >> $rootdir/root/.bashrc
  318. echo 'fi' >> $rootdir/root/.bashrc
  319. }
  320. continue_installation() {
  321. # If a configuration file exists then run with it
  322. # otherwise the interactive installer can be used
  323. # This is equivalent to installing freedombox-setup on freedombox
  324. if [ $CONFIG_FILENAME ]; then
  325. if [ ${#CONFIG_FILENAME} -gt 2 ]; then
  326. cp $CONFIG_FILENAME $rootdir/root/$PROJECT_NAME.cfg
  327. cat $rootdir/root/$PROJECT_NAME.cfg
  328. chroot "$rootdir" su -c "$PROJECT_NAME -c /root/$PROJECT_NAME.cfg" - root
  329. fi
  330. fi
  331. }
  332. atheros_wifi() {
  333. firmware_filename="open-ath9k-htc-firmware_1.3-1_all.deb"
  334. firmware_hash='5fea58ffefdf0ef15b504db7fbe3bc078c03e0d927bba64085e4b6f2546102f5'
  335. firmware_url="http://us.archive.trisquel.info/trisquel/pool/main/o/open-ath9k-htc-firmware/$firmware_filename"
  336. firmware_tempfile="/tmp/$firmware_filename"
  337. wget "$firmware_url" -O "$rootdir$firmware_tempfile"
  338. downloaded_firmware_hash=$(sha256sum "$rootdir$firmware_tempfile" | awk -F ' ' '{print $1}')
  339. if [[ "$downloaded_firmware_hash" == "$firmware_hash" ]]; then
  340. chroot "$rootdir" dpkg -i "$firmware_tempfile"
  341. else
  342. echo 'WARNING: Atheros Wifi firmware hash does not match. The driver has not been installed.'
  343. fi
  344. }
  345. configure_wifi() {
  346. if [[ $VARIANT == "mesh" || $VARIANT == "meshclient" ]]; then
  347. return
  348. fi
  349. if [ -f $WIFI_NETWORKS_FILE ]; then
  350. chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE --networks $WIFI_NETWORKS_FILE
  351. return
  352. fi
  353. if [[ $WIFI_TYPE != 'none' ]]; then
  354. if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
  355. return
  356. fi
  357. chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $WIFI_HOTSPOT
  358. else
  359. chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $WIFI_HOTSPOT
  360. fi
  361. }
  362. ##############################################################################
  363. # Mesh networking
  364. ##############################################################################
  365. # for mesh installs
  366. TRACKER_PORT=6969
  367. WIFI_CHANNEL=2
  368. # B.A.T.M.A.N settings
  369. BATMAN_CELLID='02:BA:00:00:03:01'
  370. WIFI_SSID='mesh'
  371. # To avoid confusions these are obtained from the main project file
  372. TOXID_REPO=
  373. TOX_PORT=
  374. TOXCORE_REPO=
  375. TOXIC_REPO=
  376. TOXCORE_COMMIT=
  377. TOXIC_COMMIT=
  378. # These are some default nodes, but you can replace them with trusted nodes
  379. # as you prefer. See https://wiki.tox.im/Nodes
  380. TOX_NODES=
  381. #TOX_NODES=(
  382. # '192.254.75.102,2607:5600:284::2,33445,951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F,Tox RELENG,US'
  383. # '144.76.60.215,2a01:4f8:191:64d6::1,33445,04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F,sonOfRa,DE'
  384. #)
  385. # To avoid confusions these are obtained from the main project file
  386. ZERONET_REPO=
  387. ZERONET_COMMIT=
  388. ZERONET_PORT=
  389. # Directory where source code is downloaded and compiled
  390. INSTALL_DIR=$HOME/build
  391. function mesh_avahi {
  392. chroot "$rootdir" apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd
  393. decarray=( 1 2 3 4 5 6 7 8 9 0 )
  394. PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
  395. sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" $rootdir/etc/avahi/avahi-daemon.conf
  396. if [ ! -d $rootdir/etc/avahi/services ]; then
  397. mkdir -p $rootdir/etc/avahi/services
  398. fi
  399. # remove an avahi service which isn't used
  400. if [ -f $rootdir/etc/avahi/services/udisks.service ]; then
  401. rm $rootdir/etc/avahi/services/udisks.service
  402. fi
  403. # Add an ssh service
  404. echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > $rootdir/etc/avahi/services/ssh.service
  405. echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> $rootdir/etc/avahi/services/ssh.service
  406. echo '<service-group>' >> $rootdir/etc/avahi/services/ssh.service
  407. echo ' <name replace-wildcards="yes">%h SSH</name>' >> $rootdir/etc/avahi/services/ssh.service
  408. echo ' <service>' >> $rootdir/etc/avahi/services/ssh.service
  409. echo ' <type>_ssh._tcp</type>' >> $rootdir/etc/avahi/services/ssh.service
  410. echo " <port>$SSH_PORT</port>" >> $rootdir/etc/avahi/services/ssh.service
  411. echo ' </service>' >> $rootdir/etc/avahi/services/ssh.service
  412. echo '</service-group>' >> $rootdir/etc/avahi/services/ssh.service
  413. # keep the daemon running
  414. WATCHDOG_SCRIPT_NAME="keepon"
  415. echo '' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  416. echo '# keep avahi daemon running' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  417. echo 'AVAHI_RUNNING=$(pgrep avahi-daemon > /dev/null && echo Running)' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  418. echo 'if [ ! $AVAHI_RUNNING ]; then' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  419. echo ' systemctl start avahi-daemon' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  420. echo ' echo -n $CURRENT_DATE >> $LOGFILE' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  421. echo ' echo " Avahi daemon restarted" >> $LOGFILE' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  422. echo 'fi' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  423. chmod +x $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
  424. }
  425. function mesh_batman {
  426. chroot "$rootdir" apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
  427. chroot "$rootdir" apt-get -y install python-dev libevent-dev ebtables python-pip git
  428. chroot "$rootdir" apt-get -y install wireless-tools rfkill
  429. if ! grep -q "batman_adv" $rootdir/etc/modules; then
  430. echo 'batman_adv' >> $rootdir/etc/modules
  431. fi
  432. BATMAN_SCRIPT=$rootdir/var/lib/batman
  433. if [ -f /usr/local/bin/${PROJECT_NAME}-mesh-batman ]; then
  434. cp /usr/local/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
  435. else
  436. cp /usr/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
  437. fi
  438. BATMAN_DAEMON=$rootdir/etc/systemd/system/batman.service
  439. echo '[Unit]' > $BATMAN_DAEMON
  440. echo 'Description=B.A.T.M.A.N. Advanced' >> $BATMAN_DAEMON
  441. echo '' >> $BATMAN_DAEMON
  442. echo '[Service]' >> $BATMAN_DAEMON
  443. echo 'Type=oneshot' >> $BATMAN_DAEMON
  444. echo "ExecStart=/var/lib/batman start" >> $BATMAN_DAEMON
  445. echo "ExecStop=/var/lib/batman stop" >> $BATMAN_DAEMON
  446. echo 'RemainAfterExit=yes' >> $BATMAN_DAEMON
  447. echo '' >> $BATMAN_DAEMON
  448. echo '# Allow time for the server to start/stop' >> $BATMAN_DAEMON
  449. echo 'TimeoutSec=300' >> $BATMAN_DAEMON
  450. echo '' >> $BATMAN_DAEMON
  451. echo '[Install]' >> $BATMAN_DAEMON
  452. echo 'WantedBy=multi-user.target' >> $BATMAN_DAEMON
  453. chroot "$rootdir" systemctl enable batman
  454. }
  455. function mesh_firewall {
  456. FIREWALL_FILENAME=${rootdir}/etc/systemd/system/meshfirewall.service
  457. MESH_FIREWALL_SCRIPT=${rootdir}/usr/bin/mesh-firewall
  458. echo '#!/bin/bash' > $MESH_FIREWALL_SCRIPT
  459. echo 'iptables -P INPUT ACCEPT' >> $MESH_FIREWALL_SCRIPT
  460. echo 'ip6tables -P INPUT ACCEPT' >> $MESH_FIREWALL_SCRIPT
  461. echo 'iptables -F' >> $MESH_FIREWALL_SCRIPT
  462. echo 'ip6tables -F' >> $MESH_FIREWALL_SCRIPT
  463. echo 'iptables -t nat -F' >> $MESH_FIREWALL_SCRIPT
  464. echo 'ip6tables -t nat -F' >> $MESH_FIREWALL_SCRIPT
  465. echo 'iptables -X' >> $MESH_FIREWALL_SCRIPT
  466. echo 'ip6tables -X' >> $MESH_FIREWALL_SCRIPT
  467. echo 'iptables -P INPUT DROP' >> $MESH_FIREWALL_SCRIPT
  468. echo 'ip6tables -P INPUT DROP' >> $MESH_FIREWALL_SCRIPT
  469. echo 'iptables -A INPUT -i lo -j ACCEPT' >> $MESH_FIREWALL_SCRIPT
  470. echo 'iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT' >> $MESH_FIREWALL_SCRIPT
  471. echo '' >> $MESH_FIREWALL_SCRIPT
  472. echo '# Make sure incoming tcp connections are SYN packets' >> $MESH_FIREWALL_SCRIPT
  473. echo 'iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP' >> $MESH_FIREWALL_SCRIPT
  474. echo '' >> $MESH_FIREWALL_SCRIPT
  475. echo '# Drop packets with incoming fragments' >> $MESH_FIREWALL_SCRIPT
  476. echo 'iptables -A INPUT -f -j DROP' >> $MESH_FIREWALL_SCRIPT
  477. echo '' >> $MESH_FIREWALL_SCRIPT
  478. echo '# Drop bogons' >> $MESH_FIREWALL_SCRIPT
  479. echo 'iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP' >> $MESH_FIREWALL_SCRIPT
  480. echo 'iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP' >> $MESH_FIREWALL_SCRIPT
  481. echo 'iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP' >> $MESH_FIREWALL_SCRIPT
  482. echo '' >> $MESH_FIREWALL_SCRIPT
  483. echo '# Incoming malformed NULL packets:' >> $MESH_FIREWALL_SCRIPT
  484. echo 'iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP' >> $MESH_FIREWALL_SCRIPT
  485. echo '' >> $MESH_FIREWALL_SCRIPT
  486. echo "iptables -A INPUT -p tcp --dport $TOX_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
  487. echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
  488. echo "iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
  489. echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
  490. echo "iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
  491. echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport 1900 -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
  492. chmod +x $MESH_FIREWALL_SCRIPT
  493. echo '[Unit]' > $FIREWALL_FILENAME
  494. echo 'Description=Mesh Firewall' >> $FIREWALL_FILENAME
  495. echo '' >> $FIREWALL_FILENAME
  496. echo '[Service]' >> $FIREWALL_FILENAME
  497. echo 'Type=oneshot' >> $FIREWALL_FILENAME
  498. echo 'ExecStart=/usr/bin/mesh-firewall' >> $FIREWALL_FILENAME
  499. echo 'RemainAfterExit=no' >> $FIREWALL_FILENAME
  500. echo '' >> $FIREWALL_FILENAME
  501. echo 'TimeoutSec=30' >> $FIREWALL_FILENAME
  502. echo '' >> $FIREWALL_FILENAME
  503. echo '[Install]' >> $FIREWALL_FILENAME
  504. echo 'WantedBy=multi-user.target' >> $FIREWALL_FILENAME
  505. chroot "$rootdir" systemctl enable meshfirewall
  506. }
  507. function mesh_tox_node {
  508. # obtain commits from the main file
  509. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  510. TOXCORE_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
  511. else
  512. TOXCORE_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
  513. fi
  514. if [ ${#TOXCORE_COMMIT_MAIN} -gt 10 ]; then
  515. TOXCORE_COMMIT=$TOXCORE_COMMIT_MAIN
  516. fi
  517. if [ ! $TOXCORE_COMMIT ]; then
  518. echo $'No Tox commit was specified'
  519. exit 76325
  520. fi
  521. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  522. TOX_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
  523. else
  524. TOX_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
  525. fi
  526. if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
  527. TOX_PORT=$TOX_PORT_MAIN
  528. fi
  529. if [ ! $TOX_PORT ]; then
  530. echo $'No Tox port was specified'
  531. exit 32856
  532. fi
  533. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  534. TOXCORE_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  535. else
  536. TOXCORE_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  537. fi
  538. if [ ${#TOXCORE_REPO_MAIN} -gt 10 ]; then
  539. TOXCORE_REPO=$TOXCORE_REPO_MAIN
  540. fi
  541. if [ ! $TOXCORE_REPO ]; then
  542. echo $'No Tox repo was specified'
  543. exit 16865
  544. fi
  545. chroot "$rootdir" apt-get -y install build-essential libtool autotools-dev
  546. chroot "$rootdir" apt-get -y install automake checkinstall check git yasm
  547. chroot "$rootdir" apt-get -y install libsodium13 libsodium-dev libcap2-bin
  548. chroot "$rootdir" apt-get -y install libconfig9 libconfig-dev
  549. TEMP_SCRIPT_NAME=fbtmp37272.sh
  550. TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
  551. echo '#!/bin/bash' > $TEMP_SCRIPT
  552. echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
  553. echo "git clone $TOXCORE_REPO $INSTALL_DIR/toxcore" >> $TEMP_SCRIPT
  554. echo "cd $INSTALL_DIR/toxcore" >> $TEMP_SCRIPT
  555. echo "git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT" >> $TEMP_SCRIPT
  556. echo 'autoreconf -i' >> $TEMP_SCRIPT
  557. echo './configure --enable-daemon --disable-av' >> $TEMP_SCRIPT
  558. echo 'make' >> $TEMP_SCRIPT
  559. echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
  560. echo ' exit 1' >> $TEMP_SCRIPT
  561. echo 'fi' >> $TEMP_SCRIPT
  562. echo 'make install' >> $TEMP_SCRIPT
  563. echo 'cp /usr/local/lib/libtoxcore* /usr/lib/' >> $TEMP_SCRIPT
  564. echo "cp $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service /etc/systemd/system/" >> $TEMP_SCRIPT
  565. echo "sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' /etc/systemd/system/tox-bootstrapd.service" >> $TEMP_SCRIPT
  566. echo 'systemctl enable tox-bootstrapd.service' >> $TEMP_SCRIPT
  567. echo 'exit 0' >> $TEMP_SCRIPT
  568. chmod +x $TEMP_SCRIPT
  569. cp $TEMP_SCRIPT $rootdir/root/
  570. SECONDS=0
  571. chroot "$rootdir" /root/$TEMP_SCRIPT_NAME
  572. if [ ! "$?" = "0" ]; then
  573. duration=$SECONDS
  574. echo $"Toxcore compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
  575. echo $'Unable to make toxcore'
  576. rm $TEMP_SCRIPT
  577. exit 73835
  578. fi
  579. duration=$SECONDS
  580. echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
  581. rm $TEMP_SCRIPT
  582. if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
  583. echo $"File not found /usr/local/bin/tox-bootstrapd"
  584. exit 37825
  585. fi
  586. chroot "$rootdir" useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment $"Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
  587. chroot "$rootdir" chmod 700 /var/lib/tox-bootstrapd
  588. # remove Maildir
  589. if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
  590. rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
  591. fi
  592. # create configuration file
  593. TOX_BOOTSTRAP_CONFIG=$rootdir/etc/tox-bootstrapd.conf
  594. echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
  595. echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $TOX_BOOTSTRAP_CONFIG
  596. echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
  597. echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
  598. echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
  599. echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
  600. echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
  601. echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
  602. echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
  603. echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
  604. if [ $TOX_NODES ]; then
  605. echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
  606. toxcount=0
  607. while [ "x${TOX_NODES[toxcount]}" != "x" ]
  608. do
  609. toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
  610. toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
  611. toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
  612. toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
  613. toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
  614. echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
  615. if [[ $toxval_ipv6 != 'NONE' ]]; then
  616. echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
  617. else
  618. echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
  619. fi
  620. echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
  621. echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
  622. toxcount=$(( $toxcount + 1 ))
  623. if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
  624. echo "}," >> $TOX_BOOTSTRAP_CONFIG
  625. else
  626. echo "}" >> $TOX_BOOTSTRAP_CONFIG
  627. fi
  628. done
  629. echo ')' >> $TOX_BOOTSTRAP_CONFIG
  630. fi
  631. }
  632. function mesh_tox_avahi {
  633. if [ ! -d $rootdir/etc/avahi ]; then
  634. echo $'tox_avahi: avahi is not installed'
  635. exit 87359
  636. fi
  637. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  638. TOXID_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  639. else
  640. TOXID_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  641. fi
  642. if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then
  643. TOXID_REPO=$TOXID_REPO_MAIN
  644. fi
  645. if [ ! $TOXID_REPO ]; then
  646. echo $'No ToxID repo was specified'
  647. exit 78252
  648. fi
  649. TEMP_SCRIPT_NAME=fbtmp5328252.sh
  650. TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
  651. echo '#!/bin/bash' > $TEMP_SCRIPT
  652. echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
  653. echo "git clone $TOXID_REPO $INSTALL_DIR/toxid" >> $TEMP_SCRIPT
  654. echo "if [ ! -d $INSTALL_DIR/toxid ]; then" >> $TEMP_SCRIPT
  655. echo ' exit 1' >> $TEMP_SCRIPT
  656. echo 'fi' >> $TEMP_SCRIPT
  657. echo "cd $INSTALL_DIR/toxid" >> $TEMP_SCRIPT
  658. echo "make" >> $TEMP_SCRIPT
  659. echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
  660. echo ' exit 2' >> $TEMP_SCRIPT
  661. echo 'fi' >> $TEMP_SCRIPT
  662. echo 'make install' >> $TEMP_SCRIPT
  663. echo 'if [ ! -f /usr/local/bin/toxavahi ]; then' >> $TEMP_SCRIPT
  664. echo ' exit 3' >> $TEMP_SCRIPT
  665. echo 'fi' >> $TEMP_SCRIPT
  666. echo 'toxavahi' >> $TEMP_SCRIPT
  667. echo 'echo "* * * * * root /usr/local/bin/toxavahi > /dev/null" >> /etc/crontab' >> $TEMP_SCRIPT
  668. echo 'systemctl restart avahi-daemon' >> $TEMP_SCRIPT
  669. echo 'exit 0' >> $TEMP_SCRIPT
  670. chmod +x $TEMP_SCRIPT
  671. cp $TEMP_SCRIPT $rootdir/root/
  672. chroot "$rootdir" /root/$TEMP_SCRIPT_NAME
  673. if [ ! "$?" = "0" ]; then
  674. echo $"Unable to install toxid, returned $?"
  675. rm $TEMP_SCRIPT
  676. exit 62835
  677. fi
  678. rm $TEMP_SCRIPT
  679. }
  680. function mesh_tox_client {
  681. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  682. TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
  683. else
  684. TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
  685. fi
  686. # obtain commits from the main file
  687. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  688. TOXIC_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
  689. else
  690. TOXIC_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
  691. fi
  692. if [ ${#TOXIC_COMMIT_MAIN} -gt 10 ]; then
  693. TOXIC_COMMIT=$TOXIC_COMMIT_MAIN
  694. fi
  695. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  696. TOXIC_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  697. else
  698. TOXIC_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  699. fi
  700. if [ ${#TOXIC_REPO_MAIN} -gt 5 ]; then
  701. TOXIC_REPO=$TOXIC_REPO_MAIN
  702. fi
  703. chroot "$rootdir" apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
  704. chroot "$rootdir" apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
  705. TEMP_SCRIPT_NAME=fbtmp728353.sh
  706. TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
  707. echo '#!/bin/bash' > $TEMP_SCRIPT
  708. echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
  709. echo "git clone $TOXIC_REPO $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
  710. echo "cd $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
  711. echo "git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT" >> $TEMP_SCRIPT
  712. echo 'make' >> $TEMP_SCRIPT
  713. echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
  714. echo ' exit 1' >> $TEMP_SCRIPT
  715. echo 'fi' >> $TEMP_SCRIPT
  716. echo 'make install' >> $TEMP_SCRIPT
  717. echo 'exit 0' >> $TEMP_SCRIPT
  718. chmod +x $TEMP_SCRIPT
  719. cp $TEMP_SCRIPT $rootdir/root/
  720. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  721. TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
  722. else
  723. TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
  724. fi
  725. SECONDS=0
  726. chroot "$rootdir" /root/$TEMP_SCRIPT_NAME
  727. if [ ! "$?" = "0" ]; then
  728. duration=$SECONDS
  729. echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
  730. echo $'Unable to make tox client'
  731. rm $TEMP_SCRIPT
  732. exit 74872
  733. fi
  734. rm $TEMP_SCRIPT
  735. if [ ! -f $rootdir$TOXIC_FILE ]; then
  736. echo $"Tox client was not installed to $TOXIC_FILE"
  737. exit 63278
  738. fi
  739. duration=$SECONDS
  740. echo $"Toxic client compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
  741. }
  742. function mesh_zeronet {
  743. # obtain commits from the main file
  744. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  745. ZERONET_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
  746. else
  747. ZERONET_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
  748. fi
  749. if [ ${#ZERONET_COMMIT_MAIN} -gt 10 ]; then
  750. ZERONET_COMMIT=$ZERONET_COMMIT_MAIN
  751. fi
  752. if [ ! $ZERONET_COMMIT ]; then
  753. echo $'No Tox commit was specified'
  754. exit 37046
  755. fi
  756. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  757. ZERONET_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  758. else
  759. ZERONET_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_REPO=" | head -n 1 | awk -F '"' '{print $2}')
  760. fi
  761. if [ ${#ZERONET_REPO_MAIN} -gt 5 ]; then
  762. ZERONET_REPO=$ZERONET_REPO_MAIN
  763. fi
  764. if [ ! $ZERONET_REPO ]; then
  765. echo $'No Tox commit was specified'
  766. exit 37046
  767. fi
  768. if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
  769. ZERONET_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_PORT=" | head -n 1 | awk -F '=' '{print $2}')
  770. else
  771. ZERONET_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_PORT=" | head -n 1 | awk -F '=' '{print $2}')
  772. fi
  773. if [ ${#ZERONET_PORT_MAIN} -gt 1 ]; then
  774. ZERONET_PORT=$ZERONET_PORT_MAIN
  775. fi
  776. if [ ! $ZERONET_PORT ]; then
  777. echo $'No zeronet port was specified'
  778. exit 67433
  779. fi
  780. chroot "$rootdir" apt-get -y install python python-msgpack python-gevent
  781. chroot "$rootdir" apt-get -y install python-pip bittornado
  782. chroot "$rootdir" pip install msgpack-python --upgrade
  783. chroot "$rootdir" useradd -d /opt/zeronet/ -s /bin/false zeronet
  784. git clone $ZERONET_REPO $rootdir/opt/zeronet
  785. if [ ! -d $rootdir/opt/zeronet ]; then
  786. echo 'WARNING: Unable to clone zeronet'
  787. return
  788. fi
  789. cd $rootdir/opt/zeronet
  790. git checkout $ZERONET_COMMIT -b $ZERONET_COMMIT
  791. if ! grep -q "ZeroNet commit" $COMPLETION_FILE; then
  792. echo "ZeroNet commit:$ZERONET_COMMIT" >> $rootdir$COMPLETION_FILE
  793. else
  794. sed -i "s/ZeroNet commit.*/ZeroNet commit:$ZERONET_COMMIT/g" $COMPLETION_FILE
  795. fi
  796. chroot "$rootdir" chown -R zeronet:zeronet /opt/zeronet
  797. # Hack to ensure that the file access port is opened
  798. # This is because zeronet normally relies on an internet site
  799. # to do this, but on a purely local mesh the internet isn't available
  800. sed -i 's|fileserver_port = 0|fileserver_port = config.fileserver_port\n sys.modules["main"].file_server.port_opened = True|g' $rootdir/opt/zeronet/src/Site/Site.py
  801. ZERONET_DAEMON=$rootdir/etc/systemd/system/zeronet.service
  802. echo '[Unit]' > $ZERONET_DAEMON
  803. echo 'Description=Zeronet Server' >> $ZERONET_DAEMON
  804. echo 'After=syslog.target' >> $ZERONET_DAEMON
  805. echo 'After=network.target' >> $ZERONET_DAEMON
  806. echo '[Service]' >> $ZERONET_DAEMON
  807. echo 'Type=simple' >> $ZERONET_DAEMON
  808. echo 'User=zeronet' >> $ZERONET_DAEMON
  809. echo 'Group=zeronet' >> $ZERONET_DAEMON
  810. echo 'WorkingDirectory=/opt/zeronet' >> $ZERONET_DAEMON
  811. echo 'ExecStart=/usr/bin/python zeronet.py --ip_external replace.local --trackers_file /opt/zeronet/bootstrap' >> $ZERONET_DAEMON
  812. echo '' >> $ZERONET_DAEMON
  813. echo 'TimeoutSec=300' >> $ZERONET_DAEMON
  814. echo '' >> $ZERONET_DAEMON
  815. echo '[Install]' >> $ZERONET_DAEMON
  816. echo 'WantedBy=multi-user.target' >> $ZERONET_DAEMON
  817. TRACKER_DAEMON=$rootdir/etc/systemd/system/tracker.service
  818. echo '[Unit]' > $TRACKER_DAEMON
  819. echo 'Description=Torrent Tracker' >> $TRACKER_DAEMON
  820. echo 'After=syslog.target' >> $TRACKER_DAEMON
  821. echo 'After=network.target' >> $TRACKER_DAEMON
  822. echo '[Service]' >> $TRACKER_DAEMON
  823. echo 'Type=simple' >> $TRACKER_DAEMON
  824. echo 'User=tracker' >> $TRACKER_DAEMON
  825. echo 'Group=tracker' >> $TRACKER_DAEMON
  826. echo 'WorkingDirectory=/opt/tracker' >> $TRACKER_DAEMON
  827. echo "ExecStart=/usr/bin/bttrack --port $TRACKER_PORT --dfile /opt/tracker/dstate --logfile /opt/tracker/tracker.log --nat_check 0 --scrape_allowed full --ipv6_enabled 0" >> $TRACKER_DAEMON
  828. echo '' >> $TRACKER_DAEMON
  829. echo 'TimeoutSec=300' >> $TRACKER_DAEMON
  830. echo '' >> $TRACKER_DAEMON
  831. echo '[Install]' >> $TRACKER_DAEMON
  832. echo 'WantedBy=multi-user.target' >> $TRACKER_DAEMON
  833. chroot "$rootdir" useradd -d /opt/tracker/ -s /bin/false tracker
  834. if [ ! -d $rootdir/opt/tracker ]; then
  835. mkdir $rootdir/opt/tracker
  836. fi
  837. chroot "$rootdir" chown -R tracker:tracker /opt/tracker
  838. # publish regularly
  839. echo "* * * * * root zeronetavahi > /dev/null" >> $rootdir/etc/crontab
  840. chroot "$rootdir" systemctl enable tracker.service
  841. chroot "$rootdir" systemctl enable zeronet.service
  842. }
  843. initialise_mesh() {
  844. if [[ $VARIANT != "mesh" && $VARIANT != "meshclient" ]]; then
  845. return
  846. fi
  847. if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
  848. return
  849. fi
  850. mesh_firewall
  851. mesh_avahi
  852. mesh_batman
  853. mesh_tox_node
  854. mesh_tox_avahi
  855. mesh_tox_client
  856. mesh_zeronet
  857. MESH_SERVICE='mesh-setup.service'
  858. MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE
  859. echo '[Unit]' > $MESH_SETUP_DAEMON
  860. echo 'Description=Initial mesh router configuration' >> $MESH_SETUP_DAEMON
  861. echo 'After=syslog.target' >> $MESH_SETUP_DAEMON
  862. echo 'After=network.target' >> $MESH_SETUP_DAEMON
  863. echo '[Service]' >> $MESH_SETUP_DAEMON
  864. echo 'Type=simple' >> $MESH_SETUP_DAEMON
  865. echo 'User=root' >> $MESH_SETUP_DAEMON
  866. echo 'Group=root' >> $MESH_SETUP_DAEMON
  867. echo 'WorkingDirectory=/root' >> $MESH_SETUP_DAEMON
  868. echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh > /var/log/mesh-setup.log" >> $MESH_SETUP_DAEMON
  869. echo '' >> $MESH_SETUP_DAEMON
  870. echo 'TimeoutSec=99999' >> $MESH_SETUP_DAEMON
  871. echo '' >> $MESH_SETUP_DAEMON
  872. echo '[Install]' >> $MESH_SETUP_DAEMON
  873. echo 'WantedBy=multi-user.target' >> $MESH_SETUP_DAEMON
  874. chroot "$rootdir" systemctl enable $MESH_SERVICE
  875. }
  876. # User interface for USB drive installs ######################################
  877. function enable_tox_repo {
  878. chroot "$rootdir" echo 'deb http://download.opensuse.org/repositories/home:/antonbatenev:/tox/Debian_8.0/ /' > /etc/apt/sources.list.d/tox.list
  879. chroot "$rootdir" wget http://download.opensuse.org/repositories/home:antonbatenev:tox/Debian_8.0/Release.key
  880. chroot "$rootdir" apt-key add - < Release.key
  881. chroot "$rootdir" apt-get update
  882. echo "Tox Repository Installed."
  883. }
  884. function install_syncthing {
  885. if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
  886. return
  887. fi
  888. chroot "$rootdir" apt-get -y install curl
  889. chroot "$rootdir" curl -s https://syncthing.net/release-key.txt | apt-key add -
  890. chroot "$rootdir" echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing.list
  891. chroot "$rootdir" apt-get update
  892. chroot "$rootdir" apt-get -y install syncthing
  893. # This probably does need to run as root so that it can access the Sync directories
  894. # in each user's home directory
  895. chroot "$rootdir" echo '[Unit]' > /etc/systemd/system/syncthing.service
  896. chroot "$rootdir" echo 'Description=Syncthing - Open Source Continuous File Synchronization' >> /etc/systemd/system/syncthing.service
  897. chroot "$rootdir" echo 'Documentation=man:syncthing(1)' >> /etc/systemd/system/syncthing.service
  898. chroot "$rootdir" echo 'After=network.target' >> /etc/systemd/system/syncthing.service
  899. chroot "$rootdir" echo 'Wants=syncthing-inotify@.service' >> /etc/systemd/system/syncthing.service
  900. chroot "$rootdir" echo '' >> /etc/systemd/system/syncthing.service
  901. chroot "$rootdir" echo '[Service]' >> /etc/systemd/system/syncthing.service
  902. chroot "$rootdir" echo 'User=root' >> /etc/systemd/system/syncthing.service
  903. chroot "$rootdir" echo "Environment='all_proxy=socks5://localhost:9050'" >> /etc/systemd/system/syncthing.service
  904. chroot "$rootdir" echo 'ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0' >> /etc/systemd/system/syncthing.service
  905. chroot "$rootdir" echo 'Restart=on-failure' >> /etc/systemd/system/syncthing.service
  906. chroot "$rootdir" echo 'SuccessExitStatus=3 4' >> /etc/systemd/system/syncthing.service
  907. chroot "$rootdir" echo 'RestartForceExitStatus=3 4' >> /etc/systemd/system/syncthing.service
  908. chroot "$rootdir" echo '' >> /etc/systemd/system/syncthing.service
  909. chroot "$rootdir" echo '[Install]' >> /etc/systemd/system/syncthing.service
  910. chroot "$rootdir" echo 'WantedBy=multi-user.target' >> /etc/systemd/system/syncthing.service
  911. chroot "$rootdir" systemctl enable syncthing
  912. chroot "$rootdir" systemctl daemon-reload
  913. if ! grep -q "syncthing" $rootdir/etc/crontab; then
  914. chroot "$rootdir" echo "*/1 * * * * root /usr/local/bin/freedombone-syncthing > /dev/null" >> /etc/crontab
  915. chroot "$rootdir" systemctl restart cron
  916. fi
  917. echo 'install_syncthing'
  918. }
  919. function configure_user_interface {
  920. if [[ $VARIANT != "meshclient" && $VARIANT != "usb" ]]; then
  921. return
  922. fi
  923. # desktop
  924. chroot "$rootdir" apt-get -y install mate-desktop-environment
  925. # browser
  926. chroot "$rootdir" apt-get -y install iceweasel
  927. # NOTE: The Tox repo only supports a limited range of architectures
  928. if [[ $ARCHITECTURE == 'amd64' || $ARCHITECTURE == 'i386' ]]; then
  929. # Tox user interface
  930. enable_tox_repo
  931. # TODO: this may not work on all architectures
  932. chroot "$rootdir" apt-get -y install qtox
  933. fi
  934. # Syncthing
  935. install_syncthing
  936. if [[ $VARIANT == "usb" ]]; then
  937. # tor
  938. chroot "$rootdir" apt-get -y install tor
  939. # xmpp client
  940. chroot "$rootdir" echo "deb ftp://ftp.gajim.org/debian unstable main" > /etc/apt/sources.list.d/gajim.list
  941. chroot "$rootdir" apt-get update
  942. chroot "$rootdir" apt-get -y install gajim-dev-keyring
  943. chroot "$rootdir" apt-get -y install git python-dev python-pip gajim-nightly
  944. chroot "$rootdir" mkdir /home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins -p
  945. chroot "$rootdir" git clone https://github.com/omemo/gajim-omemo /home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins/gajim-omemo
  946. chroot "$rootdir" pip install protobuf==2.6.1, python-axolotl==0.1.35
  947. chroot "$rootdir" chown -R $GENERIC_IMAGE_USERNAME:$GENERIC_IMAGE_USERNAME /home/$GENERIC_IMAGE_USERNAME/.local
  948. # IRC client
  949. chroot "$rootdir" apt-get -y install hexchat profanity
  950. # zeronet
  951. # TODO
  952. fi
  953. }
  954. ##############################################################################
  955. # Set to true/false to control if eatmydata is used during build
  956. use_eatmydata=true
  957. rootdir="$1"
  958. fmdir="$(pwd)"
  959. image="$fmdir"/"$2"
  960. cd "$rootdir"
  961. echo info: building $MACHINE for $ARCHITECTURE
  962. export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
  963. export LC_ALL=C LANGUAGE=C LANG=C
  964. # Override libpam-tmpdir setting during build, as the directories
  965. # are not created yet.
  966. export TMP=/tmp/ TMPDIR=/tmp/
  967. username=$MY_USERNAME
  968. echo $"warning: creating initial user $username with well known password!"
  969. password=$MY_PASSWORD
  970. chroot "$rootdir" adduser --gecos $username --disabled-password $username
  971. echo $username:$password | chroot $rootdir /usr/sbin/chpasswd
  972. chroot "$rootdir" adduser $username sudo
  973. case "$MACHINE" in
  974. virtualbox)
  975. # hide irrelevant console keyboard messages.
  976. echo "echo \"4 4 1 7\" > /proc/sys/kernel/printk" \
  977. >> /etc/init.d/rc.local
  978. ;;
  979. qemu)
  980. # hide irrelevant console keyboard messages.
  981. echo "echo \"4 4 1 7\" > /proc/sys/kernel/printk" \
  982. >> /etc/init.d/rc.local
  983. ;;
  984. esac
  985. set_apt_sources $BUILD_MIRROR
  986. chroot "$rootdir" apt-get clean
  987. chroot "$rootdir" rm -rf /var/lib/apt/lists/*
  988. chroot "$rootdir" apt-get clean
  989. chroot "$rootdir" apt-get update
  990. cat > $rootdir/usr/sbin/policy-rc.d <<EOF
  991. #!/bin/sh
  992. exit 101
  993. EOF
  994. chmod a+rx $rootdir/usr/sbin/policy-rc.d
  995. if $use_eatmydata ; then
  996. enable_eatmydata_override
  997. fi
  998. if [ -n "$CUSTOM_SETUP" ]; then
  999. cp "$CUSTOM_SETUP" "$rootdir"/tmp
  1000. chroot "$rootdir" apt-get install -y gdebi-core
  1001. chroot "$rootdir" gdebi -n /tmp/"$(basename $CUSTOM_SETUP)"
  1002. fi
  1003. chroot "$rootdir" apt-get install -y sudo git dialog toilet build-essential openssh-server
  1004. chroot "$rootdir" apt-get install -y avahi-daemon avahi-utils avahi-discover avahi-autoipd
  1005. chroot "$rootdir" apt-get install -y iptables dnsutils net-tools network-manager iputils-ping
  1006. chroot "$rootdir" apt-get install -y libnss-mdns libnss-myhostname libnss-gw-name nano man ntp
  1007. chroot "$rootdir" apt-get install -y locales locales-all debconf wireless-tools wpasupplicant
  1008. sed -i "s|#host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
  1009. sed -i "s|host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
  1010. chroot "$rootdir" /bin/bash -x <<EOF
  1011. git clone $PROJECT_REPO /root/$PROJECT_NAME
  1012. cd /root/$PROJECT_NAME
  1013. make install
  1014. EOF
  1015. chroot "$rootdir" ${PROJECT_NAME}-image-hardware-setup 2>&1 | \
  1016. tee $rootdir/var/log/${PROJECT_NAME}-image-hardware-setup.log
  1017. rm $rootdir/usr/sbin/policy-rc.d
  1018. # Set up HRNG for systems known to have one
  1019. # Otherwise install haveged
  1020. if [[ "$MACHINE" != "beaglebone" ]]; then
  1021. chroot $rootdir apt-get -y install haveged
  1022. else
  1023. chroot $rootdir apt-get -y install rng-tools
  1024. sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' $rootdir/etc/default/rng-tools
  1025. fi
  1026. # copy u-boot to beginning of image
  1027. case "$MACHINE" in
  1028. beaglebone)
  1029. dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/MLO of="$image" \
  1030. count=1 seek=1 conv=notrunc bs=128k
  1031. dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img of="$image" \
  1032. count=2 seek=1 conv=notrunc bs=384k
  1033. ;;
  1034. cubieboard2)
  1035. dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
  1036. seek=8 conv=notrunc bs=1k
  1037. ;;
  1038. a20-olinuxino-lime)
  1039. dd if=$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin \
  1040. of="$image" seek=8 conv=notrunc bs=1k
  1041. ;;
  1042. esac
  1043. if $use_eatmydata ; then
  1044. disable_eatmydata_override
  1045. fi
  1046. set_apt_sources $MIRROR
  1047. chroot "$rootdir" apt-get update
  1048. configure_ssh
  1049. configure_networking
  1050. admin_user_sudo
  1051. create_generic_image
  1052. atheros_wifi
  1053. continue_installation
  1054. initialise_mesh
  1055. configure_wifi
  1056. configure_user_interface
  1057. cd /
  1058. echo $"info: killing leftover processes in chroot"
  1059. fuser -mvk $rootdir/. || true
  1060. exit 0