freedombone-image-customise 93KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # Based on bin/freedombox-customize from freedom-maker
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. set -e
  29. set -x
  30. PROJECT_NAME='freedombone'
  31. LOCAL_NAME=${PROJECT_NAME}
  32. INSTALL_DIR=/root/build
  33. COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
  34. PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
  35. VARIANT='full'
  36. # username created by default within a debian image
  37. GENERIC_IMAGE_USERNAME='fbone'
  38. export TEXTDOMAIN=${PROJECT_NAME}-image-customise
  39. export TEXTDOMAINDIR="/usr/share/locale"
  40. # Whether to minimise the number of decisions during interactive install
  41. MINIMAL_INSTALL="yes"
  42. MY_USERNAME='debian'
  43. MY_PASSWORD="${PROJECT_NAME}"
  44. # Minimum number of characters in a password
  45. MINIMUM_PASSWORD_LENGTH=10
  46. # IP address of the router (gateway)
  47. ROUTER_IP_ADDRESS="192.168.1.254"
  48. # The fixed IP address of the Beaglebone Black on your local network
  49. BOX_IP_ADDRESS="192.168.1.55"
  50. # DNS
  51. NAMESERVER1='91.239.100.100'
  52. NAMESERVER2='89.233.43.71'
  53. NAMESERVER3='87.118.100.175'
  54. NAMESERVER4='94.75.228.29'
  55. NAMESERVER5='85.25.251.254'
  56. NAMESERVER6='2.141.58.13'
  57. # optional configuration file containing freedombone settings
  58. CONFIG_FILENAME=
  59. # Optional ssh public key to allow
  60. SSH_PUBKEY="no"
  61. # Whether this is a generic image for mass redistribution on the interwebs
  62. GENERIC_IMAGE="no"
  63. # default SSH port
  64. SSH_PORT=2222
  65. # for mesh installs
  66. TRACKER_PORT=6969
  67. # Whether sites are accessible only within a Tor browser
  68. ONION_ONLY="no"
  69. # Whether to only install debian and nothing else
  70. DEBIAN_INSTALL_ONLY="no"
  71. # wifi settings
  72. WIFI_INTERFACE='wlan0'
  73. WIFI_SSID=
  74. WIFI_TYPE='wpa2-psk'
  75. WIFI_PASSPHRASE=
  76. WIFI_HOTSPOT='no'
  77. WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
  78. # Whether to install non-free wifi drivers for the mesh client
  79. INSECURE='no'
  80. # optional desktop background image for mesh
  81. MESH_DESKTOP_BACKGROUND_IMAGE=/usr/local/share/${PROJECT_NAME}_mesh_initial_background.png
  82. # The browser application to use
  83. BROWSER=firefox
  84. BROWSER_OPTIONS='-url'
  85. MESH_INSTALL_DIR=/var/lib
  86. # for mesh installs whether to delete all data and generate
  87. # a new identity at every shutdown/boot
  88. AMNESIC='no'
  89. # Whether this is a dedicated gnusocial or postactiv instance
  90. SOCIALINSTANCE=
  91. # defines the initial keyboard layout
  92. KEYBOARD_MAP='gb'
  93. # Strings used for setting the username
  94. MESH_TITLE=$"Freedombone Mesh"
  95. MESH_SET_USERNAME=$"Welcome to the Freedombone mesh.\n\nThe first thing you will need to do is set a username so that other peers can find you."
  96. # Whether to enable zeronet on the mesh
  97. ENABLE_ZERONET=
  98. MESH_TEXT_EDITOR='pluma'
  99. BABEL_REPO="https://github.com/jech/babeld"
  100. BABEL_COMMIT='d9390d1fee337c464e67255bbbd879d975e126e2'
  101. OLSR2_REPO="https://github.com/OLSR/OONF"
  102. OLSR2_COMMIT='81033251c4ee1c5699bfee9d2985112c6266ab0a'
  103. BMX6_REPO="https://github.com/bmx-routing/bmx6"
  104. BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181'
  105. BMX7_REPO="https://github.com/bmx-routing/bmx7"
  106. BMX7_COMMIT='0a82c7c10fef44b259b35e77ab33632aa132d219'
  107. PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
  108. configure_backports() {
  109. echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main" >> "$rootdir/etc/apt/sources.list"
  110. }
  111. configure_contrib_repo() {
  112. if ! grep -q "contrib" "$rootdir/etc/apt/sources.list"; then
  113. chroot "$rootdir" /bin/sed -i "s| main| main contrib|g" /etc/apt/sources.list
  114. fi
  115. }
  116. enable_eatmydata_override() {
  117. chroot "$rootdir" apt-get install -y eatmydata
  118. if [ -x "$rootdir/usr/bin/eatmydata" ] && \
  119. [ ! -f "$rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata" ]; then
  120. echo $"info: Adding apt config to call dpkg via eatmydata"
  121. printf "#!/bin/sh\\nexec eatmydata dpkg \"\$@\"\\n" \
  122. > "$rootdir/var/tmp/dpkg-eatmydata"
  123. chmod 755 "$rootdir/var/tmp/dpkg-eatmydata"
  124. cat > "$rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata" <<EOF
  125. Dir::Bin::dpkg "/var/tmp/dpkg-eatmydata";
  126. EOF
  127. else
  128. echo $"error: unable to find /usr/bin/eatmydata after installing the eatmydata package"
  129. fi
  130. }
  131. disable_eatmydata_override() {
  132. for override in \
  133. /etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata \
  134. /var/tmp/dpkg-eatmydata ; do
  135. echo $"info: Removing apt config to call dpkg via eatmydata"
  136. if [ -f "$rootdir$override" ] ; then
  137. rm -f "$rootdir$override"
  138. else
  139. echo $"warning: missing $rootdir$override"
  140. fi
  141. done
  142. sync # Flush file buffers before continuing
  143. }
  144. set_apt_sources() {
  145. NEW_MIRROR="$1"
  146. COMPONENTS="main"
  147. cat <<EOF > etc/apt/sources.list
  148. deb $NEW_MIRROR $SUITE $COMPONENTS
  149. deb-src $NEW_MIRROR $SUITE $COMPONENTS
  150. #deb http://security.debian.org/ $SUITE/updates main
  151. #deb-src http://security.debian.org/ $SUITE/updates main
  152. EOF
  153. }
  154. configure_networking() {
  155. chroot "$rootdir" apt-get -yq install resolvconf
  156. if [[ "$DEBIAN_INSTALL_ONLY" != "no" ]]; then
  157. return
  158. fi
  159. if [[ "$GENERIC_IMAGE" == "no" ]]; then
  160. echo '# This file describes the network interfaces available on your system' > "$rootdir/etc/network/interfaces"
  161. echo '# and how to activate them. For more information, see interfaces(5).' >> "$rootdir/etc/network/interfaces"
  162. echo 'source /etc/network/interfaces.d/*' >> "$rootdir/etc/network/interfaces"
  163. echo "auto eth0
  164. iface eth0 inet static
  165. address $BOX_IP_ADDRESS
  166. netmask 255.255.255.0
  167. gateway $ROUTER_IP_ADDRESS" > "$rootdir/etc/network/interfaces.d/static"
  168. hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
  169. a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  170. b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  171. c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  172. d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  173. e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
  174. echo "hwaddress ether de:$a:$b:$c:$d:$e" > "$rootdir/etc/network/interfaces.d/macaddress"
  175. fi
  176. # configure DNS
  177. resolvconf=$rootdir/etc/resolvconf/resolv.conf.d/head
  178. { echo 'domain localdomain';
  179. echo 'search localdomain';
  180. echo "nameserver $NAMESERVER1";
  181. echo "nameserver $NAMESERVER2";
  182. echo "nameserver $NAMESERVER3";
  183. echo "nameserver $NAMESERVER4";
  184. echo "nameserver $NAMESERVER5";
  185. echo "nameserver $NAMESERVER6"; } > "$resolvconf"
  186. chroot "$rootdir" resolvconf -u
  187. if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" ]]; then
  188. # change the motd to show further install instructions
  189. echo $"
  190. _____ _ _
  191. | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  192. | __| _| -_| -_| . | . | | . | . | | -_|
  193. |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  194. Initial base install
  195. Your system is not yet installed. To complete the process run the
  196. following commands, then enter your details.
  197. sudo su
  198. ${PROJECT_NAME} menuconfig
  199. " > "$rootdir/etc/motd"
  200. else
  201. echo $"
  202. _____ _ _
  203. | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  204. | __| _| -_| -_| . | . | | . | . | | -_|
  205. |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  206. Freedom in the Mesh
  207. " > "$rootdir/etc/motd"
  208. fi
  209. }
  210. configure_ssh() {
  211. if [[ $VARIANT == "mesh"* ]]; then
  212. return
  213. fi
  214. sed -i "s/Port .*/Port ${SSH_PORT}/g" "$rootdir/etc/ssh/sshd_config"
  215. sed -i "s/#Port ${SSH_PORT}/Port ${SSH_PORT}/g" "$rootdir/etc/ssh/sshd_config"
  216. if [[ "$SSH_PUBKEY" != "no" ]]; then
  217. if [ ! -d "$rootdir/home/$MY_USERNAME/.ssh" ]; then
  218. mkdir "$rootdir/home/$MY_USERNAME/.ssh"
  219. fi
  220. echo "$SSH_PUBKEY" > "$rootdir/home/$MY_USERNAME/.ssh/authorized_keys"
  221. chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.ssh"
  222. sed -i 's|PasswordAuthentication.*|PasswordAuthentication no|g' "$rootdir/etc/ssh/sshd_config"
  223. sed -i 's|#PasswordAuthentication no|PasswordAuthentication no|g' "$rootdir/etc/ssh/sshd_config"
  224. echo $"Using ssh public key:"
  225. echo $SSH_PUBKEY
  226. echo $'Password ssh authentication turned off'
  227. fi
  228. }
  229. create_generic_image() {
  230. if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
  231. return
  232. fi
  233. if [[ $GENERIC_IMAGE == "no" ]]; then
  234. return
  235. fi
  236. if [ $CONFIG_FILENAME ]; then
  237. if [[ "$CONFIG_FILENAME" == *"mesh.cfg"* ]]; then
  238. VARIANT="mesh"
  239. fi
  240. fi
  241. # Don't install any configuration. This will be a base system
  242. if [[ $VARIANT != "mesh"* ]]; then
  243. CONFIG_FILENAME=
  244. else
  245. touch "$rootdir/root/.initial_mesh_setup"
  246. fi
  247. # Stick with the existing login for mesh clients
  248. if [[ $VARIANT == "meshclient" || $VARIANT == "meshusb" ]]; then
  249. return
  250. fi
  251. # The presence of this file indicates that the initial
  252. # setup has not yet been completed
  253. touch "$rootdir/home/$MY_USERNAME/.initial_setup"
  254. chroot "$rootdir" /bin/chown "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.initial_setup"
  255. touch "$rootdir/root/.initial_setup"
  256. cat >> "$rootdir/home/$MY_USERNAME/.bashrc" <<EOF
  257. # initial setup of the system
  258. if [ -f ~/.initial_setup ]; then
  259. clear
  260. echo "
  261. .---. . .
  262. | | |
  263. |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  264. | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  265. ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  266. Initial setup process
  267. Please enter your password a second time.
  268. "
  269. sudo su
  270. fi
  271. EOF
  272. { echo "MY_USERNAME=${MY_USERNAME}";
  273. echo '# initial setup of the system';
  274. echo 'if [ -f ~/.initial_setup ]; then';
  275. echo ' if [ -f ~/login.txt ]; then';
  276. echo " NEW_USER_PASSWORD=\$(printf \"%s\" \"\$(cat ~/login.txt)\")";
  277. echo ' else';
  278. echo " ENTROPY=\$(cat /proc/sys/kernel/random/entropy_avail)";
  279. echo " if [ \$ENTROPY -lt 500 ]; then"; } >> "$rootdir/root/.bashrc"
  280. ENTROPY_MESSAGE1=$'Initial setup process'
  281. ENTROPY_MESSAGE2=$'Password Generation'
  282. ENTROPY_MESSAGE3=$'WARNING: The entropy available on this system is too low to generate a password.\n\nThe installation process cannot continue.'
  283. { echo " dialog --backtitle \"${ENTROPY_MESSAGE1}\" --title \"${ENTROPY_MESSAGE2}\" --msgbox \"${ENTROPY_MESSAGE3}\" 8 50";
  284. echo ' exit';
  285. echo ' fi';
  286. echo -n " NEW_USER_PASSWORD=\$(openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c ";
  287. echo "${DEFAULT_PASSWORD_LENGTH})";
  288. echo ' fi';
  289. echo " echo \"\${NEW_USER_PASSWORD}\" > ~/login.txt";
  290. echo ' clear';
  291. echo ' echo ""'; } >> "$rootdir/root/.bashrc"
  292. NEW_LOGIN_PASSWORD_MESSAGE1=$'Your new login password is:'
  293. NEW_LOGIN_PASSWORD_MESSAGE2=$'Use it whenever you wish to ssh into this system.'
  294. NEW_LOGIN_PASSWORD_MESSAGE3=$'IMPORTANT: Please take a moment to enter the above password into a\npassword manager or write it down somewhere.'
  295. PRESS_KEY_MESSAGE=$'Press any key to continue...'
  296. { echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE1}\"";
  297. echo ' echo ""';
  298. echo " echo \" \${NEW_USER_PASSWORD}\"";
  299. echo ' echo ""';
  300. echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE2}\"";
  301. echo ' echo ""';
  302. echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE3}\"";
  303. echo ' echo ""';
  304. echo " read -n1 -r -p \"${PRESS_KEY_MESSAGE}\" key";
  305. # change the password for the admin user
  306. echo -n " echo \"${MY_USERNAME}:";
  307. echo "\$(printf \"%s\" \"\$(cat ~/login.txt)\")\"|chpasswd";
  308. # update before continuing
  309. echo " cd /root/${PROJECT_NAME}";
  310. echo " git stash";
  311. echo " git pull";
  312. echo " git checkout stretch";
  313. echo " make install"; } >> "$rootdir/root/.bashrc"
  314. if [[ "$VARIANT" != "mesh"* && "$VARIANT" != "usb" ]]; then
  315. if [[ "$SOCIALINSTANCE" == "gnusocial" ]]; then
  316. echo " ${PROJECT_NAME} menuconfig-gnusocial" >> "$rootdir/root/.bashrc"
  317. else
  318. if [[ "$SOCIALINSTANCE" == "postactiv" ]]; then
  319. echo " ${PROJECT_NAME} menuconfig-postactiv" >> "$rootdir/root/.bashrc"
  320. else
  321. if [[ "$SOCIALINSTANCE" == "pleroma" ]]; then
  322. echo " ${PROJECT_NAME} menuconfig-pleroma" >> "$rootdir/root/.bashrc"
  323. else
  324. if [[ "$ONION_ONLY" == "no" ]]; then
  325. if [[ "$MINIMAL_INSTALL" == "no" ]]; then
  326. echo " ${PROJECT_NAME} menuconfig-full" >> "$rootdir/root/.bashrc"
  327. else
  328. echo " ${PROJECT_NAME} menuconfig" >> "$rootdir/root/.bashrc"
  329. fi
  330. else
  331. echo " ${PROJECT_NAME} menuconfig-onion" >> "$rootdir/root/.bashrc"
  332. fi
  333. fi
  334. fi
  335. fi
  336. else
  337. echo " echo ''" >> "$rootdir/root/.bashrc"
  338. fi
  339. { echo ' if [ "$?" = "0" ]; then';
  340. echo " if [ -f ~/${PROJECT_NAME}-completed.txt ]; then";
  341. echo " # Check that the initial setup really did complete";
  342. echo " if grep -q 'tripwire' ~/${PROJECT_NAME}-completed.txt; then";
  343. # Remove the initial setup files
  344. echo ' rm /root/.initial_setup';
  345. echo ' rm /home/fbone/.initial_setup';
  346. echo " touch /root/.remove_${GENERIC_IMAGE_USERNAME}";
  347. echo ' shred -zu ~/login.txt'; } >> "$rootdir/root/.bashrc"
  348. if [[ "$VARIANT" != "mesh"* && "$VARIANT" != "usb" ]]; then
  349. { echo " SSH_ONION_HOSTNAME=\$(cat /var/lib/tor/hidden_service_ssh/hostname)";
  350. echo " if [ \${#SSH_ONION_HOSTNAME} -lt 2 ]; then";
  351. echo ' exit 62392';
  352. echo ' fi'; } >> "$rootdir/root/.bashrc"
  353. fi
  354. { echo " if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then";
  355. echo " echo '[Unit]' > /etc/systemd/system/wifistart.service";
  356. echo " echo 'Description=WifiStartup (Start wifi networking)' >> /etc/systemd/system/wifistart.service";
  357. echo " echo 'After=syslog.target' >> /etc/systemd/system/wifistart.service";
  358. echo " echo 'After=network.target' >> /etc/systemd/system/wifistart.service";
  359. echo " echo 'After=remote-fs.target' >> /etc/systemd/system/wifistart.service";
  360. echo " echo '' >> /etc/systemd/system/wifistart.service";
  361. echo " echo '[Service]' >> /etc/systemd/system/wifistart.service";
  362. echo " echo 'Type=simple' >> /etc/systemd/system/wifistart.service";
  363. echo " echo 'User=root' >> /etc/systemd/system/wifistart.service";
  364. echo " echo 'Group=root' >> /etc/systemd/system/wifistart.service";
  365. echo " echo 'WorkingDirectory=/root' >> /etc/systemd/system/wifistart.service";
  366. echo " echo 'ExecStart=/usr/local/bin/freedombone-wifi --wait 5 2> /dev/null' >> /etc/systemd/system/wifistart.service";
  367. echo " echo '' >> /etc/systemd/system/wifistart.service";
  368. echo " echo '[Install]' >> /etc/systemd/system/wifistart.service";
  369. echo " echo 'WantedBy=multi-user.target' >> /etc/systemd/system/wifistart.service";
  370. echo " systemctl enable wifistart";
  371. echo " systemctl daemon-reload";
  372. echo ' fi';
  373. echo ' systemctl reboot -i';
  374. echo ' fi';
  375. echo ' fi';
  376. echo ' else';
  377. echo ' key=';
  378. echo " while [[ \$key != \"x\" ]]; do"; } >> "$rootdir/root/.bashrc"
  379. INSTALL_FAIL_MESSAGE=$"Install failed. Press x to continue..."
  380. { echo " read -n1 -r -p \"${INSTALL_FAIL_MESSAGE}\" key";
  381. echo ' done';
  382. echo ' fi';
  383. echo ' exit';
  384. echo 'else';
  385. echo ' # Remove default account after install';
  386. echo " if [ -f /root/.remove_${GENERIC_IMAGE_USERNAME} ]; then";
  387. echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then";
  388. echo " userdel -r ${GENERIC_IMAGE_USERNAME}";
  389. echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then";
  390. echo " rm -rf /home/${GENERIC_IMAGE_USERNAME}";
  391. echo " rm /root/.remove_${GENERIC_IMAGE_USERNAME}";
  392. echo ' fi';
  393. echo ' fi';
  394. echo ' fi';
  395. echo 'fi'; } >> "$rootdir/root/.bashrc"
  396. }
  397. continue_installation() {
  398. # If a configuration file exists then run with it
  399. # otherwise the interactive installer can be used
  400. # This is equivalent to installing freedombox-setup on freedombox
  401. if [ $CONFIG_FILENAME ]; then
  402. if [ ${#CONFIG_FILENAME} -gt 2 ]; then
  403. cp "$CONFIG_FILENAME" "$rootdir/root/$PROJECT_NAME.cfg"
  404. cat "$rootdir/root/$PROJECT_NAME.cfg"
  405. chroot "$rootdir" su -c "$PROJECT_NAME -c /root/$PROJECT_NAME.cfg" - root
  406. fi
  407. fi
  408. }
  409. atheros_wifi() {
  410. chroot "$rootdir" dpkg -i /root/freedombone/drivers/firmware-ath9k-htc.deb
  411. chroot "$rootdir" apt-get -yq install firmware-linux-free
  412. }
  413. configure_wifi() {
  414. if [[ $VARIANT == "mesh"* ]]; then
  415. return
  416. fi
  417. wifi_setup_service=setupwififirstboot
  418. wifi_setup_file=$rootdir/root/setup_wifi_firstboot
  419. echo '#!/bin/bash' > "$wifi_setup_file"
  420. if [ -f $WIFI_NETWORKS_FILE ]; then
  421. echo "${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE" >> "$wifi_setup_file"
  422. else
  423. if [[ $WIFI_TYPE != 'none' ]]; then
  424. if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
  425. return
  426. fi
  427. echo "${PROJECT_NAME}-wifi -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $WIFI_HOTSPOT" >> "$wifi_setup_file"
  428. else
  429. echo "${PROJECT_NAME}-wifi -s $WIFI_SSID -t $WIFI_TYPE --hotspot $WIFI_HOTSPOT" >> "$wifi_setup_file"
  430. fi
  431. fi
  432. { echo "systemctl stop ${wifi_setup_service}";
  433. echo "systemctl disable ${wifi_setup_service}";
  434. echo "rm /etc/systemd/system/${wifi_setup_service}.service";
  435. echo 'systemctl reboot -i'; } >> "$wifi_setup_file"
  436. chmod +x "$wifi_setup_file"
  437. { echo '[Unit]';
  438. echo 'Description=Initial wifi configuration';
  439. echo 'After=syslog.target';
  440. echo 'After=network.target';
  441. echo '';
  442. echo '[Service]';
  443. echo 'Type=simple';
  444. echo 'User=root';
  445. echo 'Group=root';
  446. echo 'WorkingDirectory=/root';
  447. echo "ExecStart=/root/setup_wifi_firstboot > /var/log/wifi_setup.log";
  448. echo '';
  449. echo 'TimeoutSec=99999';
  450. echo '';
  451. echo '[Install]';
  452. echo 'WantedBy=multi-user.target'; } >> "$rootdir/etc/systemd/system/${wifi_setup_service}.service"
  453. chmod +x "$rootdir/etc/systemd/system/${wifi_setup_service}.service"
  454. chroot "$rootdir" systemctl enable ${wifi_setup_service}
  455. }
  456. ##############################################################################
  457. # Mesh networking
  458. ##############################################################################
  459. # for mesh installs
  460. TRACKER_PORT=6969
  461. WIFI_CHANNEL=2
  462. # B.A.T.M.A.N settings
  463. BATMAN_CELLID='02:BA:00:00:03:01'
  464. WIFI_SSID='mesh'
  465. # To avoid confusions these are obtained from the main project file
  466. #TOXID_REPO=
  467. #TOX_PORT=
  468. #TOXCORE_REPO=
  469. #TOXIC_REPO=
  470. #TOXCORE_COMMIT=
  471. #TOXIC_COMMIT=
  472. # These are some default nodes, but you can replace them with trusted nodes
  473. # as you prefer. See https://wiki.tox.im/Nodes
  474. #TOX_NODES=
  475. #TOX_NODES=(
  476. # '192.254.75.102,2607:5600:284::2,33445,951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F,Tox RELENG,US'
  477. # '144.76.60.215,2a01:4f8:191:64d6::1,33445,04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F,sonOfRa,DE'
  478. #)
  479. # To avoid confusions these are obtained from the main project file
  480. ZERONET_REPO=
  481. ZERONET_COMMIT=
  482. ZERONET_PORT=
  483. ZERONET_BLOG_REPO=
  484. ZERONET_BLOG_COMMIT=
  485. ZERONET_MAIL_REPO=
  486. ZERONET_MAIL_COMMIT=
  487. ZERONET_FORUM_REPO=
  488. ZERONET_FORUM_COMMIT=
  489. ZERONET_ID_REPO=
  490. ZERONET_ID_COMMIT=
  491. # Directory where source code is downloaded and compiled
  492. INSTALL_DIR=$HOME/build
  493. INSTALLING_MESH=
  494. PATCHWORK_REPO="https://github.com/ssbc/patchwork"
  495. PATCHWORK_COMMIT='60111a9e3385d65be0d17aa0d15fd20e5fb311ce'
  496. FERMENT_REPO="https://github.com/LolaShare/ferment"
  497. FERMENT_COMMIT='6e0e434114cd4cc652a03f6dcc6ddcec007b0058'
  498. install_patchwork() {
  499. if [[ $VARIANT != "meshclient" ]]; then
  500. return
  501. fi
  502. get_npm_arch
  503. mesh_setup_npm
  504. git clone "$PATCHWORK_REPO" "$rootdir/etc/patchwork"
  505. if [ ! -d "$rootdir/etc/patchwork" ]; then
  506. exit 7823520
  507. fi
  508. cd "$rootdir/etc/patchwork" || exit 68724685427
  509. git checkout "$PATCHWORK_COMMIT" -b "$PATCHWORK_COMMIT"
  510. cat <<EOF > "$rootdir/usr/bin/install_patchwork"
  511. #!/bin/bash
  512. cd /etc/patchwork
  513. npm install --arch=$NPM_ARCH --build-from-source
  514. npm install --arch=$NPM_ARCH --save-dev electron-rebuild
  515. ./node_modules/.bin/electron-rebuild
  516. npm install --arch=$NPM_ARCH git-ssb
  517. EOF
  518. chroot "$rootdir" /bin/chmod +x /usr/bin/install_patchwork
  519. chroot "$rootdir" /usr/bin/install_patchwork
  520. rm "$rootdir/usr/bin/install_patchwork"
  521. { echo '#!/bin/bash';
  522. echo 'cd /etc/patchwork';
  523. echo 'npm start'; } > "$rootdir/usr/bin/start_patchwork"
  524. chmod +x "$rootdir/usr/bin/start_patchwork"
  525. # Copy icon to an accesible location
  526. cp "$rootdir/root/$PROJECT_NAME/img/icon_patchwork.png" "$rootdir/etc/patchwork/icon_patchwork.png"
  527. }
  528. install_ferment() {
  529. if [[ "$VARIANT" != "meshclient" ]]; then
  530. return
  531. fi
  532. get_npm_arch
  533. git clone "$FERMENT_REPO" "$rootdir/etc/ferment"
  534. if [ ! -d "$rootdir/etc/ferment" ]; then
  535. exit 5239465
  536. fi
  537. cd "$rootdir/etc/ferment" || exit 2482684
  538. git checkout "$FERMENT_COMMIT" -b "$FERMENT_COMMIT"
  539. cat <<EOF > "$rootdir/usr/bin/install_ferment"
  540. #!/bin/bash
  541. cd /etc/ferment
  542. npm install --arch=$NPM_ARCH --build-from-source
  543. npm install --arch=$NPM_ARCH --save-dev electron-rebuild
  544. ./node_modules/.bin/electron-rebuild
  545. npm install --arch=$NPM_ARCH git-ssb
  546. EOF
  547. chroot "$rootdir" /bin/chmod +x /usr/bin/install_ferment
  548. chroot "$rootdir" /usr/bin/install_ferment
  549. rm "$rootdir/usr/bin/install_ferment"
  550. { echo '#!/bin/bash';
  551. echo 'cd /etc/ferment';
  552. echo 'npm start'; } > "$rootdir/usr/bin/start_ferment"
  553. chmod +x "$rootdir/usr/bin/start_ferment"
  554. # Copy icon to an accesible location
  555. cp "$rootdir/root/$PROJECT_NAME/img/icon_ferment.png" "$rootdir/etc/patchwork/icon_ferment.png"
  556. }
  557. mesh_shutdown_script() {
  558. mesh_shutdown_script="$rootdir/usr/bin/meshshutdown"
  559. { echo '#!/bin/bash';
  560. echo 'batman stop'; } > "$mesh_shutdown_script"
  561. chroot "$rootdir" chmod +x /usr/bin/meshshutdown
  562. { echo '[Unit]';
  563. echo 'Description=Shuts down the mesh';
  564. echo 'Before=shutdown.target';
  565. echo '';
  566. echo '[Service]';
  567. echo 'User=root';
  568. echo 'Group=root';
  569. echo 'ExecStart=/bin/true';
  570. echo 'ExecStop=/bin/bash /usr/bin/meshshutdown';
  571. echo 'RemainAfterExit=yes';
  572. echo '';
  573. echo '[Install]';
  574. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/meshshutdown.service"
  575. chroot "$rootdir" systemctl enable meshshutdown
  576. }
  577. install_babel() {
  578. git clone "$BABEL_REPO" "$rootdir/etc/babel"
  579. cat <<EOF > "$rootdir/usr/bin/install_babel"
  580. #!/bin/bash
  581. cd /etc/babel
  582. git checkout $BABEL_COMMIT -b $BABEL_COMMIT
  583. cd /etc/babel
  584. make
  585. make install
  586. EOF
  587. chroot "$rootdir" chmod +x /usr/bin/install_babel
  588. chroot "$rootdir" /usr/bin/install_babel
  589. if [ ! -f "$rootdir/usr/local/bin/babeld" ]; then
  590. echo $'Unable to build Babel'
  591. exit 52382524
  592. fi
  593. rm "$rootdir/usr/bin/install_babel"
  594. { echo '[Unit]';
  595. echo 'Description=Babel mesh routing protocol';
  596. echo 'Requires=network.target';
  597. echo 'After=network.target';
  598. echo '';
  599. echo '[Service]';
  600. echo 'User=root';
  601. echo 'Group=root';
  602. echo 'ExecStart=/usr/local/bin/babeld wlan0';
  603. echo 'Restart=on-failure';
  604. echo '';
  605. echo '[Install]';
  606. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/babel.service"
  607. }
  608. install_olsr2() {
  609. chroot "$rootdir" apt-get -yq install cmake libnl-3-dev
  610. git clone "$OLSR2_REPO" "$rootdir/etc/olsr2"
  611. cat <<EOF > "$rootdir/usr/bin/install_olsr2"
  612. #!/bin/bash
  613. cd /etc/olsr2
  614. git checkout $OLSR2_COMMIT -b $OLSR2_COMMIT
  615. cd /etc/olsr2/build
  616. cmake ..
  617. make
  618. make install
  619. EOF
  620. chroot "$rootdir" chmod +x /usr/bin/install_olsr2
  621. chroot "$rootdir" /usr/bin/install_olsr2
  622. if [ ! -f "$rootdir/usr/local/sbin/olsrd2_static" ]; then
  623. echo $'Unable to build OLSR2'
  624. exit 79835392
  625. fi
  626. rm "$rootdir/usr/bin/install_olsr2"
  627. { echo '[Unit]';
  628. echo 'Description=OLSR2 mesh routing protocol';
  629. echo 'Requires=network.target';
  630. echo 'After=network.target';
  631. echo '';
  632. echo '[Service]';
  633. echo 'User=root';
  634. echo 'Group=root';
  635. echo 'ExecStart=/usr/local/sbin/olsrd2_static wlan0';
  636. echo 'Restart=on-failure';
  637. echo '';
  638. echo '[Install]';
  639. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/olsr2.service"
  640. }
  641. install_bmx6() {
  642. git clone "$BMX6_REPO" "$rootdir/etc/bmx6"
  643. cat <<EOF > "$rootdir/usr/bin/install_bmx6"
  644. #!/bin/bash
  645. cd /etc/bmx6
  646. git checkout $BMX6_COMMIT -b $BMX6_COMMIT
  647. make
  648. make install
  649. cd /etc/bmx6/lib/bmx6_http_info
  650. make
  651. make install
  652. cd /etc/bmx6/lib/bmx6_json
  653. make
  654. make install
  655. cd /etc/bmx6/lib/bmx6_quagga
  656. make
  657. make install
  658. cd /etc/bmx6/lib/bmx6_sms
  659. make
  660. make install
  661. cd /etc/bmx6/lib/bmx6_table
  662. make
  663. make install
  664. cd /etc/bmx6/lib/bmx6_topology
  665. make
  666. make install
  667. EOF
  668. chroot "$rootdir" chmod +x /usr/bin/install_bmx6
  669. chroot "$rootdir" /usr/bin/install_bmx6
  670. if [ ! -f "$rootdir/usr/sbin/bmx6" ]; then
  671. echo $'bmx6 was not installed'
  672. exit 79835292
  673. fi
  674. rm "$rootdir/usr/bin/install_bmx6"
  675. { echo '[Unit]';
  676. echo 'Description=BMX6 mesh routing protocol';
  677. echo 'Requires=network.target';
  678. echo 'After=network.target';
  679. echo '';
  680. echo '[Service]';
  681. echo 'Type=forking';
  682. echo 'User=root';
  683. echo 'Group=root';
  684. echo 'ExecStart=/usr/sbin/bmx6 dev=wlan0';
  685. echo "ExecStop=/usr/bin/kill -15 \$MAINPID";
  686. echo 'PIDFile=/var/run/bmx6/pid';
  687. echo 'Restart=on-failure';
  688. echo '';
  689. echo '[Install]';
  690. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/bmx6.service"
  691. }
  692. install_bmx7() {
  693. chroot "$rootdir" apt-get -qy install libjson-c-dev zlib1g-dev libiw-dev
  694. git clone "$BMX7_REPO" "$rootdir/etc/bmx7"
  695. cat <<EOF > "$rootdir/usr/bin/install_bmx7"
  696. #!/bin/bash
  697. cd /etc
  698. wget https://polarssl.org/code/releases/polarssl-1.3.3-gpl.tgz
  699. tar xzvf polarssl-1.3.3-gpl.tgz
  700. cd /etc/polarssl-1.3.3
  701. make
  702. sudo make install
  703. cd /etc/bmx7
  704. git checkout $BMX7_COMMIT -b $BMX7_COMMIT
  705. make EXTRA_CFLAGS="-DCRYPTLIB=POLARSSL_1_3_3"
  706. make install
  707. cd /etc/bmx7/lib/bmx7_http_info
  708. make
  709. make install
  710. cd /etc/bmx7/lib/bmx7_json
  711. make
  712. make install
  713. cd /etc/bmx7/lib/bmx7_tun
  714. make
  715. make install
  716. cd /etc/bmx7/lib/bmx7_sms
  717. make
  718. make install
  719. cd /etc/bmx7/lib/bmx7_topology
  720. make
  721. make install
  722. EOF
  723. chroot "$rootdir" chmod +x /usr/bin/install_bmx7
  724. chroot "$rootdir" /usr/bin/install_bmx7
  725. if [ ! -f "$rootdir/usr/sbin/bmx7" ]; then
  726. echo $'bmx7 was not installed'
  727. exit 67836235
  728. fi
  729. rm "$rootdir/usr/bin/install_bmx7"
  730. { echo '[Unit]';
  731. echo 'Description=BMX7 mesh routing protocol';
  732. echo 'Requires=network.target';
  733. echo 'After=network.target';
  734. echo '';
  735. echo '[Service]';
  736. echo 'Type=forking';
  737. echo 'User=root';
  738. echo 'Group=root';
  739. echo 'ExecStart=/usr/sbin/bmx7 dev=wlan0';
  740. echo "ExecStop=/usr/bin/kill -15 \$MAINPID";
  741. echo 'PIDFile=/var/run/bmx7/pid';
  742. echo 'Restart=on-failure';
  743. echo '';
  744. echo '[Install]';
  745. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/bmx7.service"
  746. }
  747. initialise_mesh() {
  748. if [[ "$VARIANT" != "mesh"* ]]; then
  749. return
  750. fi
  751. if [[ "$DEBIAN_INSTALL_ONLY" != "no" ]]; then
  752. return
  753. fi
  754. if [[ "$INSECURE" == $'yes' ]]; then
  755. echo '*********************************************************'
  756. echo $'WARNING: non-free wifi drivers are being installed.'
  757. echo $' This may compromise the security of your system.'
  758. echo '*********************************************************'
  759. # enable non-free repo
  760. if ! grep -q "non-free" "$rootdir/etc/apt/sources.list"; then
  761. chroot "$rootdir" /bin/sed -i "s| main| main non-free|g" /etc/apt/sources.list
  762. fi
  763. chroot "$rootdir" apt-get update
  764. # install proprietary wifi drivers
  765. # see https://wiki.debian.org/iwlwifi
  766. chroot "$rootdir" apt-get -yq install firmware-iwlwifi firmware-b43-installer firmware-brcm80211 firmware-realtek
  767. fi
  768. INSTALLING_MESH=1
  769. chroot "$rootdir" apt-get -yq install apt-transport-https
  770. # install tor as a possible way of routing traffic between internet gateways
  771. chroot "$rootdir" apt-get -yq -t stretch-backports install tor
  772. # dhcp daemon for hotspot on secondary wifi adapter
  773. chroot "$rootdir" apt-get -yq install dnsmasq
  774. # for debugging
  775. chroot "$rootdir" apt-get -yq install traceroute
  776. # set the default protocol to be used
  777. echo 'bmx6' > "$rootdir$MESH_DEFAULT_PROTOCOL"
  778. sed -i 's|#net.ipv6.conf.all.forwarding.*|net.ipv6.conf.all.forwarding=1|g' "$rootdir/etc/sysctl.conf"
  779. sed -i 's|net.ipv6.conf.all.forwarding.*|net.ipv6.conf.all.forwarding=1|g' "$rootdir/etc/sysctl.conf"
  780. sed -i 's|#net.ipv6.conf.all.accept_redirects.*|net.ipv6.conf.all.accept_redirects=1|g' "$rootdir/etc/sysctl.conf"
  781. sed -i 's|net.ipv6.conf.all.accept_redirects.*|net.ipv6.conf.all.accept_redirects=1|g' "$rootdir/etc/sysctl.conf"
  782. sed -i 's|#net.ipv6.conf.all.accept_source_route.*|net.ipv6.conf.all.accept_source_route=1|g' "$rootdir/etc/sysctl.conf"
  783. sed -i 's|net.ipv6.conf.all.accept_source_route.*|net.ipv6.conf.all.accept_source_route=1|g' "$rootdir/etc/sysctl.conf"
  784. configure_firewall
  785. install_avahi
  786. install_batman
  787. install_bmx6
  788. #install_bmx7
  789. install_olsr2
  790. install_babel
  791. mesh_shutdown_script
  792. install_vpn
  793. install_tomb
  794. #install_tahoelafs
  795. #install_librevault
  796. install_patchwork
  797. install_web_server
  798. mesh_install_scuttlebot
  799. #install_ferment
  800. chroot "$rootdir" apt-get clean
  801. chroot "$rootdir" /bin/rm -rf /var/lib/apt/lists/*
  802. chroot "$rootdir" apt-get clean
  803. install_ipfs
  804. install_tox
  805. install_pelican
  806. mesh_install_cryptpad
  807. #mesh_install_peertube
  808. if [ "$ENABLE_ZERONET" ]; then
  809. install_zeronet
  810. fi
  811. # ssh server not available on mesh peers
  812. if [ -f "$rootdir/etc/avahi/services/ssh.service" ]; then
  813. rm "$rootdir/etc/avahi/services/ssh.service"
  814. fi
  815. MESH_SERVICE='mesh-setup.service'
  816. MESH_SETUP_DAEMON="$rootdir/etc/systemd/system/$MESH_SERVICE"
  817. MESH_STARTUP_PARAMS="${MY_USERNAME}"
  818. if [[ "$AMNESIC" != 'no' ]]; then
  819. MESH_STARTUP_PARAMS="${MY_USERNAME} amnesic"
  820. fi
  821. # command to switch to wired mesh
  822. { echo '#!/bin/bash';
  823. echo 'echo -n "eth" > /root/.mesh_interface_type';
  824. echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wired"
  825. chmod +x "$rootdir/usr/bin/wired"
  826. # command to switch to wireless mesh
  827. { echo '#!/bin/bash';
  828. echo 'echo -n "wlan" > /root/.mesh_interface_type';
  829. echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wireless"
  830. chmod +x "$rootdir/usr/bin/wireless"
  831. { echo '[Unit]';
  832. echo 'Description=Initial mesh router configuration';
  833. echo 'After=syslog.target';
  834. echo 'After=network.target';
  835. echo '';
  836. echo '[Service]';
  837. echo 'Type=simple';
  838. echo 'User=root';
  839. echo 'Group=root';
  840. echo 'WorkingDirectory=/root';
  841. echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh ${MESH_STARTUP_PARAMS} > /var/log/mesh-setup.log";
  842. echo '';
  843. echo 'TimeoutSec=99999';
  844. echo '';
  845. echo '[Install]';
  846. echo 'WantedBy=multi-user.target'; } > "$MESH_SETUP_DAEMON"
  847. chmod +x "$MESH_SETUP_DAEMON"
  848. chroot "$rootdir" systemctl enable "$MESH_SERVICE"
  849. }
  850. # User interface for USB drive installs ######################################
  851. mesh_client_startup_applications() {
  852. if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
  853. mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
  854. fi
  855. if [ ! -d "$rootdir/home/$MY_USERNAME/.config/autostart" ]; then
  856. mkdir -p "$rootdir/home/$MY_USERNAME/.config/autostart"
  857. chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.config"
  858. fi
  859. START_DESKTOP="$rootdir/home/$MY_USERNAME/mesh-desktop.sh"
  860. FIRST_BOOT="/home/$MY_USERNAME/.first_boot"
  861. TAHOE_COMMAND="cd /var/lib/tahoelafs && venv/bin/tahoe"
  862. { echo '#!/bin/bash';
  863. echo "setxkbmap ${KEYBOARD_MAP}";
  864. echo 'dconf write /org/mate/caja/desktop/volumes-visible false';
  865. echo 'dconf write /org/mate/caja/desktop/computer-icon-visible false';
  866. echo 'dconf write /org/mate/caja/desktop/home-icon-visible false';
  867. echo 'dconf write /org/mate/caja/desktop/network-icon-visible false';
  868. echo 'dconf write /org/mate/caja/desktop/trash-icon-visible false';
  869. echo 'dconf write /org/mate/caja/desktop/volumes-visible false';
  870. echo 'dconf write /org/mate/desktop/media-handling/automount-open false';
  871. echo 'dconf write /org/mate/screensaver/lock-enabled false';
  872. echo 'dconf write /org/mate/power-manager/lock-keyring-suspend false';
  873. echo 'dconf write /org/mate/power-manager/lock-suspend false';
  874. echo 'dconf write /org/mate/power-manager/lock-use-screensaver false';
  875. echo 'dconf write /org/mate/power-manager/lock-blank-screen false';
  876. echo 'dconf write /org/mate/power-manager/lock-hibernate false';
  877. echo 'dconf write /org/mate/power-manager/lock-keyring-hibernate false';
  878. echo 'dconf write /org/mate/desktop/peripherals/touchpad/scroll-method 2';
  879. echo "touch /home/$MY_USERNAME/.dbus/Xdbus";
  880. echo "chmod 600 /home/$MY_USERNAME/.dbus/Xdbus";
  881. echo "env | grep DBUS_SESSION_BUS_ADDRESS > /home/$MY_USERNAME/.dbus/Xdbus";
  882. echo "echo 'export DBUS_SESSION_BUS_ADDRESS' >> /home/$MY_USERNAME/.dbus/Xdbus";
  883. echo '';
  884. echo "amixer set 'Master' unmute";
  885. echo "amixer set 'Master' 50%";
  886. echo '';
  887. echo '';
  888. echo "if [ ! -f $FIRST_BOOT ]; then";
  889. echo ' if [ -d /var/lib/tahoelafs ]; then';
  890. echo " $TAHOE_COMMAND start";
  891. echo ' fi';
  892. echo ' exit 0';
  893. echo 'fi';
  894. echo '';
  895. echo 'INITIAL_TOX_USERNAME=""';
  896. echo "while [ \${#INITIAL_TOX_USERNAME} -eq 0 ]; do";
  897. echo " data=\$(zenity --entry --title=\"$MESH_TITLE\" --text=\"$MESH_SET_USERNAME\")";
  898. echo ' accepted=$?';
  899. echo ' if ((accepted == 0)); then';
  900. echo " INITIAL_TOX_USERNAME=\$(awk -F, '{print \$1}' <<<\$data)";
  901. echo ' fi';
  902. echo 'done';
  903. echo '';
  904. echo "toxid --setuser \"\$INITIAL_TOX_USERNAME\"";
  905. echo '';
  906. echo "if [ -f /home/$MY_USERNAME/.tahoe/tahoe.cfg ]; then";
  907. echo " sed -i 's|nickname =.*|nickname = \$INITIAL_TOX_USERNAME|g' /home/$MY_USERNAME/.tahoe/tahoe.cfg";
  908. echo " $TAHOE_COMMAND restart";
  909. echo 'fi';
  910. echo '';
  911. echo "rm -f $FIRST_BOOT";
  912. echo '';
  913. echo 'exit 0'; } > "$START_DESKTOP"
  914. chmod +x "$START_DESKTOP"
  915. START_DESKTOP2="$rootdir/home/$MY_USERNAME/.config/autostart/mesh-start.desktop"
  916. { echo '[Desktop Entry]';
  917. echo 'Type=Application';
  918. echo 'Name=Mesh start desktop script';
  919. echo "Exec=bash -c '~/mesh-desktop.sh'";
  920. echo 'X-GNOME-Autostart-enabled=true'; } > "$START_DESKTOP2"
  921. chmod +x "$START_DESKTOP2"
  922. }
  923. mesh_desktop_icons() {
  924. if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
  925. mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
  926. fi
  927. # Terminal
  928. #echo '[Desktop Entry]' > $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  929. #echo 'Name=MATE Terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  930. #echo 'Type=Application' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  931. #echo 'Comment=Use the command line' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  932. #echo 'TryExec=mate-terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  933. #echo 'Exec=mate-terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  934. #echo 'Icon=terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  935. #echo 'StartupNotify=true' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  936. chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
  937. }
  938. configure_user_interface() {
  939. if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
  940. return
  941. fi
  942. # desktop
  943. chroot "$rootdir" apt-get -yq install mate-desktop-environment
  944. # tool to change desktop settings from command line
  945. chroot "$rootdir" apt-get -yq install dconf-cli dconf-gsettings-backend dbus dbus-x11
  946. # for tomb
  947. chroot "$rootdir" apt-get -yq install pinentry-gtk2
  948. # for tox video
  949. chroot "$rootdir" apt-get -yq install ffmpeg cheese v4l-utils
  950. # to provide notifications
  951. chroot "$rootdir" apt-get -yq install libnotify-bin
  952. # for video/audio
  953. chroot "$rootdir" apt-get -yq install libtheora-bin libvorbis-dev v4l-utils
  954. # a sane editor
  955. chroot "$rootdir" apt-get -yq install emacs
  956. # for wifi monitoring
  957. chroot "$rootdir" apt-get -yq install horst
  958. # for sound level control
  959. chroot "$rootdir" apt-get -yq install alsa-utils pavucontrol
  960. # to play various media types
  961. chroot "$rootdir" apt-get -yq install vlc
  962. # android adb to allow phones to be connected and for example transfer photos/documents
  963. chroot "$rootdir" apt-get -yq install android-tools-adb
  964. # USB cloning tool
  965. chroot "$rootdir" apt-get -yq install gnome-multi-writer
  966. # clipboard
  967. chroot "$rootdir" apt-get -yq install xclip
  968. # multimedia recording and editing
  969. chroot "$rootdir" apt-get -yq install audacity
  970. chroot "$rootdir" apt-get -yq install shotwell
  971. chroot "$rootdir" apt-get -yq install kdenlive breeze-icon-theme
  972. # for gtk dialog entry
  973. chroot "$rootdir" apt-get -yq install zenity
  974. # Produce a text file on the desktop listing users on the mesh
  975. cat <<EOF > "$rootdir/usr/bin/list-tox-users"
  976. #!/bin/bash
  977. StrMeshUsers=\$"Mesh Users"
  978. StrUsername=\$'Username'
  979. StrToxID=\$'Tox ID'
  980. ethernet_connected=\$(cat /sys/class/net/eth0/carrier)
  981. users_list=\$(lstox | awk -F ' ' '{\$1=""; print \$0}' | sed -e 's/^[[:space:]]*//' | sort -d | uniq)
  982. if [ \${#users_list} -eq 0 ]; then
  983. no_of_users=0
  984. else
  985. no_of_users=\$(echo "\$users_list" | wc -l)
  986. fi
  987. if [ \$no_of_users -gt 0 ]; then
  988. echo "\$users_list" > /tmp/Users.txt
  989. chown $MY_USERNAME:$MY_USERNAME /tmp/Users.txt
  990. if [ ! -f /home/$MY_USERNAME/showusers ]; then
  991. echo '#!/bin/bash' > /home/$MY_USERNAME/showusers
  992. echo 'data=\$(' >> /home/$MY_USERNAME/showusers
  993. echo 'cat /tmp/Users.txt | \\' >> /home/$MY_USERNAME/showusers
  994. echo " awk -F ' ' '{" >> /home/$MY_USERNAME/showusers
  995. echo ' for(i=1;i<=NF;i++){' >> /home/$MY_USERNAME/showusers
  996. echo ' print \$i;' >> /home/$MY_USERNAME/showusers
  997. echo ' }' >> /home/$MY_USERNAME/showusers
  998. echo "}' | \\\\" >> /home/$MY_USERNAME/showusers
  999. echo ' zenity --list \\' >> /home/$MY_USERNAME/showusers
  1000. echo " --title='\$StrMeshUsers' \\\\" >> /home/$MY_USERNAME/showusers
  1001. echo " --column='\$StrUsername' --column='\$StrToxID' \\\\" >> /home/$MY_USERNAME/showusers
  1002. echo ' --print-column=2 --hide-column=2 --width=250 --height=400)' >> /home/$MY_USERNAME/showusers
  1003. echo 'if [ ! \$data ]; then' >> /home/$MY_USERNAME/showusers
  1004. echo ' exit 0' >> /home/$MY_USERNAME/showusers
  1005. echo 'fi' >> /home/$MY_USERNAME/showusers
  1006. echo 'echo "\$data" | xclip -selection clipboard' >> /home/$MY_USERNAME/showusers
  1007. chmod +x /home/$MY_USERNAME/showusers
  1008. fi
  1009. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/Users.desktop
  1010. if [ \$no_of_users -lt 2 ]; then
  1011. echo "Name=\$no_of_users Other User" >> /home/$MY_USERNAME/Desktop/Users.desktop
  1012. else
  1013. echo "Name=\$no_of_users Other Users" >> /home/$MY_USERNAME/Desktop/Users.desktop
  1014. fi
  1015. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1016. echo 'Comment=List of users' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1017. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1018. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1019. echo "Comment[ca]=Llista d'usuaris" >> /home/$MY_USERNAME/Desktop/Users.desktop
  1020. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1021. echo 'Comment[fr]=Liste des utilisateurs' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1022. echo 'Comment[de]=Liste der Benutzer' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1023. echo 'Comment[es]=Lista de usuarios' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1024. echo 'Comment[it]=Elenco degli utenti' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1025. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1026. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1027. echo 'Exec=bash /home/$MY_USERNAME/showusers' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1028. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_users.png' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1029. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1030. chmod +x /home/$MY_USERNAME/Desktop/Users.desktop
  1031. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/Users.desktop
  1032. if [ ! -f /home/$MY_USERNAME/.cryptpad.desktop ]; then
  1033. if [ ! -f /home/$MY_USERNAME/Desktop/cryptpad.desktop ]; then
  1034. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1035. echo 'Name=CryptPad' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1036. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1037. echo 'Comment=Realtime collaborative editing of documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1038. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1039. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1040. echo 'Comment[ca]=Edici collaborativa en temps real de documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1041. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1042. echo 'Comment[fr]=Edition collaborative en temps rel de documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1043. echo 'Comment[de]=Kollaboratives Echtzeit-Editing von Dokumenten' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1044. echo 'Comment[es]=Edicin colaborativa en tiempo real de documentos' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1045. echo 'Comment[it]=Editing collaborativo di documenti in tempo reale' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1046. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1047. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1048. echo "Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local" >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1049. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_cryptpad.png" >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1050. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1051. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1052. chmod +x /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1053. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1054. else
  1055. if ! grep -q "\${HOSTNAME}.local" /home/$MY_USERNAME/Desktop/cryptpad.desktop; then
  1056. sed -i "s|Exec=.*|Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local|g" /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1057. fi
  1058. fi
  1059. fi
  1060. if [ -d /etc/peertube ]; then
  1061. if [ ! -f /home/$MY_USERNAME/.peertube.desktop ]; then
  1062. if [ ! -f /home/$MY_USERNAME/Desktop/peertube.desktop ]; then
  1063. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/peertube.desktop
  1064. echo 'Name=PeerTube' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1065. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1066. echo 'Comment=Upload and view videos on the mesh' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1067. echo 'Comment[el]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1068. echo 'Comment[ar]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1069. echo 'Comment[ca]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1070. echo 'Comment[hi]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1071. echo 'Comment[fr]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1072. echo 'Comment[de]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1073. echo 'Comment[es]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1074. echo 'Comment[it]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1075. echo 'Comment[ru]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1076. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1077. echo "Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local:$MESH_PEERTUBE_PORT" >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1078. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_peertube.png" >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1079. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1080. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1081. chmod +x /home/$MY_USERNAME/Desktop/peertube.desktop
  1082. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/peertube.desktop
  1083. else
  1084. if ! grep -q "\${HOSTNAME}.local" /home/$MY_USERNAME/Desktop/peertube.desktop; then
  1085. sed -i "s|Exec=.*|Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local:$MESH_PEERTUBE_PORT|g" /home/$MY_USERNAME/Desktop/peertube.desktop
  1086. fi
  1087. fi
  1088. fi
  1089. fi
  1090. if [ ! -f /home/$MY_USERNAME/Desktop/social.desktop ]; then
  1091. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/social.desktop
  1092. echo 'Name=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1093. echo 'Name[el]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1094. echo 'Name[ar]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1095. echo 'Name[ca]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1096. echo 'Name[hi]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1097. echo 'Name[fr]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1098. echo 'Name[de]=Soziale' >> /home/$MY_USERNAME/Desktop/social.desktop
  1099. echo 'Name[es]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1100. echo 'Name[it]=Sociale' >> /home/$MY_USERNAME/Desktop/social.desktop
  1101. echo 'Name[ru]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1102. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1103. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/social.desktop
  1104. echo "Comment=A decentralized messaging and sharing app built on top of Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1105. echo "Comment[el]= Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1106. echo "Comment[ar]= ()" >> /home/$MY_USERNAME/Desktop/social.desktop
  1107. echo "Comment[ca]=Una aplicaci de missatgeria i distribuci descentralitzada integrada a Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1108. echo "Comment[hi]= () " >> /home/$MY_USERNAME/Desktop/social.desktop
  1109. echo "Comment[fr]=Une application de messagerie et de partage dcentralise base sur Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1110. echo "Comment[de]=Eine dezentralisierte Messaging- und Sharing-App, die auf Secure Scuttlebutt basiert" >> /home/$MY_USERNAME/Desktop/social.desktop
  1111. echo "Comment[es]=Una aplicacin de mensajera y uso compartido descentralizada construida sobre Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1112. echo "Comment[it]=Un'applicazione decentralizzata di messaggistica e condivisione costruita sulla base di Secure Shuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1113. echo "Comment[ru]= , Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1114. echo "Comment[zh]=Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1115. echo 'Exec=bash /usr/bin/start_patchwork' >> /home/$MY_USERNAME/Desktop/social.desktop
  1116. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_social.png" >> /home/$MY_USERNAME/Desktop/social.desktop
  1117. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/social.desktop
  1118. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/social.desktop
  1119. chmod +x /home/$MY_USERNAME/Desktop/social.desktop
  1120. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/social.desktop
  1121. fi
  1122. #if [ ! -f /home/$MY_USERNAME/Desktop/audio.desktop ]; then
  1123. # echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/audio.desktop
  1124. # echo 'Name=Audio/Music' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1125. # echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1126. # echo 'Comment=Audio publishing and streaming' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1127. # echo 'Exec=bash /usr/bin/start_ferment' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1128. # echo "Icon=/etc/patchwork/icon_ferment.png" >> /home/$MY_USERNAME/Desktop/audio.desktop
  1129. # echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1130. # echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1131. # chmod +x /home/$MY_USERNAME/Desktop/audio.desktop
  1132. # chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/audio.desktop
  1133. #fi
  1134. if [ ! -f /home/$MY_USERNAME/Desktop/vpn.desktop ]; then
  1135. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/vpn.desktop
  1136. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1137. echo 'Name=Connect Meshes' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1138. echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1139. echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1140. echo 'Name[ca]=Connecteu malles' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1141. echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1142. echo 'Name[fr]=Connecter les maillages' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1143. echo 'Name[de]=Netze verbinden' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1144. echo 'Name[es]=Conectar Mallas' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1145. echo 'Name[it]=Collegare le maglie' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1146. echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1147. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1148. echo 'Comment=Connect to another mesh network via the internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1149. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1150. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1151. echo "Comment[ca]=Connecteu-vos a una altra xarxa de malla a travs d'Internet" >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1152. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1153. echo 'Comment[fr]=Connectez-vous un autre rseau maill via Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1154. echo 'Comment[de]=Verbindung mit einem anderen Mesh-Netzwerk ber das Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1155. echo 'Comment[es]=Conctese a otra red en malla a travs de Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1156. echo "Comment[it]=Collegarsi ad un'altra rete di maglie via internet" >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1157. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1158. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1159. echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-connect' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1160. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_connect.png' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1161. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1162. chmod +x /home/$MY_USERNAME/Desktop/vpn.desktop
  1163. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/vpn.desktop
  1164. fi
  1165. if [ ! -f /home/$MY_USERNAME/Desktop/routing.desktop ]; then
  1166. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/routing.desktop
  1167. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1168. echo 'Name=Routing Protocol' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1169. echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1170. echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1171. echo "Name[ca]=Protocol d'enrutament" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1172. echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1173. echo 'Name[fr]=Protocole de routage' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1174. echo 'Name[de]=Routingprotokoll' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1175. echo 'Name[es]=Protocolo de enrutamiento' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1176. echo 'Name[it]=Protocollo di routing' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1177. echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1178. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1179. echo 'Comment=Select the mesh routing protocol' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1180. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1181. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1182. echo "Comment[ca]=Seleccioneu el protocol d'enrutament de malles" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1183. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1184. echo 'Comment[fr]=Slectionnez le protocole de routage de maillage' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1185. echo 'Comment[de]=Whlen Sie das Mesh-Routing-Protokoll' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1186. echo 'Comment[es]=Seleccione el protocolo de enrutamiento de malla' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1187. echo "Comment[it]=Seleziona il protocollo di instradamento della mesh" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1188. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1189. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1190. echo "Exec=mate-terminal -e \"/usr/local/bin/${PROJECT_NAME}-mesh-routing\"" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1191. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_routing.png' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1192. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1193. echo 'Categories=Application' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1194. chmod +x /home/$MY_USERNAME/Desktop/routing.desktop
  1195. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/routing.desktop
  1196. fi
  1197. if [ -f /tmp/.ipfs-users ]; then
  1198. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/sites.desktop
  1199. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1200. echo "Name=Visit a site" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1201. echo "Name[el]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1202. echo "Name[ar]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1203. echo "Name[ca]=Visiteu un lloc" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1204. echo "Name[hi]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1205. echo "Name[fr]=Visitez un site" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1206. echo "Name[de]=Besuchen Sie eine Website" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1207. echo "Name[es]=Visita un sitio" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1208. echo "Name[it]=Visita un sito" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1209. echo "Name[ru]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1210. echo "Name[zh]=" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1211. echo 'Comment=Visit a site' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1212. echo "Comment[el]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1213. echo "Comment[ar]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1214. echo "Commant[ca]=Visiteu un lloc" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1215. echo "Comment[hi]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1216. echo "Comment[fr]=Visitez un site" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1217. echo "Comment[de]=Besuchen Sie eine Website" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1218. echo "Comment[es]=Visita un sitio" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1219. echo "Comment[it]=Visita un sito" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1220. echo "Comment[ru]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1221. echo "Comment[zh]=" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1222. echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-visit-site' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1223. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_sites.png' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1224. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1225. chmod +x /home/$MY_USERNAME/Desktop/sites.desktop
  1226. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/sites.desktop
  1227. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/blog.desktop
  1228. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1229. echo "Name=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1230. echo "Name[el]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1231. echo "Name[ar]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1232. echo "Name[ca]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1233. echo "Name[hi]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1234. echo "Name[fr]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1235. echo "Name[de]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1236. echo "Name[es]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1237. echo "Name[it]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1238. echo "Name[ru]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1239. echo "Name[zh]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1240. echo 'Comment=View or create blog entries' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1241. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1242. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1243. echo 'Comment[ca]=Permet visualitzar o crear entrades de bloc' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1244. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1245. echo 'Comment[fr]=Afficher ou crer des entres de blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1246. echo 'Comment[de]=Blog-Eintrge anzeigen oder erstellen' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1247. echo 'Comment[es]=Ver o crear entradas de blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1248. echo 'Comment[it]=Visualizza o crea voci di blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1249. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1250. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1251. echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1252. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_blog.png' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1253. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1254. chmod +x /home/$MY_USERNAME/Desktop/blog.desktop
  1255. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/blog.desktop
  1256. fi
  1257. if [ ! -f /home/$MY_USERNAME/runtox ]; then
  1258. echo 'qtox_running=\$(ps aux | grep qtox | grep data)' > /home/$MY_USERNAME/runtox
  1259. echo 'if [ \${#qtox_running} -eq 0 ]; then' >> /home/$MY_USERNAME/runtox
  1260. echo ' bash -c "qtox -p data"' >> /home/$MY_USERNAME/runtox
  1261. echo 'fi' >> /home/$MY_USERNAME/runtox
  1262. echo 'exit 0' >> /home/$MY_USERNAME/runtox
  1263. chmod +x /home/$MY_USERNAME/runtox
  1264. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/runtox
  1265. fi
  1266. if [ ! -f /home/$MY_USERNAME/Desktop/tox.desktop ]; then
  1267. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/tox.desktop
  1268. echo 'Name=Chat' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1269. echo 'Name[el]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1270. echo 'Name[ar]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1271. echo 'Name[ca]=Xat' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1272. echo 'Name[hi]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1273. echo 'Name[fr]=Bavarder' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1274. echo 'Name[de]=Chat' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1275. echo 'Name[es]=Charla' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1276. echo 'Name[it]=Chiacchierare' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1277. echo 'Name[ru]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1278. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1279. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1280. echo 'Comment=Chat, Voice and Video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1281. echo 'Comment[el]=, ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1282. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1283. echo 'Comment[ca]=Xat, veu i vdeo' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1284. echo 'Comment[hi]=, ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1285. echo 'Comment[fr]=Chat, voix et vido' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1286. echo 'Comment[de]=Chat, Sprache und Video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1287. echo 'Comment[es]=Chat, voz y video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1288. echo 'Comment[it]=Chat, voce e video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1289. echo 'Comment[ru]=, ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1290. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1291. echo 'Exec=bash /home/$MY_USERNAME/runtox' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1292. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_chat.png" >> /home/$MY_USERNAME/Desktop/tox.desktop
  1293. echo 'StartupNotify=true' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1294. chmod +x /home/$MY_USERNAME/Desktop/tox.desktop
  1295. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/tox.desktop
  1296. fi
  1297. # If ethernet is connected then add the invite icon to help enable
  1298. # SSB nat traversal
  1299. if [[ "\$ethernet_connected" != "0" ]]; then
  1300. if [ ! -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
  1301. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/invite.desktop
  1302. echo 'Version=1.0' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1303. echo 'Name=Create Invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1304. echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1305. echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1306. echo 'Name[ca]=Crea una invitaci' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1307. echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1308. echo 'Name[fr]=Crer une invitation' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1309. echo 'Name[de]=Einladung erstellen' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1310. echo 'Name[es]=Crear invitacin' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1311. echo 'Name[it]=Crea Invita' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1312. echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1313. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1314. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1315. echo 'Comment=Create an invite for Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1316. echo 'Comment[el]= Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1317. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1318. echo 'Comment[ca]=Crea una invitaci per Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1319. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1320. echo 'Comment[fr]=Crer une invitation pour Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1321. echo 'Comment[de]=Erstellen Sie eine Einladung fr Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1322. echo 'Comment[es]=Crear una invitacin para Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1323. echo 'Comment[it]=Crea un invito per patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1324. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1325. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1326. echo 'Exec=mate-terminal -e freedombone-mesh-invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1327. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_invite.png' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1328. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1329. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1330. chmod +x /home/$MY_USERNAME/Desktop/invite.desktop
  1331. fi
  1332. else
  1333. if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
  1334. rm /home/$MY_USERNAME/Desktop/invite.desktop
  1335. fi
  1336. fi
  1337. else
  1338. if [ -f /tmp/Users.txt ]; then
  1339. rm /tmp/Users.txt
  1340. rm /home/$MY_USERNAME/Desktop/Users.desktop
  1341. if [ -f /home/$MY_USERNAME/Desktop/Users.desktop ]; then
  1342. rm /home/$MY_USERNAME/Desktop/Users.desktop
  1343. fi
  1344. if [ -f /home/$MY_USERNAME/Desktop/sites.desktop ]; then
  1345. rm /home/$MY_USERNAME/Desktop/sites.desktop
  1346. fi
  1347. if [ -f /home/$MY_USERNAME/Desktop/blog.desktop ]; then
  1348. rm /home/$MY_USERNAME/Desktop/blog.desktop
  1349. fi
  1350. if [ -f /home/$MY_USERNAME/Desktop/tox.desktop ]; then
  1351. rm /home/$MY_USERNAME/Desktop/tox.desktop
  1352. fi
  1353. pkill qtox
  1354. fi
  1355. # If there is no ethernet then remove the invite icon
  1356. if [[ "\$ethernet_connected" == "0" ]]; then
  1357. if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
  1358. rm /home/$MY_USERNAME/Desktop/invite.desktop
  1359. fi
  1360. fi
  1361. fi
  1362. EOF
  1363. chroot "$rootdir" /bin/chown "$MY_USERNAME":"$MY_USERNAME" /usr/bin/list-tox-users
  1364. chroot "$rootdir" /bin/chmod +x /usr/bin/list-tox-users
  1365. echo "* * * * * $MY_USERNAME bash -c /usr/bin/list-tox-users > /dev/null" >> "$rootdir/etc/crontab"
  1366. if [[ "$VARIANT" != "usb" ]]; then
  1367. # log in automatically
  1368. chroot "$rootdir" apt-get -y install nodm xinit
  1369. echo 'NODM_ENABLED=true' > /etc/default/nodm
  1370. echo "NODM_USER=$MY_USERNAME" >> /etc/default/nodm
  1371. chroot "$rootdir" mkdir /etc/systemd/system/getty@tty1.service.d
  1372. { echo '[Service]';
  1373. echo 'ExecStart=';
  1374. echo "ExecStart=-/sbin/agetty --autologin fbone --noclear %I \$TERM"; } > "$rootdir/etc/systemd/system/getty@tty1.service.d/override.conf"
  1375. echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx" >> "$rootdir/home/$MY_USERNAME/.profile"
  1376. chroot "$rootdir" systemctl set-default multi-user.target
  1377. mesh_client_startup_applications
  1378. mesh_desktop_icons
  1379. # Different desktop background for amnesic
  1380. if [[ "$AMNESIC" != 'no' ]]; then
  1381. MESH_DESKTOP_BACKGROUND_IMAGE="/usr/local/share/${PROJECT_NAME}_mesh_amnesic_background.png"
  1382. fi
  1383. # change the desktop background
  1384. if [ "$MESH_DESKTOP_BACKGROUND_IMAGE" ]; then
  1385. if [ -f "$MESH_DESKTOP_BACKGROUND_IMAGE" ]; then
  1386. if [ -d "$rootdir/usr/share/images/desktop-base" ]; then
  1387. cp "$MESH_DESKTOP_BACKGROUND_IMAGE" "$rootdir/usr/share/images/desktop-base/${PROJECT_NAME}_mesh_background.png"
  1388. chroot "$rootdir" /bin/rm /usr/share/images/desktop-base/desktop-background
  1389. chroot "$rootdir" ln -s "/usr/share/images/desktop-base/${PROJECT_NAME}_mesh_background.png" /usr/share/images/desktop-base/desktop-background
  1390. fi
  1391. fi
  1392. fi
  1393. else
  1394. chroot "$rootdir" apt-get -yq install lightdm
  1395. fi
  1396. # browser
  1397. chroot "$rootdir" apt-get -yq install firefox-esr
  1398. # help
  1399. mkdir -p "$rootdir/home/${MY_USERNAME}/help/images"
  1400. cd "$rootdir/root/${PROJECT_NAME}/website" || exit 2346872684
  1401. ./deploy.sh EN "$rootdir/home/${MY_USERNAME}/help"
  1402. chroot "$rootdir" /bin/chown -R "${MY_USERNAME}":"${MY_USERNAME}" "/home/${MY_USERNAME}/help"
  1403. # Tox user interface
  1404. #enable_tox_repo
  1405. mesh_tox_qtox
  1406. # copy the default qtox ini file
  1407. if [ ! -d "${rootdir}/home/${MY_USERNAME}/.config/tox" ]; then
  1408. mkdir "${rootdir}/home/${MY_USERNAME}/.config/tox"
  1409. cp "/usr/local/bin/${PROJECT_NAME}-config-qtox" "${rootdir}/home/${MY_USERNAME}/.config/tox/qtox.ini"
  1410. chroot "$rootdir" /bin/chown -R "${MY_USERNAME}":"${MY_USERNAME}" "/home/${MY_USERNAME}/.config"
  1411. fi
  1412. if [[ "$VARIANT" == "usb" ]]; then
  1413. # tor
  1414. chroot "$rootdir" apt-get -yq -t stretch-backports install tor
  1415. # xmpp client
  1416. chroot "$rootdir" echo "deb ftp://ftp.gajim.org/debian unstable main" > /etc/apt/sources.list.d/gajim.list
  1417. chroot "$rootdir" apt-get update
  1418. chroot "$rootdir" apt-get -yq install gajim-dev-keyring
  1419. chroot "$rootdir" apt-get -yq install git python-dev python-pip gajim-nightly
  1420. chroot "$rootdir" mkdir "/home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins" -p
  1421. chroot "$rootdir" git clone https://github.com/omemo/gajim-omemo "/home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins/gajim-omemo"
  1422. chroot "$rootdir" pip install protobuf==2.6.1, python-axolotl==0.1.35
  1423. chroot "$rootdir" /bin/chown -R "$GENERIC_IMAGE_USERNAME":"$GENERIC_IMAGE_USERNAME" "/home/$GENERIC_IMAGE_USERNAME/.local"
  1424. # IRC client
  1425. chroot "$rootdir" apt-get -yq install hexchat profanity
  1426. fi
  1427. }
  1428. ##############################################################################
  1429. # setup_utils
  1430. ##############################################################################
  1431. image_install_inadyn() {
  1432. if [ "$INSTALLING_MESH" ]; then
  1433. return
  1434. fi
  1435. if [ ! -d "$rootdir/root/build" ]; then
  1436. mkdir -p "$rootdir/root/build"
  1437. fi
  1438. chroot "$rootdir" apt-get -yq install build-essential curl libgnutls28-dev automake1.11 libconfuse-dev
  1439. if [ -d /repos/inadyn ]; then
  1440. mkdir "$rootdir/root/build/inadyn"
  1441. cp -r -p /repos/inadyn/. "$rootdir/root/build/inadyn"
  1442. cd "$rootdir/root/build/inadyn" || exit 24729466456
  1443. git pull
  1444. else
  1445. git clone "$INADYN_REPO" "$rootdir/root/build/inadyn"
  1446. fi
  1447. if [ ! -d "$rootdir/root/build/inadyn" ]; then
  1448. echo 'Failed to clone inadyn'
  1449. exit 728252
  1450. fi
  1451. cd "$rootdir/root/build/inadyn" || exit 3468724568
  1452. git checkout "$INADYN_COMMIT" -b "$INADYN_COMMIT"
  1453. cd "$rootdir/root/build/inadyn" || exit 24682464628
  1454. { echo '#!/bin/bash';
  1455. echo 'cd ~/build/inadyn';
  1456. echo '#./autogen.sh';
  1457. echo './configure';
  1458. echo 'USE_OPENSSL=1 make';
  1459. echo 'make install'; } > "$rootdir/root/build/build_inadyn.sh"
  1460. chmod +x "$rootdir/root/build/build_inadyn.sh"
  1461. chroot "$rootdir" /root/build/build_inadyn.sh
  1462. if [ ! -f "$rootdir/usr/local/sbin/inadyn" ]; then
  1463. echo 'Failed to build inadyn'
  1464. exit 6209356
  1465. fi
  1466. # create a configuration file
  1467. { echo 'background';
  1468. echo 'verbose 1';
  1469. echo 'period 300';
  1470. echo 'startup-delay 60';
  1471. echo 'cache-dir /run/inadyn';
  1472. echo 'logfile /dev/null'; } > "$rootdir/etc/inadyn.conf"
  1473. chmod 600 "$rootdir/etc/inadyn.conf"
  1474. { echo '[Unit]';
  1475. echo 'Description=inadyn (DynDNS updater)';
  1476. echo 'After=network.target';
  1477. echo '';
  1478. echo '[Service]';
  1479. echo 'ExecStart=/usr/local/sbin/inadyn --config /etc/inadyn.conf';
  1480. echo 'Restart=always';
  1481. echo 'Type=forking';
  1482. echo '';
  1483. echo '[Install]';
  1484. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/inadyn.service"
  1485. chroot "$rootdir" systemctl enable inadyn
  1486. echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1487. }
  1488. image_setup_utils() {
  1489. if [ "$INSTALLING_MESH" ]; then
  1490. return
  1491. fi
  1492. chroot "$rootdir" apt-get -yq install apt-transport-https
  1493. chroot "$rootdir" apt-get -yq remove --purge apache2-bin*
  1494. chroot "$rootdir" apt-get -yq dist-upgrade
  1495. chroot "$rootdir" apt-get -yq install ca-certificates
  1496. chroot "$rootdir" apt-get -yq install apt-utils
  1497. chroot "$rootdir" apt-get -yq install shellcheck
  1498. if [[ "$ARCHITECTURE" == 'amd64' ]]; then
  1499. chroot "$rootdir" apt-get -yq install linux-image-amd64
  1500. fi
  1501. if [[ "$ARCHITECTURE" == 'qemu'* || "$ARCHITECTURE" == 'amd64' || "$ARCHITECTURE" == 'x86_64' || "$ARCHITECTURE" == 'i686' || "$ARCHITECTURE" == 'i386' ]]; then
  1502. chroot "$rootdir" apt-get -yq install grub2 lvm2
  1503. fi
  1504. chroot "$rootdir" apt-get -yq install locales locales-all debconf
  1505. SYSCTL_FILE="$rootdir/etc/sysctl.conf"
  1506. if [ ! -f "$SYSCTL_FILE" ]; then
  1507. touch "$SYSCTL_FILE"
  1508. fi
  1509. cp "$SYSCTL_FILE" "$rootdir/root/sysctl.conf"
  1510. chown "$CURR_USER":"$CURR_GROUP" "$rootdir/root/sysctl.conf"
  1511. if ! grep -q "tcp_challenge_ack_limit" "$rootdir/root/sysctl.conf"; then
  1512. echo 'net.ipv4.tcp_challenge_ack_limit = 999999999' >> "$rootdir/root/sysctl.conf"
  1513. else
  1514. sed -i 's|net.ipv4.tcp_challenge_ack_limit.*|net.ipv4.tcp_challenge_ack_limit = 999999999|g' "$rootdir/root/sysctl.conf"
  1515. fi
  1516. cp "$rootdir/root/sysctl.conf" "$SYSCTL_FILE"
  1517. rm "$rootdir/root/sysctl.conf"
  1518. # all the packages
  1519. chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget
  1520. chroot "$rootdir" apt-get -yq install avahi-daemon avahi-utils avahi-discover
  1521. chroot "$rootdir" apt-get -yq install connect-proxy openssh-server
  1522. chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
  1523. chroot "$rootdir" apt-get -yq install avahi-discover iptables dnsutils net-tools
  1524. chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
  1525. chroot "$rootdir" apt-get -yq install libnss-gw-name nano man ntp locales locales-all debconf
  1526. chroot "$rootdir" apt-get -yq install wireless-tools wpasupplicant usbutils cryptsetup zsh
  1527. chroot "$rootdir" apt-get -yq install pinentry-curses eatmydata iotop bc hostapd haveged
  1528. chroot "$rootdir" apt-get -yq install cpulimit screen elinks libpam-cracklib
  1529. chroot "$rootdir" apt-get -yq install vim-common python3 unattended-upgrades
  1530. # Tor and ssh over tor
  1531. chroot "$rootdir" apt-get -yq -t stretch-backports install tor
  1532. chroot "$rootdir" apt-get -yq install connect-proxy
  1533. chroot "$rootdir" connect-proxy
  1534. sed -i 's|#Log notice file.*|Log notice file /dev/null|g' "$rootdir/etc/tor/torrc"
  1535. sed -i 's|Log notice file.*|Log notice file /dev/null|g' "$rootdir/etc/tor/torrc"
  1536. sed -i "s|#AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
  1537. sed -i "s|AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
  1538. if ! grep -q 'Host *.onion' "$rootdir/root/.ssh/config"; then
  1539. if [ ! -d "$rootdir/root/.ssh" ]; then
  1540. mkdir "$rootdir/root/.ssh"
  1541. fi
  1542. echo 'Host *.onion' >> "$rootdir/root/.ssh/config"
  1543. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> "$rootdir/root/.ssh/config"
  1544. fi
  1545. if ! grep -q 'Host *.onion' "$rootdir/etc/skel/.ssh/config"; then
  1546. if [ ! -d "$rootdir/etc/skel/.ssh" ]; then
  1547. mkdir "$rootdir/etc/skel/.ssh"
  1548. fi
  1549. echo 'Host *.onion' >> "$rootdir/etc/skel/.ssh/config"
  1550. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> "$rootdir/etc/skel/.ssh/config"
  1551. fi
  1552. # Install golang
  1553. chroot "$rootdir" adduser --disabled-login --gecos 'go' go
  1554. GOARCH=
  1555. if [[ "$ARCHITECTURE" == *"386" || "$ARCHITECTURE" == *"686" ]]; then
  1556. GOARCH=386
  1557. fi
  1558. if [[ "$ARCHITECTURE" == *"amd64" || "$ARCHITECTURE" == "x86_64" ]]; then
  1559. GOARCH=amd64
  1560. fi
  1561. if [[ "$ARCHITECTURE" == *"arm"* ]]; then
  1562. GOARCH=armv6l
  1563. fi
  1564. if [[ "$ARCHITECTURE" == *"aarch"* || "$ARCHITECTURE" == *"arm64"* ]]; then
  1565. GOARCH=arm64
  1566. fi
  1567. if [ ! "$GOARCH" ]; then
  1568. echo $'System architecture was not specified when installing Go'
  1569. exit 6734378
  1570. fi
  1571. GO_SOURCE="https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GOARCH}.tar.gz"
  1572. if [ ! -d "${rootdir}/root/build" ]; then
  1573. mkdir -p "$rootdir/root/build"
  1574. fi
  1575. cd "$rootdir/root/build" || exit 4268746282
  1576. wget "${GO_SOURCE}"
  1577. if [ ! -f "${rootdir}/root/build/go${GO_VERSION}.linux-${GOARCH}.tar.gz" ]; then
  1578. exit 265243553
  1579. fi
  1580. chroot "$rootdir" tar -C /home/go -xzf "${INSTALL_DIR}/go${GO_VERSION}.linux-${GOARCH}.tar.gz"
  1581. if [ ! -d "${rootdir}/home/go/go/bin" ]; then
  1582. echo 'Go binary not installed'
  1583. exit 763562
  1584. fi
  1585. # shellcheck disable=SC2086
  1586. mv ${rootdir}/home/go/go ${rootdir}/home/go/go${GO_VERSION}
  1587. echo "export GOROOT=/home/go" >> "${rootdir}/root/.bashrc"
  1588. echo "export GOROOT=/home/go" >> "${rootdir}/etc/skel/.bashrc"
  1589. echo "export GOROOT=/home/go" >> "${rootdir}/home/go/.bashrc"
  1590. echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/root/.bashrc"
  1591. echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/etc/skel/.bashrc"
  1592. echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/home/go/.bashrc"
  1593. echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/root/.bashrc"
  1594. echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/etc/skel/.bashrc"
  1595. echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/home/go/.bashrc"
  1596. chroot "$rootdir" chown -R go:go /home/go
  1597. cp "${rootdir}/home/go/go${GO_VERSION}/bin/"* "${rootdir}/usr/bin"
  1598. echo "upgrade_golang:$GO_VERSION" >> "${rootdir}/root/${PROJECT_NAME}-completed.txt"
  1599. # Tomb
  1600. chroot "$rootdir" apt-get -yq install zsh pinentry-curses
  1601. git clone "$TOMB_REPO" "$rootdir/root/build/tomb"
  1602. cd "$rootdir/root/build/tomb" || exit 468368345425
  1603. git checkout "$TOMB_COMMIT" -b "$TOMB_COMMIT"
  1604. chroot "$rootdir" cd /root/build/tomb && make install
  1605. echo "tomb commit:$TOMB_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1606. if ! grep -q '\* hard maxsyslogins' "$rootdir/etc/security/limits.conf"; then
  1607. echo '* hard maxsyslogins 10' >> "$rootdir/etc/security/limits.conf"
  1608. else
  1609. sed -i 's|hard maxsyslogins.*|hard maxsyslogins 10|g' "$rootdir/etc/security/limits.conf"
  1610. fi
  1611. # Max logins for each user
  1612. if ! grep -q '\* hard maxlogins' "$rootdir/etc/security/limits.conf"; then
  1613. echo '* hard maxlogins 2' >> "$rootdir/etc/security/limits.conf"
  1614. else
  1615. sed -i 's|hard maxlogins.*|hard maxlogins 2|g' "$rootdir/etc/security/limits.conf"
  1616. fi
  1617. # Email
  1618. chroot "$rootdir" apt-get -yq remove postfix
  1619. chroot "$rootdir" apt-get -yq install exim4 exim4-daemon-heavy sasl2-bin swaks libnet-ssleay-perl procmail
  1620. chroot "$rootdir" apt-get -yq install spamassassin
  1621. chroot "$rootdir" apt-get -yq install dovecot-imapd
  1622. #backup
  1623. chroot "$rootdir" apt-get -yq install duplicity gnupg
  1624. # monkeysphere
  1625. #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl
  1626. # encrypting email
  1627. chroot "$rootdir" apt-get -yq install libmail-gnupg-perl
  1628. git clone "$GPGIT_REPO" "$rootdir/root/build/gpgit"
  1629. cd "$rootdir/root/build/gpgit" || exit 62484624682
  1630. git checkout "$GPGIT_COMMIT" -b "$GPGIT_COMMIT"
  1631. cp "$rootdir/root/build/gpgit/gpgit.pl" "$rootdir/usr/bin"
  1632. echo "gpgit commit:$GPGIT_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1633. # email client
  1634. chroot "$rootdir" apt-get -yq install lynx abook urlview mutt
  1635. git clone "$CLEANUP_MAILDIR_REPO" "$rootdir/root/build/cleanup-maildir"
  1636. cd "$rootdir/root/build/cleanup-maildir" || exit 246872646847264
  1637. git checkout "$CLEANUP_MAILDIR_COMMIT" -b "$CLEANUP_MAILDIR_COMMIT"
  1638. cp "$rootdir/root/build/cleanup-maildir/cleanup-maildir" "$rootdir/usr/bin"
  1639. echo "cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1640. # web server
  1641. chroot "$rootdir" apt-get -yq remove --purge apache2
  1642. chroot "$rootdir" apt-get -yq install nginx php-fpm
  1643. git clone "$NGINX_ENSITE_REPO" "$rootdir/root/build/nginx_ensite"
  1644. cd "$rootdir/root/build/nginx_ensite" || exit 462746826482
  1645. git checkout "$NGINX_ENSITE_COMMIT" -b "$NGINX_ENSITE_COMMIT"
  1646. echo "nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1647. chroot "$rootdir" cd /root/build/nginx_ensite && make install
  1648. if [ ! -f "$rootdir/etc/pam.d/nginx" ]; then
  1649. { echo '#%PAM-1.0';
  1650. echo '@include common-auth';
  1651. echo '@include common-account';
  1652. echo '@include common-session'; } > "$rootdir/etc/pam.d/nginx"
  1653. fi
  1654. chroot "$rootdir" apt-get -yq install tripwire
  1655. # filesystem optimisations
  1656. #sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
  1657. }
  1658. image_install_nodejs() {
  1659. if [[ "$VARIANT" == "mesh" ]]; then
  1660. return
  1661. fi
  1662. mesh_install_nodejs
  1663. echo 'install_nodejs' >> "${rootdir}/root/${PROJECT_NAME}-completed.txt"
  1664. }
  1665. image_preinstall_repos() {
  1666. if [[ "$VARIANT" == "mesh"* ]]; then
  1667. return
  1668. fi
  1669. if [ ! -d "$rootdir/repos" ]; then
  1670. mkdir "$rootdir/repos"
  1671. fi
  1672. git clone "$CMAKE_REPO" "$rootdir/repos/cmake"
  1673. git clone "$INADYN_REPO" "$rootdir/repos/inadyn"
  1674. git clone "$TOMB_REPO" "$rootdir/repos/tomb"
  1675. if [[ "$SOCIALINSTANCE" == "pleroma" ]]; then
  1676. git clone "$PLEROMA_REPO" "$rootdir/repos/pleroma"
  1677. return
  1678. fi
  1679. if [[ "$SOCIALINSTANCE" == "gnusocial" ]]; then
  1680. git clone "$GNUSOCIAL_REPO" "$rootdir/repos/gnusocial"
  1681. git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
  1682. git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
  1683. git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
  1684. return
  1685. fi
  1686. if [[ "$SOCIALINSTANCE" == "postactiv" ]]; then
  1687. git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
  1688. git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
  1689. git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
  1690. git clone "$POSTACTIV_REPO" "$rootdir/repos/postactiv"
  1691. return
  1692. fi
  1693. git clone "$CRYPTPAD_REPO" "$rootdir/repos/cryptpad"
  1694. git clone "$BLUDIT_REPO" "$rootdir/repos/bludit"
  1695. git clone "$DOKUWIKI_REPO" "$rootdir/repos/dokuwiki"
  1696. git clone "$ETHERPAD_REPO" "$rootdir/repos/etherpad"
  1697. git clone "$FRIENDICA_REPO" "$rootdir/repos/friendica"
  1698. git clone "$GNUSOCIAL_REPO" "$rootdir/repos/gnusocial"
  1699. git clone "$PLEROMA_REPO" "$rootdir/repos/pleroma"
  1700. git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
  1701. git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
  1702. git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
  1703. git clone "$POSTACTIV_REPO" "$rootdir/repos/postactiv"
  1704. git clone "$SHARINGS_REPO" "$rootdir/repos/sharings"
  1705. git clone "$HTMLY_REPO" "$rootdir/repos/htmly"
  1706. git clone "$HUBZILLA_REPO" "$rootdir/repos/hubzilla"
  1707. git clone "$HUBZILLA_ADDONS_REPO" "$rootdir/repos/hubzilla-addons"
  1708. git clone "$KOEL_REPO" "$rootdir/repos/koel"
  1709. git clone "$LYCHEE_REPO" "$rootdir/repos/lychee"
  1710. git clone "$MAILPILE_REPO" "$rootdir/repos/mailpile"
  1711. git clone "$MATRIX_REPO" "$rootdir/repos/matrix"
  1712. git clone "$MEDIAGOBLIN_REPO" "$rootdir/repos/mediagoblin"
  1713. #git clone "$MOVIM_REPO" "$rootdir/repos/movim"
  1714. git clone "$NEXTCLOUD_REPO" "$rootdir/repos/nextcloud"
  1715. git clone "$PIHOLE_REPO" "$rootdir/repos/pihole"
  1716. git clone "$PROFANITY_REPO" "$rootdir/repos/profanity"
  1717. git clone "$LIBMESODE_REPO" "$rootdir/repos/libmesode"
  1718. git clone "$PROFANITY_OMEMO_PLUGIN_REPO" "$rootdir/repos/profanity-omemo"
  1719. git clone "$RSS_READER_REPO" "$rootdir/repos/rss"
  1720. git clone "$RSS_MOBILE_READER_REPO" "$rootdir/repos/rss-mobile"
  1721. git clone "$SEARX_REPO" "$rootdir/repos/searx"
  1722. git clone "$TOXCORE_REPO" "$rootdir/repos/toxcore"
  1723. git clone "$TOXID_REPO" "$rootdir/repos/toxid"
  1724. git clone "$TOXIC_REPO" "$rootdir/repos/toxic"
  1725. git clone "$TURTL_REPO" "$rootdir/repos/turtl"
  1726. git clone "$KANBOARD_REPO" "$rootdir/repos/kanboard"
  1727. git clone "$KEYSERVER_WEB_REPO" "$rootdir/repos/keyserverweb"
  1728. git clone "$PEERTUBE_REPO" "$rootdir/repos/peertube"
  1729. git clone "$PRIVATEBIN_REPO" "$rootdir/repos/privatebin"
  1730. git clone "$EDITH_REPO" "$rootdir/repos/edith"
  1731. git clone "$BDSMAIL_REPO" "$rootdir/repos/bdsmail"
  1732. #git clone "$WEKAN_REPO" "$rootdir/repos/wekan"
  1733. #git clone "$FLOW_ROUTER_REPO" "$rootdir/repos/flowrouter"
  1734. #git clone "$METEOR_USERACCOUNTS_REPO" "$rootdir/repos/meteoruseraccounts"
  1735. #git clone "$METEOR_REPO" "$rootdir/repos/meteor"
  1736. #git clone "$ZERONET_REPO" "$rootdir/repos/zeronet"
  1737. #git clone "$QTOX_REPO" "$rootdir/repos/qtox"
  1738. }
  1739. ##############################################################################
  1740. # Set to true/false to control if eatmydata is used during build
  1741. use_eatmydata=true
  1742. rootdir="$1"
  1743. fmdir="$(pwd)"
  1744. image="$fmdir"/"$2"
  1745. cd "$rootdir"
  1746. echo info: building "$MACHINE" for "$ARCHITECTURE"
  1747. export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
  1748. export LC_ALL=C LANGUAGE=C LANG=C
  1749. # Override libpam-tmpdir setting during build, as the directories
  1750. # are not created yet.
  1751. export TMP=/tmp/ TMPDIR=/tmp/
  1752. if [ ! "$MY_USERNAME" ]; then
  1753. echo $'No username was specified'
  1754. exit 52825
  1755. fi
  1756. username="$MY_USERNAME"
  1757. echo $"warning: creating initial user $username with well known password!"
  1758. password="$MY_PASSWORD"
  1759. chroot "$rootdir" /usr/bin/env -i \
  1760. HOME=/root \
  1761. PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
  1762. echo "export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:" >> "$rootdir/root/.bashrc"
  1763. chroot "$rootdir" adduser --gecos "$username" --disabled-password "$username"
  1764. echo "$username:$password" | chroot "$rootdir" /usr/sbin/chpasswd
  1765. chroot "$rootdir" adduser "$username" sudo
  1766. if [ ! "$DEBIAN_REPO" ]; then
  1767. DEBIAN_REPO='ftp.de.debian.org'
  1768. fi
  1769. if [ ! "$DEBIAN_VERSION" ]; then
  1770. DEBIAN_VERSION='stretch'
  1771. fi
  1772. set_apt_sources "$BUILD_MIRROR"
  1773. chroot "$rootdir" apt-get clean
  1774. chroot "$rootdir" /bin/rm -rf /var/lib/apt/lists/*
  1775. chroot "$rootdir" apt-get clean
  1776. set_apt_sources "$MIRROR"
  1777. configure_backports
  1778. configure_contrib_repo
  1779. chroot "$rootdir" apt-get update
  1780. chroot "$rootdir" apt-get install -y apt-utils
  1781. cat > "$rootdir/usr/sbin/policy-rc.d" <<EOF
  1782. #!/bin/sh
  1783. exit 101
  1784. EOF
  1785. chmod a+rx "$rootdir/usr/sbin/policy-rc.d"
  1786. if "$use_eatmydata" ; then
  1787. enable_eatmydata_override
  1788. fi
  1789. if [ -n "$CUSTOM_SETUP" ]; then
  1790. cp "$CUSTOM_SETUP" "$rootdir"/tmp
  1791. chroot "$rootdir" apt-get install -y gdebi-core
  1792. chroot "$rootdir" gdebi -n "/tmp/$(basename "$CUSTOM_SETUP")"
  1793. fi
  1794. if [[ "$VARIANT" != "mesh"* ]]; then
  1795. chroot "$rootdir" apt-get install -y openssh-server
  1796. fi
  1797. chroot "$rootdir" apt-get install -y sudo git dialog build-essential
  1798. chroot "$rootdir" apt-get install -y avahi-daemon avahi-utils avahi-discover
  1799. chroot "$rootdir" apt-get install -y iptables dnsutils net-tools network-manager iputils-ping
  1800. chroot "$rootdir" apt-get install -y libnss-mdns libnss-myhostname libnss-gw-name nano man ntp
  1801. chroot "$rootdir" apt-get install -y locales locales-all debconf wireless-tools wpasupplicant usbutils
  1802. if [[ "$ARCHITECTURE" == 'qemu'* || "$ARCHITECTURE" == 'i386' || "$ARCHITECTURE" == 'i686' || "$ARCHITECTURE" == 'amd64' || "$ARCHITECTURE" == 'x86_64' ]]; then
  1803. chroot "$rootdir" apt-get install -y cryptsetup zsh pinentry-curses iotop bc
  1804. chroot "$rootdir" apt-get install -y grub2 hostapd lvm2
  1805. fi
  1806. sed -i "s|#host-name=.*|host-name=${LOCAL_NAME}|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1807. sed -i "s|host-name=.*|host-name=${LOCAL_NAME}|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1808. sed -i 's|#domain-name=.*|domain-name=local|g' "$rootdir/etc/avahi/avahi-daemon.conf"
  1809. sed -i 's|domain-name=.*|domain-name=local|g' "$rootdir/etc/avahi/avahi-daemon.conf"
  1810. sed -i "s|use-ipv4=.*|use-ipv4=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1811. sed -i "s|use-ipv6=.*|use-ipv6=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1812. sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1813. sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" "$rootdir/etc/nsswitch.conf"
  1814. sed -i "s|#publish-domain=.*|publish-domain=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1815. sed -i "s|publish-domain=.*|publish-domain=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1816. sed -i "s|#publish-addresses=.*|publish-addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1817. sed -i "s|publish-addresses=.*|publish-addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1818. # Add an ssh avahi service
  1819. { echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->';
  1820. echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">';
  1821. echo '<service-group>';
  1822. echo ' <name replace-wildcards="yes">%h SSH</name>';
  1823. echo ' <service>';
  1824. echo ' <type>_ssh._tcp</type>';
  1825. echo " <port>$SSH_PORT</port>";
  1826. echo ' </service>';
  1827. echo '</service-group>'; } > "$rootdir/etc/avahi/services/ssh.service"
  1828. # Ensure that the avahi daemon keeps running
  1829. WATCHDOG_SCRIPT_NAME="keepon"
  1830. { echo '#!/bin/bash';
  1831. echo 'LOGFILE=/var/log/keepon.log';
  1832. echo "CURRENT_DATE=\$(date)";
  1833. echo '';
  1834. echo "# keep avahi-daemon daemon running";
  1835. echo "RUNNING=$(pgrep avahi-daemon > /dev/null && echo Running)";
  1836. echo "if [ ! \$RUNNING ]; then";
  1837. echo " systemctl start avahi-daemon";
  1838. echo " echo -n \$CURRENT_DATE >> \$LOGFILE";
  1839. echo " echo \"avahi-daemon daemon restarted\" >> \$LOGFILE";
  1840. echo 'fi';
  1841. echo "# End of avahi-daemon"; } > "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
  1842. chmod +x "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
  1843. echo "*/1 * * * * root /usr/bin/$WATCHDOG_SCRIPT_NAME" >> "$rootdir/etc/crontab"
  1844. chroot "$rootdir" /bin/bash -x <<EOF
  1845. git clone $PROJECT_REPO /root/$PROJECT_NAME
  1846. cd /root/$PROJECT_NAME
  1847. git checkout stretch
  1848. make install
  1849. cp image_build/bbb-4.9.0.tar.gz /boot/bbb.tar.gz
  1850. EOF
  1851. chroot "$rootdir" "${PROJECT_NAME}-image-hardware-setup" 2>&1 | \
  1852. tee "$rootdir/var/log/${PROJECT_NAME}-image-hardware-setup.log"
  1853. rm "$rootdir/usr/sbin/policy-rc.d"
  1854. # Set up HRNG for systems known to have one
  1855. # Otherwise install haveged
  1856. if [[ "$MACHINE" != "beaglebone"* ]]; then
  1857. # With some VMs, the hardware cycles counter is emulated and deterministic,
  1858. # and thus predictible, so havege should not be used
  1859. if [[ "$MACHINE" != "qemu"* ]]; then
  1860. chroot "$rootdir" apt-get -yq install haveged
  1861. fi
  1862. else
  1863. chroot "$rootdir" apt-get -yq install rng-tools
  1864. sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' "$rootdir/etc/default/rng-tools"
  1865. fi
  1866. # copy u-boot to beginning of image
  1867. case "$MACHINE" in
  1868. beaglebone)
  1869. dd if="$rootdir/usr/lib/u-boot/am335x_boneblack/MLO" of="$image" \
  1870. count=1 seek=1 conv=notrunc bs=128k
  1871. dd if="$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img" of="$image" \
  1872. count=2 seek=1 conv=notrunc bs=384k
  1873. ;;
  1874. cubieboard2)
  1875. dd if="$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin" of="$image" \
  1876. seek=8 conv=notrunc bs=1k
  1877. ;;
  1878. a20-olinuxino-lime)
  1879. dd if="$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin" \
  1880. of="$image" seek=8 conv=notrunc bs=1k
  1881. ;;
  1882. esac
  1883. if "$use_eatmydata" ; then
  1884. disable_eatmydata_override
  1885. fi
  1886. configure_ssh
  1887. configure_networking
  1888. admin_user_sudo
  1889. create_generic_image
  1890. atheros_wifi
  1891. continue_installation
  1892. image_install_nodejs
  1893. initialise_mesh
  1894. configure_wifi
  1895. configure_user_interface
  1896. image_setup_utils
  1897. image_install_inadyn
  1898. image_install_pleroma
  1899. image_preinstall_repos
  1900. # remove downloaded packages
  1901. chroot "$rootdir" apt-get -y autoremove
  1902. chroot "$rootdir" apt-get clean
  1903. cd /
  1904. echo $"info: killing leftover processes in chroot"
  1905. fuser -mvk "$rootdir/." || true
  1906. exit 0