freedombone-image-customise 94KB

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