freedombone-image-customise 93KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194
  1. #!/bin/bash
  2. # _____ _ _
  3. # | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
  4. # | __| _| -_| -_| . | . | | . | . | | -_|
  5. # |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
  6. #
  7. # Freedom in the Cloud
  8. #
  9. # Based on bin/freedombox-customize from freedom-maker
  10. #
  11. # License
  12. # =======
  13. #
  14. # Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. set -e
  29. set -x
  30. PROJECT_NAME='freedombone'
  31. LOCAL_NAME=${PROJECT_NAME}
  32. INSTALL_DIR=/root/build
  33. COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
  34. PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
  35. VARIANT='full'
  36. # username created by default within a debian image
  37. GENERIC_IMAGE_USERNAME='fbone'
  38. export TEXTDOMAIN=${PROJECT_NAME}-image-customise
  39. export TEXTDOMAINDIR="/usr/share/locale"
  40. # Whether to minimise the number of decisions during interactive install
  41. MINIMAL_INSTALL="yes"
  42. MY_USERNAME='debian'
  43. MY_PASSWORD="${PROJECT_NAME}"
  44. # Minimum number of characters in a password
  45. MINIMUM_PASSWORD_LENGTH=10
  46. # IP address of the router (gateway)
  47. ROUTER_IP_ADDRESS="192.168.1.254"
  48. # The fixed IP address of the Beaglebone Black on your local network
  49. BOX_IP_ADDRESS="192.168.1.55"
  50. # DNS
  51. NAMESERVER1='91.239.100.100'
  52. NAMESERVER2='89.233.43.71'
  53. NAMESERVER3='87.118.100.175'
  54. NAMESERVER4='94.75.228.29'
  55. NAMESERVER5='85.25.251.254'
  56. NAMESERVER6='2.141.58.13'
  57. # optional configuration file containing freedombone settings
  58. CONFIG_FILENAME=
  59. # Optional ssh public key to allow
  60. SSH_PUBKEY="no"
  61. # Whether this is a generic image for mass redistribution on the interwebs
  62. GENERIC_IMAGE="no"
  63. # default SSH port
  64. SSH_PORT=2222
  65. # for mesh installs
  66. TRACKER_PORT=6969
  67. # Whether sites are accessible only within a Tor browser
  68. ONION_ONLY="no"
  69. # Whether to only install debian and nothing else
  70. DEBIAN_INSTALL_ONLY="no"
  71. # wifi settings
  72. WIFI_INTERFACE='wlan0'
  73. WIFI_SSID=
  74. WIFI_TYPE='wpa2-psk'
  75. WIFI_PASSPHRASE=
  76. WIFI_HOTSPOT='no'
  77. WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
  78. # Whether to install non-free wifi drivers for the mesh client
  79. INSECURE='no'
  80. # optional desktop background image for mesh
  81. MESH_DESKTOP_BACKGROUND_IMAGE=/usr/local/share/${PROJECT_NAME}_mesh_initial_background.png
  82. # The browser application to use
  83. BROWSER=firefox
  84. BROWSER_OPTIONS='-url'
  85. MESH_INSTALL_DIR=/var/lib
  86. # for mesh installs whether to delete all data and generate
  87. # a new identity at every shutdown/boot
  88. AMNESIC='no'
  89. # Whether this is a dedicated gnusocial or postactiv instance
  90. SOCIALINSTANCE=
  91. # defines the initial keyboard layout
  92. KEYBOARD_MAP='gb'
  93. # Strings used for setting the username
  94. MESH_TITLE=$"Freedombone Mesh"
  95. MESH_SET_USERNAME=$"Welcome to the Freedombone mesh.\n\nThe first thing you will need to do is set a username so that other peers can find you."
  96. # Whether to enable zeronet on the mesh
  97. ENABLE_ZERONET=
  98. MESH_TEXT_EDITOR='pluma'
  99. BABEL_REPO="https://github.com/jech/babeld"
  100. BABEL_COMMIT='d9390d1fee337c464e67255bbbd879d975e126e2'
  101. OLSR2_REPO="https://github.com/OLSR/OONF"
  102. OLSR2_COMMIT='81033251c4ee1c5699bfee9d2985112c6266ab0a'
  103. BMX6_REPO="https://github.com/bmx-routing/bmx6"
  104. BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181'
  105. BMX7_REPO="https://github.com/bmx-routing/bmx7"
  106. BMX7_COMMIT='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 ' shred -zu ~/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
  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 "touch /home/$MY_USERNAME/.dbus/Xdbus";
  887. echo "chmod 600 /home/$MY_USERNAME/.dbus/Xdbus";
  888. echo "env | grep DBUS_SESSION_BUS_ADDRESS > /home/$MY_USERNAME/.dbus/Xdbus";
  889. echo "echo 'export DBUS_SESSION_BUS_ADDRESS' >> /home/$MY_USERNAME/.dbus/Xdbus";
  890. echo '';
  891. echo "amixer set 'Master' unmute";
  892. echo "amixer set 'Master' 50%";
  893. echo '';
  894. echo '';
  895. echo "if [ ! -f $FIRST_BOOT ]; then";
  896. echo ' if [ -d /var/lib/tahoelafs ]; then';
  897. echo " $TAHOE_COMMAND start";
  898. echo ' fi';
  899. echo ' exit 0';
  900. echo 'fi';
  901. echo '';
  902. echo 'INITIAL_TOX_USERNAME=""';
  903. echo "while [ \${#INITIAL_TOX_USERNAME} -eq 0 ]; do";
  904. echo " data=\$(zenity --entry --title=\"$MESH_TITLE\" --text=\"$MESH_SET_USERNAME\")";
  905. echo ' accepted=$?';
  906. echo ' if ((accepted == 0)); then';
  907. echo " INITIAL_TOX_USERNAME=\$(awk -F, '{print \$1}' <<<\$data)";
  908. echo ' fi';
  909. echo 'done';
  910. echo '';
  911. echo "toxid --setuser \"\$INITIAL_TOX_USERNAME\"";
  912. echo '';
  913. echo "if [ -f /home/$MY_USERNAME/.tahoe/tahoe.cfg ]; then";
  914. echo " sed -i 's|nickname =.*|nickname = \$INITIAL_TOX_USERNAME|g' /home/$MY_USERNAME/.tahoe/tahoe.cfg";
  915. echo " $TAHOE_COMMAND restart";
  916. echo 'fi';
  917. echo '';
  918. echo "rm -f $FIRST_BOOT";
  919. echo '';
  920. echo 'exit 0'; } > "$START_DESKTOP"
  921. chmod +x "$START_DESKTOP"
  922. START_DESKTOP2="$rootdir/home/$MY_USERNAME/.config/autostart/mesh-start.desktop"
  923. { echo '[Desktop Entry]';
  924. echo 'Type=Application';
  925. echo 'Name=Mesh start desktop script';
  926. echo "Exec=bash -c '~/mesh-desktop.sh'";
  927. echo 'X-GNOME-Autostart-enabled=true'; } > "$START_DESKTOP2"
  928. chmod +x "$START_DESKTOP2"
  929. }
  930. mesh_desktop_icons() {
  931. if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
  932. mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
  933. fi
  934. # Terminal
  935. #echo '[Desktop Entry]' > $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  936. #echo 'Name=MATE Terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  937. #echo 'Type=Application' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  938. #echo 'Comment=Use the command line' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  939. #echo 'TryExec=mate-terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  940. #echo 'Exec=mate-terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  941. #echo 'Icon=terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  942. #echo 'StartupNotify=true' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
  943. chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
  944. }
  945. configure_user_interface() {
  946. if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
  947. return
  948. fi
  949. # desktop
  950. chroot "$rootdir" apt-get -yq install mate-desktop-environment
  951. # tool to change desktop settings from command line
  952. chroot "$rootdir" apt-get -yq install dconf-cli dconf-gsettings-backend dbus dbus-x11
  953. # for tomb
  954. chroot "$rootdir" apt-get -yq install pinentry-gtk2
  955. # for tox video
  956. chroot "$rootdir" apt-get -yq install ffmpeg cheese v4l-utils
  957. # to provide notifications
  958. chroot "$rootdir" apt-get -yq install libnotify-bin
  959. # for video/audio
  960. chroot "$rootdir" apt-get -yq install libtheora-bin libvorbis-dev v4l-utils
  961. # a sane editor
  962. chroot "$rootdir" apt-get -yq install emacs
  963. # for wifi monitoring
  964. chroot "$rootdir" apt-get -yq install horst
  965. # for sound level control
  966. chroot "$rootdir" apt-get -yq install alsa-utils pavucontrol
  967. # to play various media types
  968. chroot "$rootdir" apt-get -yq install vlc
  969. # android adb to allow phones to be connected and for example transfer photos/documents
  970. chroot "$rootdir" apt-get -yq install android-tools-adb
  971. # USB cloning tool
  972. chroot "$rootdir" apt-get -yq install gnome-multi-writer
  973. # clipboard
  974. chroot "$rootdir" apt-get -yq install xclip
  975. # multimedia recording and editing
  976. chroot "$rootdir" apt-get -yq install audacity
  977. chroot "$rootdir" apt-get -yq install shotwell
  978. chroot "$rootdir" apt-get -yq install kdenlive breeze-icon-theme
  979. # for gtk dialog entry
  980. chroot "$rootdir" apt-get -yq install zenity
  981. # Produce a text file on the desktop listing users on the mesh
  982. cat <<EOF > "$rootdir/usr/bin/list-tox-users"
  983. #!/bin/bash
  984. StrMeshUsers=\$"Mesh Users"
  985. StrUsername=\$'Username'
  986. StrToxID=\$'Tox ID'
  987. ethernet_connected=\$(cat /sys/class/net/eth0/carrier)
  988. users_list=\$(lstox | awk -F ' ' '{\$1=""; print \$0}' | sed -e 's/^[[:space:]]*//' | sort -d | uniq)
  989. if [ \${#users_list} -eq 0 ]; then
  990. no_of_users=0
  991. else
  992. no_of_users=\$(echo "\$users_list" | wc -l)
  993. fi
  994. if [ \$no_of_users -gt 0 ]; then
  995. echo "\$users_list" > /tmp/Users.txt
  996. chown $MY_USERNAME:$MY_USERNAME /tmp/Users.txt
  997. if [ ! -f /home/$MY_USERNAME/showusers ]; then
  998. echo '#!/bin/bash' > /home/$MY_USERNAME/showusers
  999. echo 'data=\$(' >> /home/$MY_USERNAME/showusers
  1000. echo 'cat /tmp/Users.txt | \\' >> /home/$MY_USERNAME/showusers
  1001. echo " awk -F ' ' '{" >> /home/$MY_USERNAME/showusers
  1002. echo ' for(i=1;i<=NF;i++){' >> /home/$MY_USERNAME/showusers
  1003. echo ' print \$i;' >> /home/$MY_USERNAME/showusers
  1004. echo ' }' >> /home/$MY_USERNAME/showusers
  1005. echo "}' | \\\\" >> /home/$MY_USERNAME/showusers
  1006. echo ' zenity --list \\' >> /home/$MY_USERNAME/showusers
  1007. echo " --title='\$StrMeshUsers' \\\\" >> /home/$MY_USERNAME/showusers
  1008. echo " --column='\$StrUsername' --column='\$StrToxID' \\\\" >> /home/$MY_USERNAME/showusers
  1009. echo ' --print-column=2 --hide-column=2 --width=250 --height=400)' >> /home/$MY_USERNAME/showusers
  1010. echo 'if [ ! \$data ]; then' >> /home/$MY_USERNAME/showusers
  1011. echo ' exit 0' >> /home/$MY_USERNAME/showusers
  1012. echo 'fi' >> /home/$MY_USERNAME/showusers
  1013. echo 'echo "\$data" | xclip -selection clipboard' >> /home/$MY_USERNAME/showusers
  1014. chmod +x /home/$MY_USERNAME/showusers
  1015. fi
  1016. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/Users.desktop
  1017. if [ \$no_of_users -lt 2 ]; then
  1018. echo "Name=\$no_of_users Other User" >> /home/$MY_USERNAME/Desktop/Users.desktop
  1019. else
  1020. echo "Name=\$no_of_users Other Users" >> /home/$MY_USERNAME/Desktop/Users.desktop
  1021. fi
  1022. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1023. echo 'Comment=List of users' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1024. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1025. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1026. echo "Comment[ca]=Llista d'usuaris" >> /home/$MY_USERNAME/Desktop/Users.desktop
  1027. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1028. echo 'Comment[fr]=Liste des utilisateurs' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1029. echo 'Comment[de]=Liste der Benutzer' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1030. echo 'Comment[es]=Lista de usuarios' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1031. echo 'Comment[it]=Elenco degli utenti' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1032. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1033. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1034. echo 'Exec=bash /home/$MY_USERNAME/showusers' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1035. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_users.png' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1036. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/Users.desktop
  1037. chmod +x /home/$MY_USERNAME/Desktop/Users.desktop
  1038. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/Users.desktop
  1039. if [ ! -f /home/$MY_USERNAME/.cryptpad.desktop ]; then
  1040. if [ ! -f /home/$MY_USERNAME/Desktop/cryptpad.desktop ]; then
  1041. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1042. echo 'Name=CryptPad' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1043. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1044. echo 'Comment=Realtime collaborative editing of documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1045. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1046. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1047. echo 'Comment[ca]=Edici collaborativa en temps real de documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1048. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1049. echo 'Comment[fr]=Edition collaborative en temps rel de documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1050. echo 'Comment[de]=Kollaboratives Echtzeit-Editing von Dokumenten' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1051. echo 'Comment[es]=Edicin colaborativa en tiempo real de documentos' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1052. echo 'Comment[it]=Editing collaborativo di documenti in tempo reale' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1053. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1054. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1055. echo "Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local" >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1056. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_cryptpad.png" >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1057. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1058. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1059. chmod +x /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1060. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1061. else
  1062. if ! grep -q "\${HOSTNAME}.local" /home/$MY_USERNAME/Desktop/cryptpad.desktop; then
  1063. sed -i "s|Exec=.*|Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local|g" /home/$MY_USERNAME/Desktop/cryptpad.desktop
  1064. fi
  1065. fi
  1066. fi
  1067. if [ -d /etc/peertube ]; then
  1068. if [ ! -f /home/$MY_USERNAME/.peertube.desktop ]; then
  1069. if [ ! -f /home/$MY_USERNAME/Desktop/peertube.desktop ]; then
  1070. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/peertube.desktop
  1071. echo 'Name=PeerTube' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1072. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1073. echo 'Comment=Upload and view videos on the mesh' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1074. echo 'Comment[el]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1075. echo 'Comment[ar]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1076. echo 'Comment[ca]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1077. echo 'Comment[hi]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1078. echo 'Comment[fr]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1079. echo 'Comment[de]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1080. echo 'Comment[es]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1081. echo 'Comment[it]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1082. echo 'Comment[ru]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1083. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1084. echo "Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local:$MESH_PEERTUBE_PORT" >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1085. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_peertube.png" >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1086. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1087. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/peertube.desktop
  1088. chmod +x /home/$MY_USERNAME/Desktop/peertube.desktop
  1089. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/peertube.desktop
  1090. else
  1091. if ! grep -q "\${HOSTNAME}.local" /home/$MY_USERNAME/Desktop/peertube.desktop; then
  1092. sed -i "s|Exec=.*|Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local:$MESH_PEERTUBE_PORT|g" /home/$MY_USERNAME/Desktop/peertube.desktop
  1093. fi
  1094. fi
  1095. fi
  1096. fi
  1097. if [ ! -f /home/$MY_USERNAME/Desktop/social.desktop ]; then
  1098. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/social.desktop
  1099. echo 'Name=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1100. echo 'Name[el]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1101. echo 'Name[ar]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1102. echo 'Name[ca]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1103. echo 'Name[hi]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1104. echo 'Name[fr]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1105. echo 'Name[de]=Soziale' >> /home/$MY_USERNAME/Desktop/social.desktop
  1106. echo 'Name[es]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
  1107. echo 'Name[it]=Sociale' >> /home/$MY_USERNAME/Desktop/social.desktop
  1108. echo 'Name[ru]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1109. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/social.desktop
  1110. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/social.desktop
  1111. echo "Comment=A decentralized messaging and sharing app built on top of Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1112. echo "Comment[el]= Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1113. echo "Comment[ar]= ()" >> /home/$MY_USERNAME/Desktop/social.desktop
  1114. echo "Comment[ca]=Una aplicaci de missatgeria i distribuci descentralitzada integrada a Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1115. echo "Comment[hi]= () " >> /home/$MY_USERNAME/Desktop/social.desktop
  1116. echo "Comment[fr]=Une application de messagerie et de partage dcentralise base sur Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1117. echo "Comment[de]=Eine dezentralisierte Messaging- und Sharing-App, die auf Secure Scuttlebutt basiert" >> /home/$MY_USERNAME/Desktop/social.desktop
  1118. echo "Comment[es]=Una aplicacin de mensajera y uso compartido descentralizada construida sobre Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1119. echo "Comment[it]=Un'applicazione decentralizzata di messaggistica e condivisione costruita sulla base di Secure Shuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1120. echo "Comment[ru]= , Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1121. echo "Comment[zh]=Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
  1122. echo 'Exec=bash /usr/bin/start_patchwork' >> /home/$MY_USERNAME/Desktop/social.desktop
  1123. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_social.png" >> /home/$MY_USERNAME/Desktop/social.desktop
  1124. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/social.desktop
  1125. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/social.desktop
  1126. chmod +x /home/$MY_USERNAME/Desktop/social.desktop
  1127. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/social.desktop
  1128. fi
  1129. #if [ ! -f /home/$MY_USERNAME/Desktop/audio.desktop ]; then
  1130. # echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/audio.desktop
  1131. # echo 'Name=Audio/Music' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1132. # echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1133. # echo 'Comment=Audio publishing and streaming' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1134. # echo 'Exec=bash /usr/bin/start_ferment' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1135. # echo "Icon=/etc/patchwork/icon_ferment.png" >> /home/$MY_USERNAME/Desktop/audio.desktop
  1136. # echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1137. # echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/audio.desktop
  1138. # chmod +x /home/$MY_USERNAME/Desktop/audio.desktop
  1139. # chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/audio.desktop
  1140. #fi
  1141. if [ ! -f /home/$MY_USERNAME/Desktop/vpn.desktop ]; then
  1142. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/vpn.desktop
  1143. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1144. echo 'Name=Connect Meshes' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1145. echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1146. echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1147. echo 'Name[ca]=Connecteu malles' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1148. echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1149. echo 'Name[fr]=Connecter les maillages' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1150. echo 'Name[de]=Netze verbinden' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1151. echo 'Name[es]=Conectar Mallas' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1152. echo 'Name[it]=Collegare le maglie' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1153. echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1154. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1155. echo 'Comment=Connect to another mesh network via the internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1156. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1157. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1158. echo "Comment[ca]=Connecteu-vos a una altra xarxa de malla a travs d'Internet" >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1159. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1160. echo 'Comment[fr]=Connectez-vous un autre rseau maill via Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1161. echo 'Comment[de]=Verbindung mit einem anderen Mesh-Netzwerk ber das Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1162. echo 'Comment[es]=Conctese a otra red en malla a travs de Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1163. echo "Comment[it]=Collegarsi ad un'altra rete di maglie via internet" >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1164. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1165. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1166. echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-connect' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1167. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_connect.png' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1168. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/vpn.desktop
  1169. chmod +x /home/$MY_USERNAME/Desktop/vpn.desktop
  1170. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/vpn.desktop
  1171. fi
  1172. if [ ! -f /home/$MY_USERNAME/Desktop/routing.desktop ]; then
  1173. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/routing.desktop
  1174. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1175. echo 'Name=Routing Protocol' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1176. echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1177. echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1178. echo "Name[ca]=Protocol d'enrutament" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1179. echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1180. echo 'Name[fr]=Protocole de routage' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1181. echo 'Name[de]=Routingprotokoll' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1182. echo 'Name[es]=Protocolo de enrutamiento' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1183. echo 'Name[it]=Protocollo di routing' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1184. echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1185. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1186. echo 'Comment=Select the mesh routing protocol' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1187. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1188. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1189. echo "Comment[ca]=Seleccioneu el protocol d'enrutament de malles" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1190. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1191. echo 'Comment[fr]=Slectionnez le protocole de routage de maillage' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1192. echo 'Comment[de]=Whlen Sie das Mesh-Routing-Protokoll' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1193. echo 'Comment[es]=Seleccione el protocolo de enrutamiento de malla' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1194. echo "Comment[it]=Seleziona il protocollo di instradamento della mesh" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1195. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1196. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1197. echo "Exec=mate-terminal -e \"/usr/local/bin/${PROJECT_NAME}-mesh-routing\"" >> /home/$MY_USERNAME/Desktop/routing.desktop
  1198. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_routing.png' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1199. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1200. echo 'Categories=Application' >> /home/$MY_USERNAME/Desktop/routing.desktop
  1201. chmod +x /home/$MY_USERNAME/Desktop/routing.desktop
  1202. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/routing.desktop
  1203. fi
  1204. if [ -f /tmp/.ipfs-users ]; then
  1205. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/sites.desktop
  1206. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1207. echo "Name=Visit a site" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1208. echo "Name[el]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1209. echo "Name[ar]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1210. echo "Name[ca]=Visiteu un lloc" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1211. echo "Name[hi]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1212. echo "Name[fr]=Visitez un site" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1213. echo "Name[de]=Besuchen Sie eine Website" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1214. echo "Name[es]=Visita un sitio" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1215. echo "Name[it]=Visita un sito" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1216. echo "Name[ru]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1217. echo "Name[zh]=" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1218. echo 'Comment=Visit a site' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1219. echo "Comment[el]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1220. echo "Comment[ar]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1221. echo "Commant[ca]=Visiteu un lloc" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1222. echo "Comment[hi]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1223. echo "Comment[fr]=Visitez un site" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1224. echo "Comment[de]=Besuchen Sie eine Website" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1225. echo "Comment[es]=Visita un sitio" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1226. echo "Comment[it]=Visita un sito" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1227. echo "Comment[ru]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
  1228. echo "Comment[zh]=" >> /home/$MY_USERNAME/Desktop/sites.desktop
  1229. echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-visit-site' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1230. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_sites.png' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1231. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/sites.desktop
  1232. chmod +x /home/$MY_USERNAME/Desktop/sites.desktop
  1233. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/sites.desktop
  1234. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/blog.desktop
  1235. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1236. echo "Name=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1237. echo "Name[el]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1238. echo "Name[ar]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1239. echo "Name[ca]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1240. echo "Name[hi]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1241. echo "Name[fr]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1242. echo "Name[de]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1243. echo "Name[es]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1244. echo "Name[it]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1245. echo "Name[ru]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1246. echo "Name[zh]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
  1247. echo 'Comment=View or create blog entries' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1248. echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1249. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1250. echo 'Comment[ca]=Permet visualitzar o crear entrades de bloc' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1251. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1252. echo 'Comment[fr]=Afficher ou crer des entres de blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1253. echo 'Comment[de]=Blog-Eintrge anzeigen oder erstellen' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1254. echo 'Comment[es]=Ver o crear entradas de blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1255. echo 'Comment[it]=Visualizza o crea voci di blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1256. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1257. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1258. echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1259. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_blog.png' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1260. echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/blog.desktop
  1261. chmod +x /home/$MY_USERNAME/Desktop/blog.desktop
  1262. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/blog.desktop
  1263. fi
  1264. if [ ! -f /home/$MY_USERNAME/runtox ]; then
  1265. echo 'qtox_running=\$(ps aux | grep qtox | grep data)' > /home/$MY_USERNAME/runtox
  1266. echo 'if [ \${#qtox_running} -eq 0 ]; then' >> /home/$MY_USERNAME/runtox
  1267. echo ' bash -c "qtox -p data"' >> /home/$MY_USERNAME/runtox
  1268. echo 'fi' >> /home/$MY_USERNAME/runtox
  1269. echo 'exit 0' >> /home/$MY_USERNAME/runtox
  1270. chmod +x /home/$MY_USERNAME/runtox
  1271. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/runtox
  1272. fi
  1273. if [ ! -f /home/$MY_USERNAME/Desktop/tox.desktop ]; then
  1274. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/tox.desktop
  1275. echo 'Name=Chat' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1276. echo 'Name[el]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1277. echo 'Name[ar]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1278. echo 'Name[ca]=Xat' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1279. echo 'Name[hi]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1280. echo 'Name[fr]=Bavarder' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1281. echo 'Name[de]=Chat' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1282. echo 'Name[es]=Charla' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1283. echo 'Name[it]=Chiacchierare' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1284. echo 'Name[ru]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1285. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1286. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1287. echo 'Comment=Chat, Voice and Video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1288. echo 'Comment[el]=, ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1289. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1290. echo 'Comment[ca]=Xat, veu i vdeo' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1291. echo 'Comment[hi]=, ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1292. echo 'Comment[fr]=Chat, voix et vido' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1293. echo 'Comment[de]=Chat, Sprache und Video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1294. echo 'Comment[es]=Chat, voz y video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1295. echo 'Comment[it]=Chat, voce e video' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1296. echo 'Comment[ru]=, ' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1297. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1298. echo 'Exec=bash /home/$MY_USERNAME/runtox' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1299. echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_chat.png" >> /home/$MY_USERNAME/Desktop/tox.desktop
  1300. echo 'StartupNotify=true' >> /home/$MY_USERNAME/Desktop/tox.desktop
  1301. chmod +x /home/$MY_USERNAME/Desktop/tox.desktop
  1302. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/tox.desktop
  1303. fi
  1304. # If ethernet is connected then add the invite icon to help enable
  1305. # SSB nat traversal
  1306. if [[ "\$ethernet_connected" != "0" ]]; then
  1307. if [ ! -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
  1308. echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/invite.desktop
  1309. echo 'Version=1.0' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1310. echo 'Name=Create Invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1311. echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1312. echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1313. echo 'Name[ca]=Crea una invitaci' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1314. echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1315. echo 'Name[fr]=Crer une invitation' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1316. echo 'Name[de]=Einladung erstellen' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1317. echo 'Name[es]=Crear invitacin' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1318. echo 'Name[it]=Crea Invita' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1319. echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1320. echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1321. echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1322. echo 'Comment=Create an invite for Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1323. echo 'Comment[el]= Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1324. echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1325. echo 'Comment[ca]=Crea una invitaci per Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1326. echo 'Comment[hi]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1327. echo 'Comment[fr]=Crer une invitation pour Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1328. echo 'Comment[de]=Erstellen Sie eine Einladung fr Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1329. echo 'Comment[es]=Crear una invitacin para Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1330. echo 'Comment[it]=Crea un invito per patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1331. echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1332. echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1333. echo 'Exec=mate-terminal -e ${PROJECT_NAME}-mesh-invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1334. echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_invite.png' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1335. echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1336. echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/invite.desktop
  1337. chmod +x /home/$MY_USERNAME/Desktop/invite.desktop
  1338. fi
  1339. else
  1340. if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
  1341. rm /home/$MY_USERNAME/Desktop/invite.desktop
  1342. fi
  1343. fi
  1344. else
  1345. if [ -f /tmp/Users.txt ]; then
  1346. rm /tmp/Users.txt
  1347. rm /home/$MY_USERNAME/Desktop/Users.desktop
  1348. if [ -f /home/$MY_USERNAME/Desktop/Users.desktop ]; then
  1349. rm /home/$MY_USERNAME/Desktop/Users.desktop
  1350. fi
  1351. if [ -f /home/$MY_USERNAME/Desktop/sites.desktop ]; then
  1352. rm /home/$MY_USERNAME/Desktop/sites.desktop
  1353. fi
  1354. if [ -f /home/$MY_USERNAME/Desktop/blog.desktop ]; then
  1355. rm /home/$MY_USERNAME/Desktop/blog.desktop
  1356. fi
  1357. if [ -f /home/$MY_USERNAME/Desktop/tox.desktop ]; then
  1358. rm /home/$MY_USERNAME/Desktop/tox.desktop
  1359. fi
  1360. pkill qtox
  1361. fi
  1362. # If there is no ethernet then remove the invite icon
  1363. if [[ "\$ethernet_connected" == "0" ]]; then
  1364. if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
  1365. rm /home/$MY_USERNAME/Desktop/invite.desktop
  1366. fi
  1367. fi
  1368. fi
  1369. EOF
  1370. chroot "$rootdir" /bin/chown "$MY_USERNAME":"$MY_USERNAME" /usr/bin/list-tox-users
  1371. chroot "$rootdir" /bin/chmod +x /usr/bin/list-tox-users
  1372. echo "* * * * * $MY_USERNAME bash -c /usr/bin/list-tox-users > /dev/null" >> "$rootdir/etc/crontab"
  1373. if [[ "$VARIANT" != "usb" ]]; then
  1374. # log in automatically
  1375. chroot "$rootdir" apt-get -y install nodm xinit
  1376. echo 'NODM_ENABLED=true' > /etc/default/nodm
  1377. echo "NODM_USER=$MY_USERNAME" >> /etc/default/nodm
  1378. chroot "$rootdir" mkdir /etc/systemd/system/getty@tty1.service.d
  1379. { echo '[Service]';
  1380. echo 'ExecStart=';
  1381. echo "ExecStart=-/sbin/agetty --autologin fbone --noclear %I \$TERM"; } > "$rootdir/etc/systemd/system/getty@tty1.service.d/override.conf"
  1382. echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx" >> "$rootdir/home/$MY_USERNAME/.profile"
  1383. chroot "$rootdir" systemctl set-default multi-user.target
  1384. mesh_client_startup_applications
  1385. mesh_desktop_icons
  1386. # Different desktop background for amnesic
  1387. if [[ "$AMNESIC" != 'no' ]]; then
  1388. MESH_DESKTOP_BACKGROUND_IMAGE="/usr/local/share/${PROJECT_NAME}_mesh_amnesic_background.png"
  1389. fi
  1390. # change the desktop background
  1391. if [ "$MESH_DESKTOP_BACKGROUND_IMAGE" ]; then
  1392. if [ -f "$MESH_DESKTOP_BACKGROUND_IMAGE" ]; then
  1393. if [ -d "$rootdir/usr/share/images/desktop-base" ]; then
  1394. cp "$MESH_DESKTOP_BACKGROUND_IMAGE" "$rootdir/usr/share/images/desktop-base/${PROJECT_NAME}_mesh_background.png"
  1395. chroot "$rootdir" /bin/rm /usr/share/images/desktop-base/desktop-background
  1396. chroot "$rootdir" ln -s "/usr/share/images/desktop-base/${PROJECT_NAME}_mesh_background.png" /usr/share/images/desktop-base/desktop-background
  1397. fi
  1398. fi
  1399. fi
  1400. else
  1401. chroot "$rootdir" apt-get -yq install lightdm
  1402. fi
  1403. # browser
  1404. chroot "$rootdir" apt-get -yq install firefox-esr
  1405. # help
  1406. mkdir -p "$rootdir/home/${MY_USERNAME}/help/images"
  1407. cd "$rootdir/root/${PROJECT_NAME}/website" || exit 2346872684
  1408. ./deploy.sh EN "$rootdir/home/${MY_USERNAME}/help"
  1409. chroot "$rootdir" /bin/chown -R "${MY_USERNAME}":"${MY_USERNAME}" "/home/${MY_USERNAME}/help"
  1410. # Tox user interface
  1411. #enable_tox_repo
  1412. mesh_tox_qtox
  1413. # copy the default qtox ini file
  1414. if [ ! -d "${rootdir}/home/${MY_USERNAME}/.config/tox" ]; then
  1415. mkdir "${rootdir}/home/${MY_USERNAME}/.config/tox"
  1416. cp "/usr/local/bin/${PROJECT_NAME}-config-qtox" "${rootdir}/home/${MY_USERNAME}/.config/tox/qtox.ini"
  1417. chroot "$rootdir" /bin/chown -R "${MY_USERNAME}":"${MY_USERNAME}" "/home/${MY_USERNAME}/.config"
  1418. fi
  1419. if [[ "$VARIANT" == "usb" ]]; then
  1420. # tor
  1421. chroot "$rootdir" apt-get -yq -t stretch-backports install tor
  1422. # xmpp client
  1423. chroot "$rootdir" echo "deb ftp://ftp.gajim.org/debian unstable main" > /etc/apt/sources.list.d/gajim.list
  1424. chroot "$rootdir" apt-get update
  1425. chroot "$rootdir" apt-get -yq install gajim-dev-keyring
  1426. chroot "$rootdir" apt-get -yq install git python-dev python-pip gajim-nightly
  1427. chroot "$rootdir" mkdir "/home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins" -p
  1428. chroot "$rootdir" git clone https://github.com/omemo/gajim-omemo "/home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins/gajim-omemo"
  1429. chroot "$rootdir" pip install protobuf==2.6.1, python-axolotl==0.1.35
  1430. chroot "$rootdir" /bin/chown -R "$GENERIC_IMAGE_USERNAME":"$GENERIC_IMAGE_USERNAME" "/home/$GENERIC_IMAGE_USERNAME/.local"
  1431. # IRC client
  1432. chroot "$rootdir" apt-get -yq install hexchat profanity
  1433. fi
  1434. }
  1435. ##############################################################################
  1436. # setup_utils
  1437. ##############################################################################
  1438. image_install_inadyn() {
  1439. if [ "$INSTALLING_MESH" ]; then
  1440. return
  1441. fi
  1442. if [ ! -d "$rootdir/root/build" ]; then
  1443. mkdir -p "$rootdir/root/build"
  1444. fi
  1445. chroot "$rootdir" apt-get -yq install build-essential curl libgnutls28-dev automake1.11 libconfuse-dev
  1446. chroot "$rootdir" apt-get -yq install gnutls-dev libconfuse-dev pkg-config libssl-dev
  1447. if [ -d /repos/inadyn ]; then
  1448. mkdir "$rootdir/root/build/inadyn"
  1449. cp -r -p /repos/inadyn/. "$rootdir/root/build/inadyn"
  1450. cd "$rootdir/root/build/inadyn" || exit 24729466456
  1451. git pull
  1452. else
  1453. git clone "$INADYN_REPO" "$rootdir/root/build/inadyn"
  1454. fi
  1455. if [ ! -d "$rootdir/root/build/inadyn" ]; then
  1456. echo 'Failed to clone inadyn'
  1457. exit 728252
  1458. fi
  1459. cd "$rootdir/root/build/inadyn" || exit 3468724568
  1460. git checkout "$INADYN_COMMIT" -b "$INADYN_COMMIT"
  1461. cd "$rootdir/root/build/inadyn" || exit 24682464628
  1462. { echo '#!/bin/bash';
  1463. echo 'cd ~/build/inadyn';
  1464. echo './autogen.sh';
  1465. echo './configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-openssl';
  1466. echo 'make -j5';
  1467. echo 'make install-strip'; } > "$rootdir/root/build/build_inadyn.sh"
  1468. chmod +x "$rootdir/root/build/build_inadyn.sh"
  1469. chroot "$rootdir" /root/build/build_inadyn.sh
  1470. if [ ! -f "$rootdir/usr/sbin/inadyn" ]; then
  1471. echo 'Failed to build inadyn'
  1472. exit 6209356
  1473. fi
  1474. # create a configuration file
  1475. { echo 'period = 300';
  1476. echo ''; } > "$rootdir/etc/inadyn.conf"
  1477. chmod 600 "$rootdir/etc/inadyn.conf"
  1478. { echo '[Unit]';
  1479. echo 'Description=Internet Dynamic DNS Client';
  1480. echo 'Documentation=man:inadyn';
  1481. echo 'Documentation=man:inadyn.conf';
  1482. echo 'Documentation=https://github.com/troglobit/inadyn';
  1483. echo 'ConditionPathExists=/etc/inadyn.conf';
  1484. echo 'After=network-online.target';
  1485. echo 'Requires=network-online.target';
  1486. echo '';
  1487. echo '[Service]';
  1488. echo 'Type=simple';
  1489. echo "ExecStart=/usr/sbin/inadyn -C -n -s --loglevel=err --config ${INADYN_CONFIG_FILE}";
  1490. echo 'Restart=on-failure';
  1491. echo 'RestartSec=10';
  1492. echo '';
  1493. echo '[Install]';
  1494. echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/inadyn.service"
  1495. chroot "$rootdir" systemctl enable inadyn
  1496. echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1497. }
  1498. image_setup_utils() {
  1499. if [ "$INSTALLING_MESH" ]; then
  1500. return
  1501. fi
  1502. chroot "$rootdir" apt-get -yq install apt-transport-https
  1503. chroot "$rootdir" apt-get -yq remove --purge apache2-bin*
  1504. chroot "$rootdir" apt-get -yq dist-upgrade
  1505. chroot "$rootdir" apt-get -yq install ca-certificates
  1506. chroot "$rootdir" apt-get -yq install apt-utils
  1507. chroot "$rootdir" apt-get -yq install shellcheck hdparm
  1508. if [[ "$ARCHITECTURE" == 'amd64' ]]; then
  1509. chroot "$rootdir" apt-get -yq install linux-image-amd64
  1510. fi
  1511. if [[ "$ARCHITECTURE" == 'qemu'* || "$ARCHITECTURE" == 'amd64' || "$ARCHITECTURE" == 'x86_64' || "$ARCHITECTURE" == 'i686' || "$ARCHITECTURE" == 'i386' ]]; then
  1512. chroot "$rootdir" apt-get -yq install grub2 lvm2
  1513. fi
  1514. chroot "$rootdir" apt-get -yq install locales locales-all debconf
  1515. SYSCTL_FILE="$rootdir/etc/sysctl.conf"
  1516. if [ ! -f "$SYSCTL_FILE" ]; then
  1517. touch "$SYSCTL_FILE"
  1518. fi
  1519. cp "$SYSCTL_FILE" "$rootdir/root/sysctl.conf"
  1520. chown "$CURR_USER":"$CURR_GROUP" "$rootdir/root/sysctl.conf"
  1521. if ! grep -q "tcp_challenge_ack_limit" "$rootdir/root/sysctl.conf"; then
  1522. echo 'net.ipv4.tcp_challenge_ack_limit = 999999999' >> "$rootdir/root/sysctl.conf"
  1523. else
  1524. sed -i 's|net.ipv4.tcp_challenge_ack_limit.*|net.ipv4.tcp_challenge_ack_limit = 999999999|g' "$rootdir/root/sysctl.conf"
  1525. fi
  1526. cp "$rootdir/root/sysctl.conf" "$SYSCTL_FILE"
  1527. rm "$rootdir/root/sysctl.conf"
  1528. # all the packages
  1529. chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget
  1530. chroot "$rootdir" apt-get -yq install avahi-daemon avahi-utils avahi-discover
  1531. chroot "$rootdir" apt-get -yq install connect-proxy openssh-server
  1532. chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
  1533. chroot "$rootdir" apt-get -yq install avahi-discover iptables dnsutils net-tools
  1534. chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
  1535. chroot "$rootdir" apt-get -yq install libnss-gw-name nano man ntp locales locales-all debconf
  1536. chroot "$rootdir" apt-get -yq install wireless-tools wpasupplicant usbutils cryptsetup zsh
  1537. chroot "$rootdir" apt-get -yq install pinentry-curses eatmydata iotop bc hostapd haveged
  1538. chroot "$rootdir" apt-get -yq install cpulimit screen elinks libpam-cracklib
  1539. chroot "$rootdir" apt-get -yq install vim-common python3 unattended-upgrades
  1540. # Tor and ssh over tor
  1541. chroot "$rootdir" apt-get -yq -t stretch-backports install tor
  1542. chroot "$rootdir" apt-get -yq install connect-proxy
  1543. chroot "$rootdir" connect-proxy
  1544. sed -i 's|#Log notice file.*|Log notice file /var/log/tor/notices.log|g' "$rootdir/etc/tor/torrc"
  1545. sed -i 's|Log notice file.*|Log notice file /var/log/tor/notices.log|g' "$rootdir/etc/tor/torrc"
  1546. sed -i "s|#AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
  1547. sed -i "s|AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
  1548. if ! grep -q 'Host *.onion' "$rootdir/root/.ssh/config"; then
  1549. if [ ! -d "$rootdir/root/.ssh" ]; then
  1550. mkdir "$rootdir/root/.ssh"
  1551. fi
  1552. echo 'Host *.onion' >> "$rootdir/root/.ssh/config"
  1553. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> "$rootdir/root/.ssh/config"
  1554. fi
  1555. if ! grep -q 'Host *.onion' "$rootdir/etc/skel/.ssh/config"; then
  1556. if [ ! -d "$rootdir/etc/skel/.ssh" ]; then
  1557. mkdir "$rootdir/etc/skel/.ssh"
  1558. fi
  1559. echo 'Host *.onion' >> "$rootdir/etc/skel/.ssh/config"
  1560. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> "$rootdir/etc/skel/.ssh/config"
  1561. fi
  1562. # Install golang
  1563. chroot "$rootdir" adduser --disabled-login --gecos 'go' go
  1564. GOARCH=
  1565. if [[ "$ARCHITECTURE" == *"386" || "$ARCHITECTURE" == *"686" ]]; then
  1566. GOARCH=386
  1567. fi
  1568. if [[ "$ARCHITECTURE" == *"amd64" || "$ARCHITECTURE" == "x86_64" ]]; then
  1569. GOARCH=amd64
  1570. fi
  1571. if [[ "$ARCHITECTURE" == *"arm"* ]]; then
  1572. GOARCH=armv6l
  1573. fi
  1574. if [[ "$ARCHITECTURE" == *"aarch"* || "$ARCHITECTURE" == *"arm64"* ]]; then
  1575. GOARCH=arm64
  1576. fi
  1577. if [ ! "$GOARCH" ]; then
  1578. echo $'System architecture was not specified when installing Go'
  1579. exit 6734378
  1580. fi
  1581. GO_SOURCE="https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GOARCH}.tar.gz"
  1582. if [ ! -d "${rootdir}/root/build" ]; then
  1583. mkdir -p "$rootdir/root/build"
  1584. fi
  1585. cd "$rootdir/root/build" || exit 4268746282
  1586. wget "${GO_SOURCE}"
  1587. if [ ! -f "${rootdir}/root/build/go${GO_VERSION}.linux-${GOARCH}.tar.gz" ]; then
  1588. exit 265243553
  1589. fi
  1590. chroot "$rootdir" tar -C /home/go -xzf "${INSTALL_DIR}/go${GO_VERSION}.linux-${GOARCH}.tar.gz"
  1591. if [ ! -d "${rootdir}/home/go/go/bin" ]; then
  1592. echo 'Go binary not installed'
  1593. exit 763562
  1594. fi
  1595. # shellcheck disable=SC2086
  1596. mv ${rootdir}/home/go/go ${rootdir}/home/go/go${GO_VERSION}
  1597. echo "export GOROOT=/home/go" >> "${rootdir}/root/.bashrc"
  1598. echo "export GOROOT=/home/go" >> "${rootdir}/etc/skel/.bashrc"
  1599. echo "export GOROOT=/home/go" >> "${rootdir}/home/go/.bashrc"
  1600. echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/root/.bashrc"
  1601. echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/etc/skel/.bashrc"
  1602. echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/home/go/.bashrc"
  1603. echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/root/.bashrc"
  1604. echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/etc/skel/.bashrc"
  1605. echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/home/go/.bashrc"
  1606. chroot "$rootdir" chown -R go:go /home/go
  1607. cp "${rootdir}/home/go/go${GO_VERSION}/bin/"* "${rootdir}/usr/bin"
  1608. echo "upgrade_golang:$GO_VERSION" >> "${rootdir}/root/${PROJECT_NAME}-completed.txt"
  1609. # Tomb
  1610. chroot "$rootdir" apt-get -yq install zsh pinentry-curses
  1611. git clone "$TOMB_REPO" "$rootdir/root/build/tomb"
  1612. cd "$rootdir/root/build/tomb" || exit 468368345425
  1613. git checkout "$TOMB_COMMIT" -b "$TOMB_COMMIT"
  1614. chroot "$rootdir" cd /root/build/tomb && make install
  1615. echo "tomb commit:$TOMB_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1616. if ! grep -q '\* hard maxsyslogins' "$rootdir/etc/security/limits.conf"; then
  1617. echo '* hard maxsyslogins 10' >> "$rootdir/etc/security/limits.conf"
  1618. else
  1619. sed -i 's|hard maxsyslogins.*|hard maxsyslogins 10|g' "$rootdir/etc/security/limits.conf"
  1620. fi
  1621. # Max logins for each user
  1622. if ! grep -q '\* hard maxlogins' "$rootdir/etc/security/limits.conf"; then
  1623. echo '* hard maxlogins 2' >> "$rootdir/etc/security/limits.conf"
  1624. else
  1625. sed -i 's|hard maxlogins.*|hard maxlogins 2|g' "$rootdir/etc/security/limits.conf"
  1626. fi
  1627. # Email
  1628. chroot "$rootdir" apt-get -yq remove postfix
  1629. chroot "$rootdir" apt-get -yq install exim4 exim4-daemon-heavy sasl2-bin swaks libnet-ssleay-perl procmail
  1630. chroot "$rootdir" apt-get -yq install spamassassin
  1631. chroot "$rootdir" apt-get -yq install dovecot-imapd
  1632. #backup
  1633. chroot "$rootdir" apt-get -yq install duplicity gnupg
  1634. # monkeysphere
  1635. #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl
  1636. # encrypting email
  1637. chroot "$rootdir" apt-get -yq install libmail-gnupg-perl
  1638. git clone "$GPGIT_REPO" "$rootdir/root/build/gpgit"
  1639. cd "$rootdir/root/build/gpgit" || exit 62484624682
  1640. git checkout "$GPGIT_COMMIT" -b "$GPGIT_COMMIT"
  1641. cp "$rootdir/root/build/gpgit/gpgit.pl" "$rootdir/usr/bin"
  1642. echo "gpgit commit:$GPGIT_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1643. # email client
  1644. chroot "$rootdir" apt-get -yq install lynx abook urlview mutt
  1645. git clone "$CLEANUP_MAILDIR_REPO" "$rootdir/root/build/cleanup-maildir"
  1646. cd "$rootdir/root/build/cleanup-maildir" || exit 246872646847264
  1647. git checkout "$CLEANUP_MAILDIR_COMMIT" -b "$CLEANUP_MAILDIR_COMMIT"
  1648. cp "$rootdir/root/build/cleanup-maildir/cleanup-maildir" "$rootdir/usr/bin"
  1649. echo "cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1650. # web server
  1651. chroot "$rootdir" apt-get -yq remove --purge apache2
  1652. chroot "$rootdir" apt-get -yq install nginx php-fpm
  1653. git clone "$NGINX_ENSITE_REPO" "$rootdir/root/build/nginx_ensite"
  1654. cd "$rootdir/root/build/nginx_ensite" || exit 462746826482
  1655. git checkout "$NGINX_ENSITE_COMMIT" -b "$NGINX_ENSITE_COMMIT"
  1656. echo "nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
  1657. chroot "$rootdir" cd /root/build/nginx_ensite && make install
  1658. if [ ! -f "$rootdir/etc/pam.d/nginx" ]; then
  1659. { echo '#%PAM-1.0';
  1660. echo '@include common-auth';
  1661. echo '@include common-account';
  1662. echo '@include common-session'; } > "$rootdir/etc/pam.d/nginx"
  1663. fi
  1664. chroot "$rootdir" apt-get -yq install tripwire
  1665. # filesystem optimisations
  1666. #sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
  1667. }
  1668. image_install_nodejs() {
  1669. if [[ "$VARIANT" == "mesh" ]]; then
  1670. return
  1671. fi
  1672. mesh_install_nodejs
  1673. echo 'install_nodejs' >> "${rootdir}/root/${PROJECT_NAME}-completed.txt"
  1674. }
  1675. image_preinstall_repos() {
  1676. if [[ "$VARIANT" == "mesh"* ]]; then
  1677. return
  1678. fi
  1679. if [ ! -d "$rootdir/repos" ]; then
  1680. mkdir "$rootdir/repos"
  1681. fi
  1682. git clone "$CMAKE_REPO" "$rootdir/repos/cmake"
  1683. git clone "$INADYN_REPO" "$rootdir/repos/inadyn"
  1684. git clone "$TOMB_REPO" "$rootdir/repos/tomb"
  1685. if [[ "$SOCIALINSTANCE" == "pleroma" ]]; then
  1686. git clone "$PLEROMA_REPO" "$rootdir/repos/pleroma"
  1687. return
  1688. fi
  1689. if [[ "$SOCIALINSTANCE" == "gnusocial" ]]; then
  1690. git clone "$GNUSOCIAL_REPO" "$rootdir/repos/gnusocial"
  1691. git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
  1692. git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
  1693. git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
  1694. return
  1695. fi
  1696. if [[ "$SOCIALINSTANCE" == "postactiv" ]]; then
  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. git clone "$POSTACTIV_REPO" "$rootdir/repos/postactiv"
  1701. return
  1702. fi
  1703. git clone "$CRYPTPAD_REPO" "$rootdir/repos/cryptpad"
  1704. git clone "$BLUDIT_REPO" "$rootdir/repos/bludit"
  1705. git clone "$DOKUWIKI_REPO" "$rootdir/repos/dokuwiki"
  1706. git clone "$ETHERPAD_REPO" "$rootdir/repos/etherpad"
  1707. git clone "$FRIENDICA_REPO" "$rootdir/repos/friendica"
  1708. git clone "$GNUSOCIAL_REPO" "$rootdir/repos/gnusocial"
  1709. git clone "$PLEROMA_REPO" "$rootdir/repos/pleroma"
  1710. git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
  1711. git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
  1712. git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
  1713. git clone "$POSTACTIV_REPO" "$rootdir/repos/postactiv"
  1714. git clone "$SHARINGS_REPO" "$rootdir/repos/sharings"
  1715. git clone "$HTMLY_REPO" "$rootdir/repos/htmly"
  1716. git clone "$HUBZILLA_REPO" "$rootdir/repos/hubzilla"
  1717. git clone "$HUBZILLA_ADDONS_REPO" "$rootdir/repos/hubzilla-addons"
  1718. git clone "$KOEL_REPO" "$rootdir/repos/koel"
  1719. git clone "$LYCHEE_REPO" "$rootdir/repos/lychee"
  1720. git clone "$MAILPILE_REPO" "$rootdir/repos/mailpile"
  1721. git clone "$MATRIX_REPO" "$rootdir/repos/matrix"
  1722. git clone "$MEDIAGOBLIN_REPO" "$rootdir/repos/mediagoblin"
  1723. #git clone "$MOVIM_REPO" "$rootdir/repos/movim"
  1724. git clone "$NEXTCLOUD_REPO" "$rootdir/repos/nextcloud"
  1725. git clone "$PIHOLE_REPO" "$rootdir/repos/pihole"
  1726. git clone "$PROFANITY_REPO" "$rootdir/repos/profanity"
  1727. git clone "$LIBMESODE_REPO" "$rootdir/repos/libmesode"
  1728. git clone "$PROFANITY_OMEMO_PLUGIN_REPO" "$rootdir/repos/profanity-omemo"
  1729. git clone "$RSS_READER_REPO" "$rootdir/repos/rss"
  1730. git clone "$RSS_MOBILE_READER_REPO" "$rootdir/repos/rss-mobile"
  1731. git clone "$SEARX_REPO" "$rootdir/repos/searx"
  1732. git clone "$TOXCORE_REPO" "$rootdir/repos/toxcore"
  1733. git clone "$TOXID_REPO" "$rootdir/repos/toxid"
  1734. git clone "$TOXIC_REPO" "$rootdir/repos/toxic"
  1735. git clone "$TURTL_REPO" "$rootdir/repos/turtl"
  1736. git clone "$KANBOARD_REPO" "$rootdir/repos/kanboard"
  1737. git clone "$KEYSERVER_WEB_REPO" "$rootdir/repos/keyserverweb"
  1738. git clone "$PEERTUBE_REPO" "$rootdir/repos/peertube"
  1739. git clone "$PRIVATEBIN_REPO" "$rootdir/repos/privatebin"
  1740. git clone "$EDITH_REPO" "$rootdir/repos/edith"
  1741. git clone "$BDSMAIL_REPO" "$rootdir/repos/bdsmail"
  1742. #git clone "$WEKAN_REPO" "$rootdir/repos/wekan"
  1743. #git clone "$FLOW_ROUTER_REPO" "$rootdir/repos/flowrouter"
  1744. #git clone "$ZERONET_REPO" "$rootdir/repos/zeronet"
  1745. #git clone "$QTOX_REPO" "$rootdir/repos/qtox"
  1746. }
  1747. ##############################################################################
  1748. # Set to true/false to control if eatmydata is used during build
  1749. use_eatmydata=true
  1750. rootdir="$1"
  1751. fmdir="$(pwd)"
  1752. image="$fmdir"/"$2"
  1753. cd "$rootdir"
  1754. echo info: building "$MACHINE" for "$ARCHITECTURE"
  1755. export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
  1756. export LC_ALL=C LANGUAGE=C LANG=C
  1757. # Override libpam-tmpdir setting during build, as the directories
  1758. # are not created yet.
  1759. export TMP=/tmp/ TMPDIR=/tmp/
  1760. if [ ! "$MY_USERNAME" ]; then
  1761. echo $'No username was specified'
  1762. exit 52825
  1763. fi
  1764. username="$MY_USERNAME"
  1765. echo $"warning: creating initial user $username with well known password!"
  1766. password="$MY_PASSWORD"
  1767. chroot "$rootdir" /usr/bin/env -i \
  1768. HOME=/root \
  1769. PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
  1770. echo "export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:" >> "$rootdir/root/.bashrc"
  1771. chroot "$rootdir" adduser --gecos "$username" --disabled-password "$username"
  1772. echo "$username:$password" | chroot "$rootdir" /usr/sbin/chpasswd
  1773. chroot "$rootdir" adduser "$username" sudo
  1774. if [ ! "$DEBIAN_REPO" ]; then
  1775. DEBIAN_REPO='ftp.de.debian.org'
  1776. fi
  1777. if [ ! "$DEBIAN_VERSION" ]; then
  1778. DEBIAN_VERSION='stretch'
  1779. fi
  1780. set_apt_sources "$BUILD_MIRROR"
  1781. chroot "$rootdir" apt-get clean
  1782. chroot "$rootdir" /bin/rm -rf /var/lib/apt/lists/*
  1783. chroot "$rootdir" apt-get clean
  1784. set_apt_sources "$MIRROR"
  1785. configure_backports
  1786. configure_contrib_repo
  1787. chroot "$rootdir" apt-get update
  1788. chroot "$rootdir" apt-get install -y apt-utils
  1789. cat > "$rootdir/usr/sbin/policy-rc.d" <<EOF
  1790. #!/bin/sh
  1791. exit 101
  1792. EOF
  1793. chmod a+rx "$rootdir/usr/sbin/policy-rc.d"
  1794. if "$use_eatmydata" ; then
  1795. enable_eatmydata_override
  1796. fi
  1797. if [ -n "$CUSTOM_SETUP" ]; then
  1798. cp "$CUSTOM_SETUP" "$rootdir"/tmp
  1799. chroot "$rootdir" apt-get install -y gdebi-core
  1800. chroot "$rootdir" gdebi -n "/tmp/$(basename "$CUSTOM_SETUP")"
  1801. fi
  1802. if [[ "$VARIANT" != "mesh"* ]]; then
  1803. chroot "$rootdir" apt-get install -y openssh-server
  1804. fi
  1805. chroot "$rootdir" apt-get install -y sudo git dialog build-essential
  1806. chroot "$rootdir" apt-get install -y avahi-daemon avahi-utils avahi-discover
  1807. chroot "$rootdir" apt-get install -y iptables dnsutils net-tools network-manager iputils-ping
  1808. chroot "$rootdir" apt-get install -y libnss-mdns libnss-myhostname libnss-gw-name nano man ntp
  1809. chroot "$rootdir" apt-get install -y locales locales-all debconf wireless-tools wpasupplicant usbutils
  1810. if [[ "$ARCHITECTURE" == 'qemu'* || "$ARCHITECTURE" == 'i386' || "$ARCHITECTURE" == 'i686' || "$ARCHITECTURE" == 'amd64' || "$ARCHITECTURE" == 'x86_64' ]]; then
  1811. chroot "$rootdir" apt-get install -y cryptsetup zsh pinentry-curses iotop bc
  1812. chroot "$rootdir" apt-get install -y grub2 hostapd lvm2
  1813. fi
  1814. sed -i "s|#host-name=.*|host-name=${LOCAL_NAME}|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1815. sed -i "s|host-name=.*|host-name=${LOCAL_NAME}|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1816. sed -i 's|#domain-name=.*|domain-name=local|g' "$rootdir/etc/avahi/avahi-daemon.conf"
  1817. sed -i 's|domain-name=.*|domain-name=local|g' "$rootdir/etc/avahi/avahi-daemon.conf"
  1818. sed -i "s|use-ipv4=.*|use-ipv4=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1819. sed -i "s|use-ipv6=.*|use-ipv6=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1820. sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1821. sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" "$rootdir/etc/nsswitch.conf"
  1822. sed -i "s|#publish-domain=.*|publish-domain=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1823. sed -i "s|publish-domain=.*|publish-domain=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1824. sed -i "s|#publish-addresses=.*|publish-addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1825. sed -i "s|publish-addresses=.*|publish-addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
  1826. # Add an ssh avahi service
  1827. { echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->';
  1828. echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">';
  1829. echo '<service-group>';
  1830. echo ' <name replace-wildcards="yes">%h SSH</name>';
  1831. echo ' <service>';
  1832. echo ' <type>_ssh._tcp</type>';
  1833. echo " <port>$SSH_PORT</port>";
  1834. echo ' </service>';
  1835. echo '</service-group>'; } > "$rootdir/etc/avahi/services/ssh.service"
  1836. # Ensure that the avahi daemon keeps running
  1837. WATCHDOG_SCRIPT_NAME="keepon"
  1838. { echo '#!/bin/bash';
  1839. echo 'LOGFILE=/var/log/keepon.log';
  1840. echo "CURRENT_DATE=\$(date)";
  1841. echo '';
  1842. echo "# keep avahi-daemon daemon running";
  1843. echo "RUNNING=$(pgrep avahi-daemon > /dev/null && echo Running)";
  1844. echo "if [ ! \$RUNNING ]; then";
  1845. echo " systemctl start avahi-daemon";
  1846. echo " echo -n \$CURRENT_DATE >> \$LOGFILE";
  1847. echo " echo \"avahi-daemon daemon restarted\" >> \$LOGFILE";
  1848. echo 'fi';
  1849. echo "# End of avahi-daemon"; } > "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
  1850. chmod +x "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
  1851. echo "*/1 * * * * root /usr/bin/$WATCHDOG_SCRIPT_NAME" >> "$rootdir/etc/crontab"
  1852. chroot "$rootdir" /bin/bash -x <<EOF
  1853. git clone $PROJECT_REPO /root/$PROJECT_NAME
  1854. cd /root/$PROJECT_NAME
  1855. git checkout stretch
  1856. make install
  1857. cp image_build/bbb-4.9.0.tar.gz /boot/bbb.tar.gz
  1858. EOF
  1859. chroot "$rootdir" "${PROJECT_NAME}-image-hardware-setup" 2>&1 | \
  1860. tee "$rootdir/var/log/${PROJECT_NAME}-image-hardware-setup.log"
  1861. rm "$rootdir/usr/sbin/policy-rc.d"
  1862. # Set up HRNG for systems known to have one
  1863. # Otherwise install haveged
  1864. if [[ "$MACHINE" != "beaglebone"* ]]; then
  1865. # With some VMs, the hardware cycles counter is emulated and deterministic,
  1866. # and thus predictible, so havege should not be used
  1867. if [[ "$MACHINE" != "qemu"* ]]; then
  1868. chroot "$rootdir" apt-get -yq install haveged
  1869. fi
  1870. else
  1871. chroot "$rootdir" apt-get -yq install rng-tools
  1872. sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' "$rootdir/etc/default/rng-tools"
  1873. fi
  1874. # copy u-boot to beginning of image
  1875. case "$MACHINE" in
  1876. beaglebone)
  1877. dd if="$rootdir/usr/lib/u-boot/am335x_boneblack/MLO" of="$image" \
  1878. count=1 seek=1 conv=notrunc bs=128k
  1879. dd if="$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img" of="$image" \
  1880. count=2 seek=1 conv=notrunc bs=384k
  1881. ;;
  1882. cubieboard2)
  1883. dd if="$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin" of="$image" \
  1884. seek=8 conv=notrunc bs=1k
  1885. ;;
  1886. a20-olinuxino-lime)
  1887. dd if="$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin" \
  1888. of="$image" seek=8 conv=notrunc bs=1k
  1889. ;;
  1890. esac
  1891. if "$use_eatmydata" ; then
  1892. disable_eatmydata_override
  1893. fi
  1894. configure_ssh
  1895. configure_networking
  1896. admin_user_sudo
  1897. create_generic_image
  1898. atheros_wifi
  1899. continue_installation
  1900. image_install_nodejs
  1901. initialise_mesh
  1902. configure_wifi
  1903. configure_user_interface
  1904. image_setup_utils
  1905. image_install_inadyn
  1906. image_install_pleroma
  1907. image_preinstall_repos
  1908. # remove downloaded packages
  1909. chroot "$rootdir" apt-get -y autoremove
  1910. chroot "$rootdir" apt-get clean
  1911. cd /
  1912. echo $"info: killing leftover processes in chroot"
  1913. fuser -mvk "$rootdir/." || true
  1914. exit 0