| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201 | 
							- #!/bin/bash
 - #  _____               _           _
 - # |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
 - # |   __|  _| -_| -_| . | . |     | . | . |   | -_|
 - # |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
 - #
 - #                              Freedom in the Cloud
 - #
 - # Based on bin/freedombox-customize from freedom-maker
 - #
 - # License
 - # =======
 - #
 - # Copyright (C) 2015-2018 Bob Mottram <bob@freedombone.net>
 - #
 - # This program is free software: you can redistribute it and/or modify
 - # it under the terms of the GNU Affero General Public License as published by
 - # the Free Software Foundation, either version 3 of the License, or
 - # (at your option) any later version.
 - #
 - # This program is distributed in the hope that it will be useful,
 - # but WITHOUT ANY WARRANTY; without even the implied warranty of
 - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 - # GNU Affero General Public License for more details.
 - #
 - # You should have received a copy of the GNU Affero General Public License
 - # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 - 
 - set -e
 - set -x
 - 
 - PROJECT_NAME='freedombone'
 - LOCAL_NAME=${PROJECT_NAME}
 - INSTALL_DIR=/root/build
 - COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
 - 
 - PROJECT_REPO="https://code.freedombone.net/bashrc/${PROJECT_NAME}"
 - 
 - VARIANT='full'
 - 
 - # username created by default within a debian image
 - GENERIC_IMAGE_USERNAME='fbone'
 - 
 - export TEXTDOMAIN=${PROJECT_NAME}-image-customise
 - export TEXTDOMAINDIR="/usr/share/locale"
 - 
 - # Whether to minimise the number of decisions during interactive install
 - MINIMAL_INSTALL="yes"
 - 
 - MY_USERNAME='debian'
 - MY_PASSWORD="${PROJECT_NAME}"
 - 
 - # Minimum number of characters in a password
 - MINIMUM_PASSWORD_LENGTH=10
 - 
 - # IP address of the router (gateway)
 - ROUTER_IP_ADDRESS="192.168.1.254"
 - 
 - # The fixed IP address of the Beaglebone Black on your local network
 - BOX_IP_ADDRESS="192.168.1.55"
 - 
 - # DNS
 - NAMESERVER1='91.239.100.100'
 - NAMESERVER2='89.233.43.71'
 - NAMESERVER3='87.118.100.175'
 - NAMESERVER4='94.75.228.29'
 - NAMESERVER5='85.25.251.254'
 - NAMESERVER6='2.141.58.13'
 - 
 - # optional configuration file containing freedombone settings
 - CONFIG_FILENAME=
 - 
 - # Optional ssh public key to allow
 - SSH_PUBKEY="no"
 - 
 - # Whether this is a generic image for mass redistribution on the interwebs
 - GENERIC_IMAGE="no"
 - 
 - # default SSH port
 - SSH_PORT=2222
 - 
 - # for mesh installs
 - TRACKER_PORT=6969
 - 
 - # Whether sites are accessible only within a Tor browser
 - ONION_ONLY="no"
 - 
 - # Whether to only install debian and nothing else
 - DEBIAN_INSTALL_ONLY="no"
 - 
 - # wifi settings
 - WIFI_INTERFACE='wlan0'
 - WIFI_SSID=
 - WIFI_TYPE='wpa2-psk'
 - WIFI_PASSPHRASE=
 - WIFI_HOTSPOT='no'
 - WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
 - 
 - # Whether to install non-free wifi drivers for the mesh client
 - INSECURE='no'
 - 
 - # optional desktop background image for mesh
 - MESH_DESKTOP_BACKGROUND_IMAGE=/usr/local/share/${PROJECT_NAME}_mesh_initial_background.png
 - 
 - # The browser application to use
 - BROWSER=firefox
 - BROWSER_OPTIONS='-url'
 - 
 - MESH_INSTALL_DIR=/var/lib
 - 
 - # for mesh installs whether to delete all data and generate
 - # a new identity at every shutdown/boot
 - AMNESIC='no'
 - 
 - # Whether this is a dedicated gnusocial or postactiv instance
 - SOCIALINSTANCE=
 - 
 - # defines the initial keyboard layout
 - KEYBOARD_MAP='gb'
 - 
 - # Strings used for setting the username
 - MESH_TITLE=$"Freedombone Mesh"
 - 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."
 - 
 - # Whether to enable zeronet on the mesh
 - ENABLE_ZERONET=
 - 
 - MESH_TEXT_EDITOR='pluma'
 - 
 - BABEL_REPO="https://github.com/jech/babeld"
 - BABEL_COMMIT='d9390d1fee337c464e67255bbbd879d975e126e2'
 - 
 - OLSR2_REPO="https://github.com/OLSR/OONF"
 - OLSR2_COMMIT='81033251c4ee1c5699bfee9d2985112c6266ab0a'
 - 
 - BMX6_REPO="https://github.com/bmx-routing/bmx6"
 - BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181'
 - 
 - BMX7_REPO="https://github.com/bmx-routing/bmx7"
 - BMX7_COMMIT='66c853f529662873d1420d39461c75be6eb88b45'
 - 
 - CONTINUOUS_INTEGRATION=
 - 
 - PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
 - 
 - # Whether to use a SATA drive and if so what its device/partition name is
 - # eg. sda2
 - EXTERNAL_DRIVE=
 - 
 - configure_backports() {
 -     echo "deb http://${DEBIAN_REPO}/debian/ ${DEBIAN_VERSION}-backports main" >> "$rootdir/etc/apt/sources.list"
 - }
 - 
 - configure_contrib_repo() {
 -     if ! grep -q "contrib" "$rootdir/etc/apt/sources.list"; then
 -         chroot "$rootdir" /bin/sed -i "s| main| main contrib|g" /etc/apt/sources.list
 -     fi
 - }
 - 
 - enable_eatmydata_override() {
 -     chroot "$rootdir" apt-get install -y eatmydata
 -     if [ -x "$rootdir/usr/bin/eatmydata" ] && \
 -            [ ! -f "$rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata" ]; then
 -         echo $"info: Adding apt config to call dpkg via eatmydata"
 -         printf "#!/bin/sh\\nexec eatmydata dpkg \"\$@\"\\n" \
 -                > "$rootdir/var/tmp/dpkg-eatmydata"
 -         chmod 755 "$rootdir/var/tmp/dpkg-eatmydata"
 -         cat > "$rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata" <<EOF
 - Dir::Bin::dpkg "/var/tmp/dpkg-eatmydata";
 - EOF
 -     else
 -         echo $"error: unable to find /usr/bin/eatmydata after installing the eatmydata package"
 -     fi
 - }
 - 
 - disable_eatmydata_override() {
 -     for override in \
 -         /etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata \
 -             /var/tmp/dpkg-eatmydata ; do
 -         echo $"info: Removing apt config to call dpkg via eatmydata"
 -         if [ -f "$rootdir$override" ] ; then
 -             rm -f "$rootdir$override"
 -         else
 -             echo $"warning: missing $rootdir$override"
 -         fi
 -     done
 -     sync # Flush file buffers before continuing
 - }
 - 
 - set_apt_sources() {
 -     NEW_MIRROR="$1"
 -     COMPONENTS="main"
 - 
 -     cat <<EOF > etc/apt/sources.list
 - deb $NEW_MIRROR $SUITE $COMPONENTS
 - deb-src $NEW_MIRROR $SUITE $COMPONENTS
 - 
 - #deb http://security.debian.org/ $SUITE/updates main
 - #deb-src http://security.debian.org/ $SUITE/updates main
 - EOF
 - }
 - 
 - configure_networking() {
 -     chroot "$rootdir" apt-get -yq install resolvconf
 - 
 -     if [[ "$DEBIAN_INSTALL_ONLY" != "no" ]]; then
 -         return
 -     fi
 - 
 -     { echo '# This file describes the network interfaces available on your system';
 -       echo '# and how to activate them. For more information, see interfaces(5).';
 -       echo 'source /etc/network/interfaces.d/*'; } > "$rootdir/etc/network/interfaces"
 - 
 -     if [[ "$GENERIC_IMAGE" == "no" ]]; then
 - 
 -         { echo 'auto eth0';
 -           echo 'iface eth0 inet static';
 -           echo "address $BOX_IP_ADDRESS";
 -           echo 'netmask 255.255.255.0';
 -           echo "gateway $ROUTER_IP_ADDRESS"; } > "$rootdir/etc/network/interfaces.d/static"
 - 
 -         hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
 -         a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 -         b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 -         c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 -         d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 -         e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 -         echo "hwaddress ether de:$a:$b:$c:$d:$e" > "$rootdir/etc/network/interfaces.d/macaddress"
 -     else
 -         { echo 'auto eth0';
 -           echo 'iface eth0 inet dhcp'; } > "$rootdir/etc/network/interfaces.d/dynamic"
 -     fi
 - 
 -     # configure DNS
 -     resolvconf=$rootdir/etc/resolvconf/resolv.conf.d/head
 -     { echo 'domain localdomain';
 -       echo 'search localdomain';
 -       echo "nameserver $NAMESERVER1";
 -       echo "nameserver $NAMESERVER2";
 -       echo "nameserver $NAMESERVER3";
 -       echo "nameserver $NAMESERVER4";
 -       echo "nameserver $NAMESERVER5";
 -       echo "nameserver $NAMESERVER6"; } > "$resolvconf"
 -     chroot "$rootdir" resolvconf -u
 - 
 -     if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" ]]; then
 -         # change the motd to show further install instructions
 -         echo $"
 -        _____               _           _
 -       |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
 -       |   __|  _| -_| -_| . | . |     | . | . |   | -_|
 -       |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
 - 
 -                                    Initial base install
 - 
 - Your system is not yet installed. To complete the process run the
 - following commands, then enter your details.
 - 
 -     sudo su
 -     ${PROJECT_NAME} menuconfig
 - 
 - " > "$rootdir/etc/motd"
 -     else
 -         echo $"
 -        _____               _           _
 -       |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
 -       |   __|  _| -_| -_| . | . |     | . | . |   | -_|
 -       |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
 - 
 -                                     Freedom in the Mesh
 - " > "$rootdir/etc/motd"
 -     fi
 - }
 - 
 - configure_ssh() {
 -     if [[ $VARIANT == "mesh"* ]]; then
 -         return
 -     fi
 - 
 -     sed -i "s/Port .*/Port ${SSH_PORT}/g" "$rootdir/etc/ssh/sshd_config"
 -     sed -i "s/#Port ${SSH_PORT}/Port ${SSH_PORT}/g" "$rootdir/etc/ssh/sshd_config"
 - 
 -     if [[ "$SSH_PUBKEY" != "no" ]]; then
 -         if [ ! -d "$rootdir/home/$MY_USERNAME/.ssh" ]; then
 -             mkdir "$rootdir/home/$MY_USERNAME/.ssh"
 -         fi
 -         echo "$SSH_PUBKEY" > "$rootdir/home/$MY_USERNAME/.ssh/authorized_keys"
 -         chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.ssh"
 -         sed -i 's|PasswordAuthentication.*|PasswordAuthentication no|g' "$rootdir/etc/ssh/sshd_config"
 -         sed -i 's|#PasswordAuthentication no|PasswordAuthentication no|g' "$rootdir/etc/ssh/sshd_config"
 -         echo $"Using ssh public key:"
 -         echo $SSH_PUBKEY
 -         echo $'Password ssh authentication turned off'
 -     fi
 - }
 - 
 - create_generic_image() {
 -     if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
 -         return
 -     fi
 -     if [[ $GENERIC_IMAGE == "no" ]]; then
 -         return
 -     fi
 -     if [ $CONFIG_FILENAME ]; then
 -         if [[ "$CONFIG_FILENAME" == *"mesh.cfg"* ]]; then
 -             VARIANT="mesh"
 -         fi
 -     fi
 - 
 -     # Don't install any configuration. This will be a base system
 -     if [[ $VARIANT != "mesh"* ]]; then
 -         CONFIG_FILENAME=
 -     else
 -         touch "$rootdir/root/.initial_mesh_setup"
 -     fi
 - 
 -     # Stick with the existing login for mesh clients
 -     if [[ $VARIANT == "meshclient" || $VARIANT == "meshusb" ]]; then
 -         return
 -     fi
 - 
 -     # The presence of this file indicates that the initial
 -     # setup has not yet been completed
 -     touch "$rootdir/home/$MY_USERNAME/.initial_setup"
 -     chroot "$rootdir" /bin/chown "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.initial_setup"
 -     touch "$rootdir/root/.initial_setup"
 - 
 -     cat >> "$rootdir/home/$MY_USERNAME/.bashrc" <<EOF
 - # initial setup of the system
 - if [ -f ~/.initial_setup ]; then
 -     clear
 -     echo "
 -  .---.                  .              .
 -  |                      |              |
 -  |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
 -  |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
 -  '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
 - 
 -                     Initial setup process
 - 
 -           Please enter your password a second time.
 - "
 -     sudo su
 - fi
 - EOF
 - 
 -     { echo "MY_USERNAME=${MY_USERNAME}";
 -       echo '# initial setup of the system';
 -       echo 'if [ -f ~/.initial_setup ]; then';
 -       echo '    if [ -f ~/login.txt ]; then';
 -       echo "        NEW_USER_PASSWORD=\$(printf \"%s\" \"\$(cat ~/login.txt)\")";
 -       echo '    else';
 -       echo "        ENTROPY=\$(cat /proc/sys/kernel/random/entropy_avail)";
 -       echo "        if [ \$ENTROPY -lt 500 ]; then"; } >> "$rootdir/root/.bashrc"
 -     ENTROPY_MESSAGE1=$'Initial setup process'
 -     ENTROPY_MESSAGE2=$'Password Generation'
 -     ENTROPY_MESSAGE3=$'WARNING: The entropy available on this system is too low to generate a password.\n\nThe installation process cannot continue.'
 -     { echo "            dialog --backtitle \"${ENTROPY_MESSAGE1}\" --title \"${ENTROPY_MESSAGE2}\" --msgbox \"${ENTROPY_MESSAGE3}\" 8 50";
 -       echo '            exit';
 -       echo '        fi';
 -       echo -n "        NEW_USER_PASSWORD=\$(openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c ";
 -       echo "${DEFAULT_PASSWORD_LENGTH})";
 -       echo '    fi';
 -       echo "    echo \"\${NEW_USER_PASSWORD}\" > ~/login.txt";
 - 
 -       echo '    clear';
 -       echo '    echo ""'; } >> "$rootdir/root/.bashrc"
 -     NEW_LOGIN_PASSWORD_MESSAGE1=$'Your new login password is:'
 -     NEW_LOGIN_PASSWORD_MESSAGE2=$'Use it whenever you wish to ssh into this system.'
 -     NEW_LOGIN_PASSWORD_MESSAGE3=$'IMPORTANT: Please take a moment to enter the above password into a\npassword manager or write it down somewhere.'
 -     PRESS_KEY_MESSAGE=$'Press any key to continue...'
 -     { echo "    echo \"${NEW_LOGIN_PASSWORD_MESSAGE1}\"";
 -       echo '    echo ""';
 -       echo "    echo \"                          \${NEW_USER_PASSWORD}\"";
 -       echo '    echo ""';
 -       echo "    echo \"${NEW_LOGIN_PASSWORD_MESSAGE2}\"";
 -       echo '    echo ""';
 -       echo "    echo \"${NEW_LOGIN_PASSWORD_MESSAGE3}\"";
 -       echo '    echo ""';
 -       echo "    read -n1 -r -p \"${PRESS_KEY_MESSAGE}\" key";
 - 
 -       # change the password for the admin user
 -       echo -n "    echo \"${MY_USERNAME}:";
 -       echo "\$(printf \"%s\" \"\$(cat ~/login.txt)\")\"|chpasswd";
 - 
 -       # update before continuing
 -       echo "    cd /root/${PROJECT_NAME}";
 -       echo "    git stash";
 -       echo "    git pull";
 -       echo "    git checkout stretch";
 -       echo "    make install"; } >> "$rootdir/root/.bashrc"
 - 
 -     if [[ "$VARIANT" != "mesh"* && "$VARIANT" != "usb" ]]; then
 -         if [[ "$SOCIALINSTANCE" == "gnusocial" ]]; then
 -             echo "    ${PROJECT_NAME} menuconfig-gnusocial" >> "$rootdir/root/.bashrc"
 -         else
 -             if [[ "$SOCIALINSTANCE" == "postactiv" ]]; then
 -                 echo "    ${PROJECT_NAME} menuconfig-postactiv" >> "$rootdir/root/.bashrc"
 -             else
 -                 if [[ "$SOCIALINSTANCE" == "pleroma" ]]; then
 -                     echo "    ${PROJECT_NAME} menuconfig-pleroma" >> "$rootdir/root/.bashrc"
 -                 else
 -                     if [[ "$ONION_ONLY" == "no" ]]; then
 -                         if [[ "$MINIMAL_INSTALL" == "no" ]]; then
 -                             echo "    ${PROJECT_NAME} menuconfig-full" >> "$rootdir/root/.bashrc"
 -                         else
 -                             echo "    ${PROJECT_NAME} menuconfig" >> "$rootdir/root/.bashrc"
 -                         fi
 -                     else
 -                         echo "    ${PROJECT_NAME} menuconfig-onion" >> "$rootdir/root/.bashrc"
 -                     fi
 -                 fi
 -             fi
 -         fi
 -     else
 -         echo "    echo ''" >> "$rootdir/root/.bashrc"
 -     fi
 -     { echo '    if [ "$?" = "0" ]; then';
 -       echo "        if [ -f ~/${PROJECT_NAME}-completed.txt ]; then";
 -       echo "            # Check that the initial setup really did complete";
 -       echo "            if grep -q 'tripwire' ~/${PROJECT_NAME}-completed.txt; then";
 -       # Remove the initial setup files
 -       echo '                rm /root/.initial_setup';
 -       echo '                rm /home/fbone/.initial_setup';
 -       echo "                touch /root/.remove_${GENERIC_IMAGE_USERNAME}";
 -       echo '                rm ~/login.txt'; } >> "$rootdir/root/.bashrc"
 -     if [[ "$VARIANT" != "mesh"* && "$VARIANT" != "usb" ]]; then
 -         { echo "                SSH_ONION_HOSTNAME=\$(cat /var/lib/tor/hidden_service_ssh/hostname)";
 - 
 -           echo "                if [ \${#SSH_ONION_HOSTNAME} -lt 2 ]; then";
 -           echo '                    exit 62392';
 -           echo '                fi'; } >> "$rootdir/root/.bashrc"
 -     fi
 -     { echo "                if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then";
 -       echo "                    echo '[Unit]' > /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'Description=WifiStartup (Start wifi networking)' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'After=syslog.target' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'After=network.target' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'After=remote-fs.target' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo '' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo '[Service]' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'Type=simple' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'User=root' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'Group=root' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'WorkingDirectory=/root' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'ExecStart=/usr/local/bin/${PROJECT_NAME}-wifi --wait 5 2> /dev/null' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo '' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo '[Install]' >> /etc/systemd/system/wifistart.service";
 -       echo "                    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/wifistart.service";
 -       echo "                    systemctl enable wifistart";
 -       echo "                    systemctl daemon-reload";
 -       echo '                fi';
 -       echo '                systemctl reboot -i';
 -       echo '            fi';
 -       echo '        fi';
 -       echo '    else';
 -       echo '        key=';
 -       echo "        while [[ \$key != \"x\" ]]; do"; } >> "$rootdir/root/.bashrc"
 -     INSTALL_FAIL_MESSAGE=$"Install failed. Press x to continue..."
 -     { echo "            read -n1 -r -p \"${INSTALL_FAIL_MESSAGE}\" key";
 -       echo '        done';
 -       echo '    fi';
 -       echo '    exit';
 -       echo 'else';
 -       echo '    # Remove default account after install';
 -       echo "    if [ -f /root/.remove_${GENERIC_IMAGE_USERNAME} ]; then";
 -       echo "        if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then";
 -       echo "           userdel -r ${GENERIC_IMAGE_USERNAME}";
 -       echo "           if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then";
 -       echo "               rm -rf /home/${GENERIC_IMAGE_USERNAME}";
 -       echo "               rm /root/.remove_${GENERIC_IMAGE_USERNAME}";
 -       echo '           fi';
 -       echo '        fi';
 -       echo '    fi';
 -       echo 'fi'; } >> "$rootdir/root/.bashrc"
 - }
 - 
 - continue_installation() {
 -     # If a configuration file exists then run with it
 -     # otherwise the interactive installer can be used
 -     # This is equivalent to installing freedombox-setup on freedombox
 -     if [ $CONFIG_FILENAME ]; then
 -         if [ ${#CONFIG_FILENAME} -gt 2 ]; then
 -             cp "$CONFIG_FILENAME" "$rootdir/root/$PROJECT_NAME.cfg"
 -             cat "$rootdir/root/$PROJECT_NAME.cfg"
 -             chroot "$rootdir" su -c "$PROJECT_NAME -c /root/$PROJECT_NAME.cfg" - root
 -         fi
 -     fi
 - }
 - 
 - atheros_wifi() {
 -     chroot "$rootdir" dpkg -i /root/${PROJECT_NAME}/drivers/firmware-ath9k-htc.deb
 -     chroot "$rootdir" apt-get -yq install firmware-linux-free
 - }
 - 
 - configure_wifi() {
 -     if [[ $VARIANT == "mesh"* ]]; then
 -         return
 -     fi
 - 
 -     wifi_setup_service=setupwififirstboot
 -     wifi_setup_file=$rootdir/root/setup_wifi_firstboot
 -     echo '#!/bin/bash' > "$wifi_setup_file"
 - 
 -     if [ -f $WIFI_NETWORKS_FILE ]; then
 -         echo "${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE" >> "$wifi_setup_file"
 -     else
 -         if [[ $WIFI_TYPE != 'none' ]]; then
 -             if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
 -                 return
 -             fi
 -             echo "${PROJECT_NAME}-wifi -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $WIFI_HOTSPOT" >> "$wifi_setup_file"
 -         else
 -             echo "${PROJECT_NAME}-wifi -s $WIFI_SSID -t $WIFI_TYPE --hotspot $WIFI_HOTSPOT" >> "$wifi_setup_file"
 -         fi
 -     fi
 - 
 -     { echo "systemctl stop ${wifi_setup_service}";
 -       echo "systemctl disable ${wifi_setup_service}";
 -       echo "rm /etc/systemd/system/${wifi_setup_service}.service";
 -       echo 'systemctl reboot -i'; } >> "$wifi_setup_file"
 -     chmod +x "$wifi_setup_file"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=Initial wifi configuration';
 -       echo 'After=syslog.target';
 -       echo 'After=network.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'Type=simple';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'WorkingDirectory=/root';
 -       echo "ExecStart=/root/setup_wifi_firstboot > /var/log/wifi_setup.log";
 -       echo '';
 -       echo 'TimeoutSec=99999';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } >> "$rootdir/etc/systemd/system/${wifi_setup_service}.service"
 -     chmod +x "$rootdir/etc/systemd/system/${wifi_setup_service}.service"
 -     chroot "$rootdir" systemctl enable ${wifi_setup_service}
 - }
 - 
 - ##############################################################################
 - # Mesh networking
 - ##############################################################################
 - 
 - # for mesh installs
 - TRACKER_PORT=6969
 - 
 - WIFI_CHANNEL=2
 - 
 - # B.A.T.M.A.N settings
 - BATMAN_CELLID='02:BA:00:00:03:01'
 - WIFI_SSID='mesh'
 - 
 - # To avoid confusions these are obtained from the main project file
 - #TOXID_REPO=
 - #TOX_PORT=
 - #TOXCORE_REPO=
 - #TOXIC_REPO=
 - #TOXCORE_COMMIT=
 - #TOXIC_COMMIT=
 - # These are some default nodes, but you can replace them with trusted nodes
 - # as you prefer. See https://wiki.tox.im/Nodes
 - #TOX_NODES=
 - #TOX_NODES=(
 - #  '192.254.75.102,2607:5600:284::2,33445,951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F,Tox RELENG,US'
 - #  '144.76.60.215,2a01:4f8:191:64d6::1,33445,04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F,sonOfRa,DE'
 - #)
 - 
 - # To avoid confusions these are obtained from the main project file
 - ZERONET_REPO=
 - ZERONET_COMMIT=
 - ZERONET_PORT=
 - ZERONET_BLOG_REPO=
 - ZERONET_BLOG_COMMIT=
 - ZERONET_MAIL_REPO=
 - ZERONET_MAIL_COMMIT=
 - ZERONET_FORUM_REPO=
 - ZERONET_FORUM_COMMIT=
 - ZERONET_ID_REPO=
 - ZERONET_ID_COMMIT=
 - 
 - # Directory where source code is downloaded and compiled
 - INSTALL_DIR=$HOME/build
 - 
 - INSTALLING_MESH=
 - 
 - PATCHWORK_REPO="https://github.com/ssbc/patchwork"
 - PATCHWORK_COMMIT='60111a9e3385d65be0d17aa0d15fd20e5fb311ce'
 - 
 - FERMENT_REPO="https://github.com/LolaShare/ferment"
 - FERMENT_COMMIT='6e0e434114cd4cc652a03f6dcc6ddcec007b0058'
 - 
 - install_patchwork() {
 -     if [[ $VARIANT != "meshclient" ]]; then
 -         return
 -     fi
 - 
 -     get_npm_arch
 -     mesh_setup_npm
 - 
 -     git clone "$PATCHWORK_REPO" "$rootdir/etc/patchwork"
 -     if [ ! -d "$rootdir/etc/patchwork" ]; then
 -         exit 7823520
 -     fi
 -     cd "$rootdir/etc/patchwork" || exit 68724685427
 -     git checkout "$PATCHWORK_COMMIT" -b "$PATCHWORK_COMMIT"
 - 
 -     cat <<EOF > "$rootdir/usr/bin/install_patchwork"
 - #!/bin/bash
 - cd /etc/patchwork
 - npm install --arch=$NPM_ARCH --build-from-source
 - npm install --arch=$NPM_ARCH --save-dev electron-rebuild
 - ./node_modules/.bin/electron-rebuild
 - npm install --arch=$NPM_ARCH git-ssb
 - EOF
 -     chroot "$rootdir" /bin/chmod +x /usr/bin/install_patchwork
 -     chroot "$rootdir" /usr/bin/install_patchwork
 -     rm "$rootdir/usr/bin/install_patchwork"
 - 
 -     { echo '#!/bin/bash';
 -       echo 'cd /etc/patchwork';
 -       echo 'npm start'; } > "$rootdir/usr/bin/start_patchwork"
 -     chmod +x "$rootdir/usr/bin/start_patchwork"
 - 
 -     # Copy icon to an accesible location
 -     cp "$rootdir/root/$PROJECT_NAME/img/icon_patchwork.png" "$rootdir/etc/patchwork/icon_patchwork.png"
 - }
 - 
 - install_ferment() {
 -     if [[ "$VARIANT" != "meshclient" ]]; then
 -         return
 -     fi
 - 
 -     get_npm_arch
 - 
 -     git clone "$FERMENT_REPO" "$rootdir/etc/ferment"
 -     if [ ! -d "$rootdir/etc/ferment" ]; then
 -         exit 5239465
 -     fi
 -     cd "$rootdir/etc/ferment" || exit 2482684
 -     git checkout "$FERMENT_COMMIT" -b "$FERMENT_COMMIT"
 - 
 -     cat <<EOF > "$rootdir/usr/bin/install_ferment"
 - #!/bin/bash
 - cd /etc/ferment
 - npm install --arch=$NPM_ARCH --build-from-source
 - npm install --arch=$NPM_ARCH --save-dev electron-rebuild
 - ./node_modules/.bin/electron-rebuild
 - npm install --arch=$NPM_ARCH git-ssb
 - EOF
 -     chroot "$rootdir" /bin/chmod +x /usr/bin/install_ferment
 -     chroot "$rootdir" /usr/bin/install_ferment
 -     rm "$rootdir/usr/bin/install_ferment"
 - 
 -     { echo '#!/bin/bash';
 -       echo 'cd /etc/ferment';
 -       echo 'npm start'; } > "$rootdir/usr/bin/start_ferment"
 -     chmod +x "$rootdir/usr/bin/start_ferment"
 - 
 -     # Copy icon to an accesible location
 -     cp "$rootdir/root/$PROJECT_NAME/img/icon_ferment.png" "$rootdir/etc/patchwork/icon_ferment.png"
 - }
 - 
 - mesh_shutdown_script() {
 -     mesh_shutdown_script="$rootdir/usr/bin/meshshutdown"
 -     { echo '#!/bin/bash';
 -       echo 'batman stop'; } > "$mesh_shutdown_script"
 -     chroot "$rootdir" chmod +x /usr/bin/meshshutdown
 - 
 -     { echo '[Unit]';
 -       echo 'Description=Shuts down the mesh';
 -       echo 'Before=shutdown.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'ExecStart=/bin/true';
 -       echo 'ExecStop=/bin/bash /usr/bin/meshshutdown';
 -       echo 'RemainAfterExit=yes';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/meshshutdown.service"
 -     chroot "$rootdir" systemctl enable meshshutdown
 - }
 - 
 - install_babel() {
 -     git clone "$BABEL_REPO" "$rootdir/etc/babel"
 - 
 -     cat <<EOF > "$rootdir/usr/bin/install_babel"
 - #!/bin/bash
 - cd /etc/babel
 - git checkout $BABEL_COMMIT -b $BABEL_COMMIT
 - cd /etc/babel
 - make
 - make install
 - EOF
 -     chroot "$rootdir" chmod +x /usr/bin/install_babel
 -     chroot "$rootdir" /usr/bin/install_babel
 - 
 -     if [ ! -f "$rootdir/usr/local/bin/babeld" ]; then
 -         echo $'Unable to build Babel'
 -         exit 52382524
 -     fi
 - 
 -     rm "$rootdir/usr/bin/install_babel"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=Babel mesh routing protocol';
 -       echo 'Requires=network.target';
 -       echo 'After=network.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'ExecStart=/usr/local/bin/babeld wlan0';
 -       echo 'Restart=on-failure';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/babel.service"
 - }
 - 
 - install_olsr2() {
 -     chroot "$rootdir" apt-get -yq install cmake libnl-3-dev
 - 
 -     git clone "$OLSR2_REPO" "$rootdir/etc/olsr2"
 - 
 -     cat <<EOF > "$rootdir/usr/bin/install_olsr2"
 - #!/bin/bash
 - cd /etc/olsr2
 - git checkout $OLSR2_COMMIT -b $OLSR2_COMMIT
 - cd /etc/olsr2/build
 - cmake ..
 - make
 - make install
 - EOF
 -     chroot "$rootdir" chmod +x /usr/bin/install_olsr2
 -     chroot "$rootdir" /usr/bin/install_olsr2
 - 
 -     if [ ! -f "$rootdir/usr/local/sbin/olsrd2_static" ]; then
 -         echo $'Unable to build OLSR2'
 -         exit 79835392
 -     fi
 - 
 -     rm "$rootdir/usr/bin/install_olsr2"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=OLSR2 mesh routing protocol';
 -       echo 'Requires=network.target';
 -       echo 'After=network.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'ExecStart=/usr/local/sbin/olsrd2_static wlan0';
 -       echo 'Restart=on-failure';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/olsr2.service"
 - }
 - 
 - install_bmx6() {
 -     git clone "$BMX6_REPO" "$rootdir/etc/bmx6"
 - 
 -     cat <<EOF > "$rootdir/usr/bin/install_bmx6"
 - #!/bin/bash
 - cd /etc/bmx6
 - git checkout $BMX6_COMMIT -b $BMX6_COMMIT
 - make
 - make install
 - 
 - cd /etc/bmx6/lib/bmx6_http_info
 - make
 - make install
 - 
 - cd /etc/bmx6/lib/bmx6_json
 - make
 - make install
 - 
 - cd /etc/bmx6/lib/bmx6_quagga
 - make
 - make install
 - 
 - cd /etc/bmx6/lib/bmx6_sms
 - make
 - make install
 - 
 - cd /etc/bmx6/lib/bmx6_table
 - make
 - make install
 - 
 - cd /etc/bmx6/lib/bmx6_topology
 - make
 - make install
 - EOF
 -     chroot "$rootdir" chmod +x /usr/bin/install_bmx6
 -     chroot "$rootdir" /usr/bin/install_bmx6
 - 
 -     if [ ! -f "$rootdir/usr/sbin/bmx6" ]; then
 -         echo $'bmx6 was not installed'
 -         exit 79835292
 -     fi
 - 
 -     rm "$rootdir/usr/bin/install_bmx6"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=BMX6 mesh routing protocol';
 -       echo 'Requires=network.target';
 -       echo 'After=network.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'Type=forking';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'ExecStart=/usr/sbin/bmx6 dev=wlan0';
 -       echo "ExecStop=/usr/bin/kill -15 \$MAINPID";
 -       echo 'PIDFile=/var/run/bmx6/pid';
 -       echo 'Restart=on-failure';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/bmx6.service"
 - }
 - 
 - install_bmx7() {
 -     chroot "$rootdir" apt-get -qy install libjson-c-dev zlib1g-dev libiw-dev wget
 - 
 -     git clone "$BMX7_REPO" "$rootdir/etc/bmx7"
 - 
 -     cat <<EOF > "$rootdir/usr/bin/install_bmx7"
 - #!/bin/bash
 - cd /etc
 - wget https://polarssl.org/code/releases/polarssl-1.3.3-gpl.tgz
 - tar xzvf polarssl-1.3.3-gpl.tgz
 - cd /etc/polarssl-1.3.3
 - make
 - sudo make install
 - 
 - cd /etc/bmx7
 - git checkout $BMX7_COMMIT -b $BMX7_COMMIT
 - make EXTRA_CFLAGS="-DCRYPTLIB=POLARSSL_1_3_3"
 - make install
 - 
 - cd /etc/bmx7/lib/bmx7_http_info
 - make
 - make install
 - 
 - cd /etc/bmx7/lib/bmx7_json
 - make
 - make install
 - 
 - cd /etc/bmx7/lib/bmx7_tun
 - make
 - make install
 - 
 - cd /etc/bmx7/lib/bmx7_sms
 - make
 - make install
 - 
 - cd /etc/bmx7/lib/bmx7_topology
 - make
 - make install
 - EOF
 -     chroot "$rootdir" chmod +x /usr/bin/install_bmx7
 -     chroot "$rootdir" /usr/bin/install_bmx7
 - 
 -     if [ ! -f "$rootdir/usr/sbin/bmx7" ]; then
 -         echo $'bmx7 was not installed'
 -         exit 67836235
 -     fi
 - 
 -     rm "$rootdir/usr/bin/install_bmx7"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=BMX7 mesh routing protocol';
 -       echo 'Requires=network.target';
 -       echo 'After=network.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'Type=forking';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'ExecStart=/usr/sbin/bmx7 dev=wlan0';
 -       echo "ExecStop=/usr/bin/kill -15 \$MAINPID";
 -       echo 'PIDFile=/var/run/bmx7/pid';
 -       echo 'Restart=on-failure';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/bmx7.service"
 - }
 - 
 - initialise_mesh() {
 -     if [[ "$VARIANT" != "mesh"* ]]; then
 -         return
 -     fi
 -     if [[ "$DEBIAN_INSTALL_ONLY" != "no" ]]; then
 -         return
 -     fi
 - 
 -     if [[ "$INSECURE" == $'yes' ]]; then
 -         echo  '*********************************************************'
 -         echo $'WARNING: non-free wifi drivers are being installed.'
 -         echo $'         This may compromise the security of your system.'
 -         echo  '*********************************************************'
 - 
 -         # enable non-free repo
 -         if ! grep -q "non-free" "$rootdir/etc/apt/sources.list"; then
 -             chroot "$rootdir" /bin/sed -i "s| main| main non-free|g" /etc/apt/sources.list
 -         fi
 - 
 -         chroot "$rootdir" apt-get update
 - 
 -         # install proprietary wifi drivers
 -         # see https://wiki.debian.org/iwlwifi
 -         chroot "$rootdir" apt-get -yq install firmware-iwlwifi firmware-b43-installer firmware-brcm80211 firmware-realtek
 -     fi
 - 
 -     INSTALLING_MESH=1
 - 
 -     chroot "$rootdir" apt-get -yq install apt-transport-https
 - 
 -     # install tor as a possible way of routing traffic between internet gateways
 -     chroot "$rootdir" apt-get -yq -t stretch-backports install tor
 - 
 -     # dhcp daemon for hotspot on secondary wifi adapter
 -     chroot "$rootdir" apt-get -yq install dnsmasq
 - 
 -     # for debugging
 -     chroot "$rootdir" apt-get -yq install traceroute
 - 
 -     # set the default protocol to be used
 -     echo 'bmx6' > "$rootdir$MESH_DEFAULT_PROTOCOL"
 - 
 -     sed -i 's|#net.ipv6.conf.all.forwarding.*|net.ipv6.conf.all.forwarding=1|g' "$rootdir/etc/sysctl.conf"
 -     sed -i 's|net.ipv6.conf.all.forwarding.*|net.ipv6.conf.all.forwarding=1|g' "$rootdir/etc/sysctl.conf"
 - 
 -     sed -i 's|#net.ipv6.conf.all.accept_redirects.*|net.ipv6.conf.all.accept_redirects=1|g' "$rootdir/etc/sysctl.conf"
 -     sed -i 's|net.ipv6.conf.all.accept_redirects.*|net.ipv6.conf.all.accept_redirects=1|g' "$rootdir/etc/sysctl.conf"
 - 
 -     sed -i 's|#net.ipv6.conf.all.accept_source_route.*|net.ipv6.conf.all.accept_source_route=1|g' "$rootdir/etc/sysctl.conf"
 -     sed -i 's|net.ipv6.conf.all.accept_source_route.*|net.ipv6.conf.all.accept_source_route=1|g' "$rootdir/etc/sysctl.conf"
 - 
 -     configure_firewall
 -     install_avahi
 -     install_batman
 -     install_bmx6
 -     install_bmx7
 -     install_olsr2
 -     install_babel
 -     mesh_shutdown_script
 -     install_vpn
 -     install_tomb
 -     #install_tahoelafs
 -     #install_librevault
 -     install_patchwork
 -     install_web_server
 -     mesh_install_scuttlebot
 -     #install_ferment
 - 
 -     chroot "$rootdir" apt-get clean
 -     chroot "$rootdir" /bin/rm -rf /var/lib/apt/lists/*
 -     chroot "$rootdir" apt-get clean
 - 
 -     install_ipfs
 -     install_tox
 -     install_pelican
 -     mesh_install_cryptpad
 -     #mesh_install_peertube
 -     if [ "$ENABLE_ZERONET" ]; then
 -         install_zeronet
 -     fi
 - 
 -     # ssh server not available on mesh peers
 -     if [ -f "$rootdir/etc/avahi/services/ssh.service" ]; then
 -         rm "$rootdir/etc/avahi/services/ssh.service"
 -     fi
 - 
 -     MESH_SERVICE='mesh-setup.service'
 -     MESH_SETUP_DAEMON="$rootdir/etc/systemd/system/$MESH_SERVICE"
 - 
 -     MESH_STARTUP_PARAMS="${MY_USERNAME}"
 -     if [[ "$AMNESIC" != 'no' ]]; then
 -         MESH_STARTUP_PARAMS="${MY_USERNAME} amnesic"
 -     fi
 - 
 -     # command to switch to wired mesh
 -     { echo '#!/bin/bash';
 -       echo 'echo -n "eth" > /root/.mesh_interface_type';
 -       echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wired"
 -     chmod +x "$rootdir/usr/bin/wired"
 - 
 -     # command to switch to wireless mesh
 -     { echo '#!/bin/bash';
 -       echo 'echo -n "wlan" > /root/.mesh_interface_type';
 -       echo 'systemctl reboot -i'; } > "$rootdir/usr/bin/wireless"
 -     chmod +x "$rootdir/usr/bin/wireless"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=Initial mesh router configuration';
 -       echo 'After=syslog.target';
 -       echo 'After=network.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'Type=simple';
 -       echo 'User=root';
 -       echo 'Group=root';
 -       echo 'WorkingDirectory=/root';
 -       echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh ${MESH_STARTUP_PARAMS} > /var/log/mesh-setup.log";
 -       echo '';
 -       echo 'TimeoutSec=99999';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$MESH_SETUP_DAEMON"
 -     chmod +x "$MESH_SETUP_DAEMON"
 -     chroot "$rootdir" systemctl enable "$MESH_SERVICE"
 - }
 - 
 - # User interface for USB drive installs ######################################
 - 
 - mesh_client_startup_applications() {
 -     if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
 -         mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
 -     fi
 - 
 -     if [ ! -d "$rootdir/home/$MY_USERNAME/.config/autostart" ]; then
 -         mkdir -p "$rootdir/home/$MY_USERNAME/.config/autostart"
 -         chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.config"
 -     fi
 - 
 -     START_DESKTOP="$rootdir/home/$MY_USERNAME/mesh-desktop.sh"
 -     FIRST_BOOT="/home/$MY_USERNAME/.first_boot"
 -     TAHOE_COMMAND="cd /var/lib/tahoelafs && venv/bin/tahoe"
 - 
 -     { echo '#!/bin/bash';
 -       echo "setxkbmap ${KEYBOARD_MAP}";
 -       echo 'dconf write /org/mate/caja/desktop/volumes-visible false';
 -       echo 'dconf write /org/mate/caja/desktop/computer-icon-visible false';
 -       echo 'dconf write /org/mate/caja/desktop/home-icon-visible false';
 -       echo 'dconf write /org/mate/caja/desktop/network-icon-visible false';
 -       echo 'dconf write /org/mate/caja/desktop/trash-icon-visible false';
 -       echo 'dconf write /org/mate/caja/desktop/volumes-visible false';
 -       echo 'dconf write /org/mate/desktop/media-handling/automount-open false';
 -       echo 'dconf write /org/mate/screensaver/lock-enabled false';
 -       echo 'dconf write /org/mate/power-manager/lock-keyring-suspend false';
 -       echo 'dconf write /org/mate/power-manager/lock-suspend false';
 -       echo 'dconf write /org/mate/power-manager/lock-use-screensaver false';
 -       echo 'dconf write /org/mate/power-manager/lock-blank-screen false';
 -       echo 'dconf write /org/mate/power-manager/lock-hibernate false';
 -       echo 'dconf write /org/mate/power-manager/lock-keyring-hibernate false';
 -       echo 'dconf write /org/mate/desktop/peripherals/touchpad/scroll-method 2';
 -       echo '#dconf write /org/mate/desktop.a11y.applications/screen-reader-enabled true';
 -       echo '#dconf write /org/mate/interface/accessibility true';
 -       echo '#dconf write /org/mate/applications-at-visual/startup true';
 -       echo "touch /home/$MY_USERNAME/.dbus/Xdbus";
 -       echo "chmod 600 /home/$MY_USERNAME/.dbus/Xdbus";
 -       echo "env | grep DBUS_SESSION_BUS_ADDRESS > /home/$MY_USERNAME/.dbus/Xdbus";
 -       echo "echo 'export DBUS_SESSION_BUS_ADDRESS' >> /home/$MY_USERNAME/.dbus/Xdbus";
 -       echo '';
 -       echo "amixer set 'Master' unmute";
 -       echo "amixer set 'Master' 50%";
 -       echo '';
 -       echo '';
 -       echo "if [ ! -f $FIRST_BOOT ]; then";
 -       echo '  if [ -d /var/lib/tahoelafs ]; then';
 -       echo "    $TAHOE_COMMAND start";
 -       echo '  fi';
 -       echo '  exit 0';
 -       echo 'fi';
 -       echo '';
 -       echo 'INITIAL_TOX_USERNAME=""';
 -       echo "while [ \${#INITIAL_TOX_USERNAME} -eq 0 ]; do";
 -       echo "  data=\$(zenity --entry --title=\"$MESH_TITLE\" --text=\"$MESH_SET_USERNAME\")";
 -       echo '  accepted=$?';
 -       echo '  if ((accepted == 0)); then';
 -       echo "      INITIAL_TOX_USERNAME=\$(awk -F, '{print \$1}' <<<\$data)";
 -       echo '  fi';
 -       echo 'done';
 -       echo '';
 -       echo "toxid --setuser \"\$INITIAL_TOX_USERNAME\"";
 -       echo '';
 -       echo "if [ -f /home/$MY_USERNAME/.tahoe/tahoe.cfg ]; then";
 -       echo "    sed -i 's|nickname =.*|nickname = \$INITIAL_TOX_USERNAME|g' /home/$MY_USERNAME/.tahoe/tahoe.cfg";
 - 
 -       echo "    $TAHOE_COMMAND restart";
 -       echo 'fi';
 -       echo '';
 -       echo "rm -f $FIRST_BOOT";
 -       echo '';
 -       echo 'exit 0'; } > "$START_DESKTOP"
 -     chmod +x "$START_DESKTOP"
 - 
 -     START_DESKTOP2="$rootdir/home/$MY_USERNAME/.config/autostart/mesh-start.desktop"
 -     { echo '[Desktop Entry]';
 -       echo 'Type=Application';
 -       echo 'Name=Mesh start desktop script';
 -       echo "Exec=bash -c '~/mesh-desktop.sh'";
 -       echo 'X-GNOME-Autostart-enabled=true'; } > "$START_DESKTOP2"
 -     chmod +x "$START_DESKTOP2"
 - }
 - 
 - mesh_desktop_icons() {
 -     if [ ! -d "$rootdir/home/$MY_USERNAME/Desktop" ]; then
 -         mkdir -p "$rootdir/home/$MY_USERNAME/Desktop"
 -     fi
 - 
 -     # Terminal
 -     #echo '[Desktop Entry]' > $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'Name=MATE Terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'Type=Application' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'Comment=Use the command line' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'TryExec=mate-terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'Exec=mate-terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'Icon=terminal' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 -     #echo 'StartupNotify=true' >> $rootdir/home/$MY_USERNAME/Desktop/terminal.desktop
 - 
 -     chroot "$rootdir" /bin/chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Desktop"
 - }
 - 
 - configure_user_interface() {
 -     if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
 -         return
 -     fi
 - 
 -     # desktop
 -     chroot "$rootdir" apt-get -yq install mate-desktop-environment
 - 
 -     # tool to change desktop settings from command line
 -     chroot "$rootdir" apt-get -yq install dconf-cli dconf-gsettings-backend dbus dbus-x11
 - 
 -     # for tomb
 -     chroot "$rootdir" apt-get -yq install pinentry-gtk2
 - 
 -     # for tox video
 -     chroot "$rootdir" apt-get -yq install ffmpeg cheese v4l-utils
 - 
 -     # to provide notifications
 -     chroot "$rootdir" apt-get -yq install libnotify-bin
 - 
 -     # for video/audio
 -     chroot "$rootdir" apt-get -yq install libtheora-bin libvorbis-dev v4l-utils
 - 
 -     # a sane editor
 -     chroot "$rootdir" apt-get -yq install emacs
 - 
 -     # for wifi monitoring
 -     chroot "$rootdir" apt-get -yq install horst
 - 
 -     # for sound level control
 -     chroot "$rootdir" apt-get -yq install alsa-utils pavucontrol
 - 
 -     # to play various media types
 -     chroot "$rootdir" apt-get -yq install vlc
 - 
 -     # android adb to allow phones to be connected and for example transfer photos/documents
 -     chroot "$rootdir" apt-get -yq install android-tools-adb
 - 
 -     # USB cloning tool
 -     chroot "$rootdir" apt-get -yq install gnome-multi-writer
 - 
 -     # clipboard
 -     chroot "$rootdir" apt-get -yq install xclip
 - 
 -     # multimedia recording and editing
 -     chroot "$rootdir" apt-get -yq install audacity
 -     chroot "$rootdir" apt-get -yq install shotwell
 -     chroot "$rootdir" apt-get -yq install kdenlive breeze-icon-theme
 - 
 -     # for gtk dialog entry
 -     chroot "$rootdir" apt-get -yq install zenity
 - 
 -     # accessibility
 -     #chroot "$rootdir" apt-get -yq -t stretch-backports install gnome-orca
 -     #chroot "$rootdir" apt-get -yq install festival
 - 
 -     # Produce a text file on the desktop listing users on the mesh
 -     cat <<EOF > "$rootdir/usr/bin/list-tox-users"
 - #!/bin/bash
 - StrMeshUsers=\$"Mesh Users"
 - StrUsername=\$'Username'
 - StrToxID=\$'Tox ID'
 - ethernet_connected=\$(cat /sys/class/net/eth0/carrier)
 - users_list=\$(lstox | awk -F ' ' '{\$1=""; print \$0}' | sed -e 's/^[[:space:]]*//' | sort -d | uniq)
 - if [ \${#users_list} -eq 0 ]; then
 -     no_of_users=0
 - else
 -     no_of_users=\$(echo "\$users_list" | wc -l)
 - fi
 - if [ \$no_of_users -gt 0 ]; then
 -     echo "\$users_list" > /tmp/Users.txt
 -     chown $MY_USERNAME:$MY_USERNAME /tmp/Users.txt
 - 
 -     if [ ! -f /home/$MY_USERNAME/showusers ]; then
 -         echo '#!/bin/bash' > /home/$MY_USERNAME/showusers
 -         echo 'data=\$(' >> /home/$MY_USERNAME/showusers
 -         echo 'cat /tmp/Users.txt | \\' >> /home/$MY_USERNAME/showusers
 -         echo "    awk -F ' ' '{" >> /home/$MY_USERNAME/showusers
 -         echo '        for(i=1;i<=NF;i++){' >> /home/$MY_USERNAME/showusers
 -         echo '            print \$i;' >> /home/$MY_USERNAME/showusers
 -         echo '        }' >> /home/$MY_USERNAME/showusers
 -         echo "}' | \\\\" >> /home/$MY_USERNAME/showusers
 -         echo '    zenity --list \\' >> /home/$MY_USERNAME/showusers
 -         echo "     --title='\$StrMeshUsers' \\\\" >> /home/$MY_USERNAME/showusers
 -         echo "     --column='\$StrUsername' --column='\$StrToxID' \\\\" >> /home/$MY_USERNAME/showusers
 -         echo '     --print-column=2 --hide-column=2 --width=250 --height=400)' >> /home/$MY_USERNAME/showusers
 -         echo 'if [ ! \$data ]; then' >> /home/$MY_USERNAME/showusers
 -         echo '    exit 0' >> /home/$MY_USERNAME/showusers
 -         echo 'fi' >> /home/$MY_USERNAME/showusers
 -         echo 'echo "\$data" | xclip -selection clipboard' >> /home/$MY_USERNAME/showusers
 -         chmod +x /home/$MY_USERNAME/showusers
 -     fi
 - 
 -     echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/Users.desktop
 -     if [ \$no_of_users -lt 2 ]; then
 -         echo "Name=\$no_of_users Other User" >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     else
 -         echo "Name=\$no_of_users Other Users" >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     fi
 -     echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment=List of users' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[el]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[ar]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo "Comment[ca]=Llista d'usuaris" >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[hi]=  ' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[fr]=Liste des utilisateurs' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[de]=Liste der Benutzer' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[es]=Lista de usuarios' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[it]=Elenco degli utenti' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[ru]= ' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Exec=bash /home/$MY_USERNAME/showusers' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_users.png' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/Users.desktop
 -     chmod +x /home/$MY_USERNAME/Desktop/Users.desktop
 -     chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/Users.desktop
 - 
 -     if [ ! -f /home/$MY_USERNAME/.cryptpad.desktop ]; then
 -         if [ ! -f /home/$MY_USERNAME/Desktop/cryptpad.desktop ]; then
 -             echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Name=CryptPad' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment=Realtime collaborative editing of documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[el]=     ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[ar]=     ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[ca]=Edici collaborativa en temps real de documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[hi]=    ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[fr]=Edition collaborative en temps rel de documents' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[de]=Kollaboratives Echtzeit-Editing von Dokumenten' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[es]=Edicin colaborativa en tiempo real de documentos' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[it]=Editing collaborativo di documenti in tempo reale' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[ru]=      ' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo "Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local" >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_cryptpad.png" >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             chmod +x /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -         else
 -             if ! grep -q "\${HOSTNAME}.local" /home/$MY_USERNAME/Desktop/cryptpad.desktop; then
 -                 sed -i "s|Exec=.*|Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local|g" /home/$MY_USERNAME/Desktop/cryptpad.desktop
 -             fi
 -         fi
 -     fi
 - 
 -     if [ -d /etc/peertube ]; then
 -         if [ ! -f /home/$MY_USERNAME/.peertube.desktop ]; then
 -             if [ ! -f /home/$MY_USERNAME/Desktop/peertube.desktop ]; then
 -                 echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Name=PeerTube' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment=Upload and view videos on the mesh' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[el]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[ar]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[ca]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[hi]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[fr]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[de]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[es]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[it]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[ru]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo "Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local:$MESH_PEERTUBE_PORT" >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_peertube.png" >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 chmod +x /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/peertube.desktop
 -             else
 -                 if ! grep -q "\${HOSTNAME}.local" /home/$MY_USERNAME/Desktop/peertube.desktop; then
 -                     sed -i "s|Exec=.*|Exec=$BROWSER $BROWSER_OPTIONS http://\${HOSTNAME}.local:$MESH_PEERTUBE_PORT|g" /home/$MY_USERNAME/Desktop/peertube.desktop
 -                 fi
 -             fi
 -         fi
 -     fi
 - 
 -     if [ ! -f /home/$MY_USERNAME/Desktop/social.desktop ]; then
 -         echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[el]=' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[ar]=' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[ca]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[hi]=' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[fr]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[de]=Soziale' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[es]=Social' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[it]=Sociale' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[ru]=' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment=A decentralized messaging and sharing app built on top of Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[el]=              Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[ar]=         ()" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[ca]=Una aplicaci de missatgeria i distribuci descentralitzada integrada a Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[hi]=  ()          " >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[fr]=Une application de messagerie et de partage dcentralise base sur Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[de]=Eine dezentralisierte Messaging- und Sharing-App, die auf Secure Scuttlebutt basiert" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[es]=Una aplicacin de mensajera y uso compartido descentralizada construida sobre Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[it]=Un'applicazione decentralizzata di messaggistica e condivisione costruita sulla base di Secure Shuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[ru]=       ,    Secure Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Comment[zh]=Scuttlebutt" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Exec=bash /usr/bin/start_patchwork' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_social.png" >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/social.desktop
 -         chmod +x /home/$MY_USERNAME/Desktop/social.desktop
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/social.desktop
 -     fi
 - 
 -     #if [ ! -f /home/$MY_USERNAME/Desktop/audio.desktop ]; then
 -     #    echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo 'Name=Audio/Music' >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo 'Comment=Audio publishing and streaming' >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo 'Exec=bash /usr/bin/start_ferment' >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo "Icon=/etc/patchwork/icon_ferment.png" >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    chmod +x /home/$MY_USERNAME/Desktop/audio.desktop
 -     #    chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/audio.desktop
 -     #fi
 - 
 -     if [ ! -f /home/$MY_USERNAME/Desktop/vpn.desktop ]; then
 -         echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name=Connect Meshes' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[el]=  ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[ca]=Connecteu malles' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[fr]=Connecter les maillages' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[de]=Netze verbinden' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[es]=Conectar Mallas' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[it]=Collegare le maglie' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment=Connect to another mesh network via the internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[el]=       ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[ar]=     ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo "Comment[ca]=Connecteu-vos a una altra xarxa de malla a travs d'Internet" >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[hi]=          ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[fr]=Connectez-vous  un autre rseau maill via Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[de]=Verbindung mit einem anderen Mesh-Netzwerk ber das Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[es]=Conctese a otra red en malla a travs de Internet' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo "Comment[it]=Collegarsi ad un'altra rete di maglie via internet" >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[ru]=       ' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-connect' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_connect.png' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/vpn.desktop
 -         chmod +x /home/$MY_USERNAME/Desktop/vpn.desktop
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/vpn.desktop
 -     fi
 - 
 -     if [ ! -f /home/$MY_USERNAME/Desktop/routing.desktop ]; then
 -         echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name=Routing Protocol' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo "Name[ca]=Protocol d'enrutament" >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[fr]=Protocole de routage' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[de]=Routingprotokoll' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[es]=Protocolo de enrutamiento' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[it]=Protocollo di routing' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment=Select the mesh routing protocol' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[el]=    ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[ar]=   ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo "Comment[ca]=Seleccioneu el protocol d'enrutament de malles" >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[hi]=     ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[fr]=Slectionnez le protocole de routage de maillage' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[de]=Whlen Sie das Mesh-Routing-Protokoll' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[es]=Seleccione el protocolo de enrutamiento de malla' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo "Comment[it]=Seleziona il protocollo di instradamento della mesh" >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[ru]=   ' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo "Exec=mate-terminal -e \"/usr/local/bin/${PROJECT_NAME}-mesh-routing\"" >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_routing.png' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         echo 'Categories=Application' >> /home/$MY_USERNAME/Desktop/routing.desktop
 -         chmod +x /home/$MY_USERNAME/Desktop/routing.desktop
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/routing.desktop
 -     fi
 - 
 -     if [ -f /tmp/.ipfs-users ]; then
 -         echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name=Visit a site" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[el]=  " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[ar]=  " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[ca]=Visiteu un lloc" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[hi]=   " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[fr]=Visitez un site" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[de]=Besuchen Sie eine Website" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[es]=Visita un sitio" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[it]=Visita un sito" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[ru]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Name[zh]=" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo 'Comment=Visit a site' >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[el]=  " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[ar]=  " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Commant[ca]=Visiteu un lloc" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[hi]=   " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[fr]=Visitez un site" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[de]=Besuchen Sie eine Website" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[es]=Visita un sitio" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[it]=Visita un sito" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[ru]= " >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo "Comment[zh]=" >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-visit-site' >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_sites.png' >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/sites.desktop
 -         chmod +x /home/$MY_USERNAME/Desktop/sites.desktop
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/sites.desktop
 - 
 -         echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[el]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[ar]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[ca]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[hi]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[fr]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[de]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[es]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[it]=Blog" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[ru]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo "Name[zh]=" >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment=View or create blog entries' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[el]=    ' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[ar]=    ' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[ca]=Permet visualitzar o crear entrades de bloc' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[hi]=    ' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[fr]=Afficher ou crer des entres de blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[de]=Blog-Eintrge anzeigen oder erstellen' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[es]=Ver o crear entradas de blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[it]=Visualizza o crea voci di blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[ru]=     ' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Exec=/usr/local/bin/${PROJECT_NAME}-mesh-blog' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_blog.png' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         echo 'StartupNotify=false' >> /home/$MY_USERNAME/Desktop/blog.desktop
 -         chmod +x /home/$MY_USERNAME/Desktop/blog.desktop
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/blog.desktop
 -     fi
 - 
 -     if [ ! -f /home/$MY_USERNAME/runtox ]; then
 -         echo 'qtox_running=\$(ps aux | grep qtox | grep data)' > /home/$MY_USERNAME/runtox
 -         echo 'if [ \${#qtox_running} -eq 0 ]; then' >> /home/$MY_USERNAME/runtox
 -         echo '    bash -c "qtox -p data"' >> /home/$MY_USERNAME/runtox
 -         echo 'fi' >> /home/$MY_USERNAME/runtox
 -         echo 'exit 0' >> /home/$MY_USERNAME/runtox
 -         chmod +x /home/$MY_USERNAME/runtox
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/runtox
 -     fi
 - 
 -     if [ ! -f /home/$MY_USERNAME/Desktop/tox.desktop ]; then
 -         echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name=Chat' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[el]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[ar]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[ca]=Xat' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[hi]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[fr]=Bavarder' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[de]=Chat' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[es]=Charla' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[it]=Chiacchierare' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[ru]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment=Chat, Voice and Video' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[el]=,   ' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[ar]=  ' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[ca]=Xat, veu i vdeo' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[hi]=,   ' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[fr]=Chat, voix et vido' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[de]=Chat, Sprache und Video' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[es]=Chat, voz y video' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[it]=Chat, voce e video' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[ru]=,   ' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'Exec=bash /home/$MY_USERNAME/runtox' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo "Icon=/usr/share/$PROJECT_NAME/avatars/icon_chat.png" >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         echo 'StartupNotify=true' >> /home/$MY_USERNAME/Desktop/tox.desktop
 -         chmod +x /home/$MY_USERNAME/Desktop/tox.desktop
 -         chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Desktop/tox.desktop
 -     fi
 - 
 -     # If ethernet is connected then add the invite icon to help enable
 -     # SSB nat traversal
 -     if [[ "\$ethernet_connected" != "0" ]]; then
 -         if [ ! -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
 -             echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Version=1.0' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name=Create Invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[el]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[ar]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[ca]=Crea una invitaci' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[hi]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[fr]=Crer une invitation' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[de]=Einladung erstellen' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[es]=Crear invitacin' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[it]=Crea Invita' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[ru]= ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Name[zh]=' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Type=Application' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment=Create an invite for Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[el]=     Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[ar]=   ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[ca]=Crea una invitaci per Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[hi]=     ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[fr]=Crer une invitation pour Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[de]=Erstellen Sie eine Einladung fr Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[es]=Crear una invitacin para Patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[it]=Crea un invito per patchwork' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[ru]=    ' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Comment[zh]=' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Exec=mate-terminal -e ${PROJECT_NAME}-mesh-invite' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Icon=/usr/share/$PROJECT_NAME/avatars/icon_invite.png' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Terminal=false' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             echo 'Categories=Application;' >> /home/$MY_USERNAME/Desktop/invite.desktop
 -             chmod +x /home/$MY_USERNAME/Desktop/invite.desktop
 -         fi
 -     else
 -         if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
 -             rm /home/$MY_USERNAME/Desktop/invite.desktop
 -         fi
 -     fi
 - else
 -     if [ -f /tmp/Users.txt ]; then
 -         rm /tmp/Users.txt
 -         rm /home/$MY_USERNAME/Desktop/Users.desktop
 -         if [ -f /home/$MY_USERNAME/Desktop/Users.desktop ]; then
 -             rm /home/$MY_USERNAME/Desktop/Users.desktop
 -         fi
 -         if [ -f /home/$MY_USERNAME/Desktop/sites.desktop ]; then
 -             rm /home/$MY_USERNAME/Desktop/sites.desktop
 -         fi
 -         if [ -f /home/$MY_USERNAME/Desktop/blog.desktop ]; then
 -             rm /home/$MY_USERNAME/Desktop/blog.desktop
 -         fi
 -         if [ -f /home/$MY_USERNAME/Desktop/tox.desktop ]; then
 -             rm /home/$MY_USERNAME/Desktop/tox.desktop
 -         fi
 -         pkill qtox
 -     fi
 - 
 -     # If there is no ethernet then remove the invite icon
 -     if [[ "\$ethernet_connected" == "0" ]]; then
 -         if [ -f /home/$MY_USERNAME/Desktop/invite.desktop ]; then
 -             rm /home/$MY_USERNAME/Desktop/invite.desktop
 -         fi
 -     fi
 - fi
 - EOF
 -     chroot "$rootdir" /bin/chown "$MY_USERNAME":"$MY_USERNAME" /usr/bin/list-tox-users
 -     chroot "$rootdir" /bin/chmod +x /usr/bin/list-tox-users
 -     echo "* *       * * *   $MY_USERNAME    bash -c /usr/bin/list-tox-users > /dev/null" >> "$rootdir/etc/crontab"
 - 
 -     if [[ "$VARIANT" != "usb" ]]; then
 -         # log in automatically
 -         chroot "$rootdir" apt-get -y install nodm xinit
 -         echo 'NODM_ENABLED=true' > /etc/default/nodm
 -         echo "NODM_USER=$MY_USERNAME" >> /etc/default/nodm
 - 
 -         chroot "$rootdir" mkdir /etc/systemd/system/getty@tty1.service.d
 -         { echo '[Service]';
 -           echo 'ExecStart=';
 -           echo "ExecStart=-/sbin/agetty --autologin fbone --noclear %I \$TERM"; } > "$rootdir/etc/systemd/system/getty@tty1.service.d/override.conf"
 - 
 -         echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx" >> "$rootdir/home/$MY_USERNAME/.profile"
 - 
 -         chroot "$rootdir" systemctl set-default multi-user.target
 - 
 -         mesh_client_startup_applications
 -         mesh_desktop_icons
 - 
 -         # Different desktop background for amnesic
 -         if [[ "$AMNESIC" != 'no' ]]; then
 -             MESH_DESKTOP_BACKGROUND_IMAGE="/usr/local/share/${PROJECT_NAME}_mesh_amnesic_background.png"
 -         fi
 - 
 -         # change the desktop background
 -         if [ "$MESH_DESKTOP_BACKGROUND_IMAGE" ]; then
 -             if [ -f "$MESH_DESKTOP_BACKGROUND_IMAGE" ]; then
 -                 if [ -d "$rootdir/usr/share/images/desktop-base" ]; then
 -                     cp "$MESH_DESKTOP_BACKGROUND_IMAGE" "$rootdir/usr/share/images/desktop-base/${PROJECT_NAME}_mesh_background.png"
 -                     chroot "$rootdir" /bin/rm /usr/share/images/desktop-base/desktop-background
 -                     chroot "$rootdir" ln -s "/usr/share/images/desktop-base/${PROJECT_NAME}_mesh_background.png" /usr/share/images/desktop-base/desktop-background
 -                 fi
 -             fi
 -         fi
 -     else
 -         chroot "$rootdir" apt-get -yq install lightdm
 -     fi
 - 
 -     # browser
 -     chroot "$rootdir" apt-get -yq install firefox-esr
 - 
 -     # help
 -     mkdir -p "$rootdir/home/${MY_USERNAME}/help/images"
 -     cd "$rootdir/root/${PROJECT_NAME}/website" || exit 2346872684
 -     ./deploy.sh EN "$rootdir/home/${MY_USERNAME}/help"
 -     chroot "$rootdir" /bin/chown -R "${MY_USERNAME}":"${MY_USERNAME}" "/home/${MY_USERNAME}/help"
 - 
 -     # Tox user interface
 -     #enable_tox_repo
 -     mesh_tox_qtox
 -     # copy the default qtox ini file
 -     if [ ! -d "${rootdir}/home/${MY_USERNAME}/.config/tox" ]; then
 -         mkdir "${rootdir}/home/${MY_USERNAME}/.config/tox"
 -         cp "/usr/local/bin/${PROJECT_NAME}-config-qtox" "${rootdir}/home/${MY_USERNAME}/.config/tox/qtox.ini"
 -         chroot "$rootdir" /bin/chown -R "${MY_USERNAME}":"${MY_USERNAME}" "/home/${MY_USERNAME}/.config"
 -     fi
 - 
 -     if [[ "$VARIANT" == "usb" ]]; then
 -         # tor
 -         chroot "$rootdir" apt-get -yq -t stretch-backports install tor
 - 
 -         # xmpp client
 -         chroot "$rootdir" echo "deb ftp://ftp.gajim.org/debian unstable main" > /etc/apt/sources.list.d/gajim.list
 -         chroot "$rootdir" apt-get update
 -         chroot "$rootdir" apt-get -yq install gajim-dev-keyring
 -         chroot "$rootdir" apt-get -yq install git python-dev python-pip gajim-nightly
 -         chroot "$rootdir" mkdir "/home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins" -p
 -         chroot "$rootdir" git clone https://github.com/omemo/gajim-omemo "/home/$GENERIC_IMAGE_USERNAME/.local/share/gajim/plugins/gajim-omemo"
 -         chroot "$rootdir" pip install protobuf==2.6.1, python-axolotl==0.1.35
 -         chroot "$rootdir" /bin/chown -R "$GENERIC_IMAGE_USERNAME":"$GENERIC_IMAGE_USERNAME" "/home/$GENERIC_IMAGE_USERNAME/.local"
 - 
 -         # IRC client
 -         chroot "$rootdir" apt-get -yq install hexchat profanity
 -     fi
 - }
 - 
 - ##############################################################################
 - # setup_utils
 - ##############################################################################
 - 
 - image_install_inadyn() {
 -     if [ "$INSTALLING_MESH" ]; then
 -         return
 -     fi
 -     if [ ! -d "$rootdir/root/build" ]; then
 -         mkdir -p "$rootdir/root/build"
 -     fi
 -     chroot "$rootdir" apt-get -yq install build-essential curl libgnutls28-dev automake1.11 libconfuse-dev
 -     chroot "$rootdir" apt-get -yq install gnutls-dev libconfuse-dev pkg-config libtool
 - 
 -     if [ -d /repos/inadyn ]; then
 -         mkdir "$rootdir/root/build/inadyn"
 -         cp -r -p /repos/inadyn/. "$rootdir/root/build/inadyn"
 -         cd "$rootdir/root/build/inadyn" || exit 24729466456
 -         git pull
 -     else
 -         git clone "$INADYN_REPO" "$rootdir/root/build/inadyn"
 -     fi
 - 
 -     if [ ! -d "$rootdir/root/build/inadyn" ]; then
 -         echo 'Failed to clone inadyn'
 -         exit 728252
 -     fi
 -     cd "$rootdir/root/build/inadyn" || exit 3468724568
 -     git checkout "$INADYN_COMMIT" -b "$INADYN_COMMIT"
 - 
 -     cd "$rootdir/root/build/inadyn" || exit 24682464628
 -     { echo '#!/bin/bash';
 -       echo 'cd ~/build/inadyn';
 -       echo './autogen.sh';
 -       echo './configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var';
 -       echo 'make -j5';
 -       echo 'make install-strip'; } > "$rootdir/root/build/build_inadyn.sh"
 -     chmod +x "$rootdir/root/build/build_inadyn.sh"
 -     chroot "$rootdir" /root/build/build_inadyn.sh
 -     if [ ! -f "$rootdir/usr/sbin/inadyn" ]; then
 -         echo 'Failed to build inadyn'
 -         exit 6209356
 -     fi
 - 
 -     # create a configuration file
 -     { echo 'period          = 300';
 -       echo ''; } > "$rootdir/etc/inadyn.conf"
 -     chmod 600 "$rootdir/etc/inadyn.conf"
 - 
 -     { echo '[Unit]';
 -       echo 'Description=Internet Dynamic DNS Client';
 -       echo 'Documentation=man:inadyn';
 -       echo 'Documentation=man:inadyn.conf';
 -       echo 'Documentation=https://github.com/troglobit/inadyn';
 -       echo 'ConditionPathExists=/etc/inadyn.conf';
 -       echo 'After=network-online.target';
 -       echo 'Requires=network-online.target';
 -       echo '';
 -       echo '[Service]';
 -       echo 'Type=simple';
 -       echo "ExecStart=/usr/sbin/inadyn -C -n -s --loglevel=err --config ${INADYN_CONFIG_FILE}";
 -       echo 'Restart=on-failure';
 -       echo 'RestartSec=10';
 -       echo '';
 -       echo '[Install]';
 -       echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/inadyn.service"
 -     chroot "$rootdir" systemctl enable inadyn
 -     echo "inadyn commit:$INADYN_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
 - }
 - 
 - image_setup_utils() {
 -     if [ "$INSTALLING_MESH" ]; then
 -         return
 -     fi
 -     chroot "$rootdir" apt-get -yq install apt-transport-https
 -     chroot "$rootdir" apt-get -yq remove --purge apache2-bin*
 -     chroot "$rootdir" apt-get -yq dist-upgrade
 -     chroot "$rootdir" apt-get -yq install ca-certificates
 -     chroot "$rootdir" apt-get -yq install apt-utils
 -     chroot "$rootdir" apt-get -yq install shellcheck hdparm
 - 
 -     if [[ "$ARCHITECTURE" == 'amd64' ]]; then
 -         chroot "$rootdir" apt-get -yq install linux-image-amd64
 -     fi
 - 
 -     if [[ "$ARCHITECTURE" == 'qemu'* || "$ARCHITECTURE" == 'amd64' || "$ARCHITECTURE" == 'x86_64' || "$ARCHITECTURE" == 'i686' || "$ARCHITECTURE" == 'i386' ]]; then
 -         chroot "$rootdir" apt-get -yq install grub2 lvm2
 -     fi
 - 
 -     chroot "$rootdir" apt-get -yq install locales locales-all debconf
 - 
 -     SYSCTL_FILE="$rootdir/etc/sysctl.conf"
 -     if [ ! -f "$SYSCTL_FILE" ]; then
 -         touch "$SYSCTL_FILE"
 -     fi
 -     cp "$SYSCTL_FILE" "$rootdir/root/sysctl.conf"
 -     chown "$CURR_USER":"$CURR_GROUP" "$rootdir/root/sysctl.conf"
 -     if ! grep -q "tcp_challenge_ack_limit" "$rootdir/root/sysctl.conf"; then
 -         echo 'net.ipv4.tcp_challenge_ack_limit = 999999999' >> "$rootdir/root/sysctl.conf"
 -     else
 -         sed -i 's|net.ipv4.tcp_challenge_ack_limit.*|net.ipv4.tcp_challenge_ack_limit = 999999999|g' "$rootdir/root/sysctl.conf"
 -     fi
 -     cp "$rootdir/root/sysctl.conf" "$SYSCTL_FILE"
 -     rm "$rootdir/root/sysctl.conf"
 - 
 -     # all the packages
 -     chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget
 -     chroot "$rootdir" apt-get -yq install avahi-daemon avahi-utils avahi-discover
 -     chroot "$rootdir" apt-get -yq install connect-proxy openssh-server
 -     chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
 -     chroot "$rootdir" apt-get -yq install avahi-discover iptables dnsutils net-tools
 -     chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
 -     chroot "$rootdir" apt-get -yq install libnss-gw-name nano man ntp locales locales-all debconf
 -     chroot "$rootdir" apt-get -yq install wireless-tools wpasupplicant usbutils cryptsetup zsh
 -     chroot "$rootdir" apt-get -yq install pinentry-curses eatmydata iotop bc hostapd haveged
 -     chroot "$rootdir" apt-get -yq install cpulimit screen elinks libpam-cracklib
 -     chroot "$rootdir" apt-get -yq install vim-common python3 unattended-upgrades
 - 
 -     # Tor and ssh over tor
 -     chroot "$rootdir" apt-get -yq -t stretch-backports install tor
 -     chroot "$rootdir" apt-get -yq install connect-proxy
 -     chroot "$rootdir" connect-proxy
 -     sed -i 's|#Log notice file.*|Log notice file /var/log/tor/notices.log|g' "$rootdir/etc/tor/torrc"
 -     sed -i 's|Log notice file.*|Log notice file /var/log/tor/notices.log|g' "$rootdir/etc/tor/torrc"
 -     sed -i "s|#AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
 -     sed -i "s|AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
 -     if ! grep -q 'Host *.onion' "$rootdir/root/.ssh/config"; then
 -         if [ ! -d "$rootdir/root/.ssh" ]; then
 -             mkdir "$rootdir/root/.ssh"
 -         fi
 -         echo 'Host *.onion' >> "$rootdir/root/.ssh/config"
 -         echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> "$rootdir/root/.ssh/config"
 -     fi
 -     if ! grep -q 'Host *.onion' "$rootdir/etc/skel/.ssh/config"; then
 -         if [ ! -d "$rootdir/etc/skel/.ssh" ]; then
 -             mkdir "$rootdir/etc/skel/.ssh"
 -         fi
 -         echo 'Host *.onion' >> "$rootdir/etc/skel/.ssh/config"
 -         echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> "$rootdir/etc/skel/.ssh/config"
 -     fi
 - 
 -     # Install golang
 -     chroot "$rootdir" adduser --disabled-login --gecos 'go' go
 -     GOARCH=
 -     if [[ "$ARCHITECTURE" == *"386" || "$ARCHITECTURE" == *"686" ]]; then
 -         GOARCH=386
 -     fi
 -     if [[ "$ARCHITECTURE" == *"amd64" || "$ARCHITECTURE" == "x86_64" ]]; then
 -         GOARCH=amd64
 -     fi
 -     if [[ "$ARCHITECTURE" == *"arm"* ]]; then
 -         GOARCH=armv6l
 -     fi
 -     if [[ "$ARCHITECTURE" == *"aarch"* || "$ARCHITECTURE" == *"arm64"* ]]; then
 -         GOARCH=arm64
 -     fi
 -     if [ ! "$GOARCH" ]; then
 -         echo $'System architecture was not specified when installing Go'
 -         exit 6734378
 -     fi
 -     GO_SOURCE="https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GOARCH}.tar.gz"
 - 
 -     if [ ! -d "${rootdir}/root/build" ]; then
 -         mkdir -p "$rootdir/root/build"
 -     fi
 -     cd "$rootdir/root/build" || exit 4268746282
 -     wget "${GO_SOURCE}"
 -     if [ ! -f "${rootdir}/root/build/go${GO_VERSION}.linux-${GOARCH}.tar.gz" ]; then
 -         exit 265243553
 -     fi
 -     chroot "$rootdir" tar -C /home/go -xzf "${INSTALL_DIR}/go${GO_VERSION}.linux-${GOARCH}.tar.gz"
 -     if [ ! -d "${rootdir}/home/go/go/bin" ]; then
 -         echo 'Go binary not installed'
 -         exit 763562
 -     fi
 -     # shellcheck disable=SC2086
 -     mv ${rootdir}/home/go/go ${rootdir}/home/go/go${GO_VERSION}
 -     echo "export GOROOT=/home/go" >> "${rootdir}/root/.bashrc"
 -     echo "export GOROOT=/home/go" >> "${rootdir}/etc/skel/.bashrc"
 -     echo "export GOROOT=/home/go" >> "${rootdir}/home/go/.bashrc"
 -     echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/root/.bashrc"
 -     echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/etc/skel/.bashrc"
 -     echo "export GOPATH=\$GOROOT/go${GO_VERSION}/bin" >> "${rootdir}/home/go/.bashrc"
 -     echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/root/.bashrc"
 -     echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/etc/skel/.bashrc"
 -     echo "export PATH=\$PATH:\$GOPATH" >> "${rootdir}/home/go/.bashrc"
 -     chroot "$rootdir" chown -R go:go /home/go
 -     cp "${rootdir}/home/go/go${GO_VERSION}/bin/"* "${rootdir}/usr/bin"
 -     echo "upgrade_golang:$GO_VERSION" >> "${rootdir}/root/${PROJECT_NAME}-completed.txt"
 - 
 -     # Tomb
 -     chroot "$rootdir" apt-get -yq install zsh pinentry-curses
 -     git clone "$TOMB_REPO" "$rootdir/root/build/tomb"
 -     cd "$rootdir/root/build/tomb" || exit 468368345425
 -     git checkout "$TOMB_COMMIT" -b "$TOMB_COMMIT"
 -     chroot "$rootdir" cd /root/build/tomb && make install
 -     echo "tomb commit:$TOMB_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
 - 
 -     if ! grep -q '\* hard maxsyslogins' "$rootdir/etc/security/limits.conf"; then
 -         echo '* hard maxsyslogins 10' >> "$rootdir/etc/security/limits.conf"
 -     else
 -         sed -i 's|hard maxsyslogins.*|hard maxsyslogins 10|g' "$rootdir/etc/security/limits.conf"
 -     fi
 - 
 -     # Max logins for each user
 -     if ! grep -q '\* hard maxlogins' "$rootdir/etc/security/limits.conf"; then
 -         echo '* hard maxlogins 2' >> "$rootdir/etc/security/limits.conf"
 -     else
 -         sed -i 's|hard maxlogins.*|hard maxlogins 2|g' "$rootdir/etc/security/limits.conf"
 -     fi
 - 
 -     # Email
 -     chroot "$rootdir" apt-get -yq remove postfix
 -     chroot "$rootdir" apt-get -yq install exim4 exim4-daemon-heavy sasl2-bin swaks libnet-ssleay-perl procmail
 -     chroot "$rootdir" apt-get -yq install spamassassin
 -     chroot "$rootdir" apt-get -yq install dovecot-imapd
 - 
 -     #backup
 -     chroot "$rootdir" apt-get -yq install duplicity gnupg
 - 
 -     # monkeysphere
 -     #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl
 - 
 -     # encrypting email
 -     chroot "$rootdir" apt-get -yq install libmail-gnupg-perl
 -     git clone "$GPGIT_REPO" "$rootdir/root/build/gpgit"
 -     cd "$rootdir/root/build/gpgit" || exit 62484624682
 -     git checkout "$GPGIT_COMMIT" -b "$GPGIT_COMMIT"
 -     cp "$rootdir/root/build/gpgit/gpgit.pl" "$rootdir/usr/bin"
 -     echo "gpgit commit:$GPGIT_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
 - 
 -     # email client
 -     chroot "$rootdir" apt-get -yq install lynx abook urlview mutt
 - 
 -     git clone "$CLEANUP_MAILDIR_REPO" "$rootdir/root/build/cleanup-maildir"
 -     cd "$rootdir/root/build/cleanup-maildir" || exit 246872646847264
 -     git checkout "$CLEANUP_MAILDIR_COMMIT" -b "$CLEANUP_MAILDIR_COMMIT"
 -     cp "$rootdir/root/build/cleanup-maildir/cleanup-maildir" "$rootdir/usr/bin"
 -     echo "cleanup-maildir commit:$CLEANUP_MAILDIR_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
 - 
 -     # web server
 -     chroot "$rootdir" apt-get -yq remove --purge apache2
 -     chroot "$rootdir" apt-get -yq install nginx php-fpm
 -     git clone "$NGINX_ENSITE_REPO" "$rootdir/root/build/nginx_ensite"
 -     cd "$rootdir/root/build/nginx_ensite" || exit 462746826482
 -     git checkout "$NGINX_ENSITE_COMMIT" -b "$NGINX_ENSITE_COMMIT"
 -     echo "nginx-ensite commit:$NGINX_ENSITE_COMMIT" >> "$rootdir/root/${PROJECT_NAME}-completed.txt"
 -     chroot "$rootdir" cd /root/build/nginx_ensite && make install
 -     if [ ! -f "$rootdir/etc/pam.d/nginx" ]; then
 -         { echo '#%PAM-1.0';
 -           echo '@include common-auth';
 -           echo '@include common-account';
 -           echo '@include common-session'; } > "$rootdir/etc/pam.d/nginx"
 -     fi
 -     chroot "$rootdir" apt-get -yq install tripwire
 - 
 -     # filesystem optimisations
 -     #sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' $rootdir/etc/fstab
 - }
 - 
 - image_install_nodejs() {
 -     if [[ "$VARIANT" == "mesh" ]]; then
 -         return
 -     fi
 - 
 -     mesh_install_nodejs
 -     echo 'install_nodejs' >> "${rootdir}/root/${PROJECT_NAME}-completed.txt"
 - }
 - 
 - image_preinstall_repos() {
 -     if [[ "$VARIANT" == "mesh"* ]]; then
 -         return
 -     fi
 - 
 -     if [ ! -d "$rootdir/repos" ]; then
 -         mkdir "$rootdir/repos"
 -     fi
 - 
 -     git clone "$CMAKE_REPO" "$rootdir/repos/cmake"
 -     git clone "$INADYN_REPO" "$rootdir/repos/inadyn"
 -     git clone "$TOMB_REPO" "$rootdir/repos/tomb"
 - 
 -     if [[ "$SOCIALINSTANCE" == "pleroma" ]]; then
 -         git clone "$PLEROMA_REPO" "$rootdir/repos/pleroma"
 -         return
 -     fi
 - 
 -     if [[ "$SOCIALINSTANCE" == "gnusocial" ]]; then
 -         git clone "$GNUSOCIAL_REPO" "$rootdir/repos/gnusocial"
 -         git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
 -         git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
 -         git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
 -         return
 -     fi
 - 
 -     if [[ "$SOCIALINSTANCE" == "postactiv" ]]; then
 -         git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
 -         git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
 -         git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
 -         git clone "$POSTACTIV_REPO" "$rootdir/repos/postactiv"
 -         return
 -     fi
 - 
 -     git clone "$CRYPTPAD_REPO" "$rootdir/repos/cryptpad"
 -     git clone "$BLUDIT_REPO" "$rootdir/repos/bludit"
 -     git clone "$DOKUWIKI_REPO" "$rootdir/repos/dokuwiki"
 -     git clone "$ETHERPAD_REPO" "$rootdir/repos/etherpad"
 -     git clone "$FRIENDICA_REPO" "$rootdir/repos/friendica"
 -     git clone "$GNUSOCIAL_REPO" "$rootdir/repos/gnusocial"
 -     git clone "$PLEROMA_REPO" "$rootdir/repos/pleroma"
 -     git clone "$GNUSOCIAL_MARKDOWN_REPO" "$rootdir/repos/gnusocial-markdown"
 -     git clone "$QVITTER_THEME_REPO" "$rootdir/repos/qvitter"
 -     git clone "$PLEROMA_FRONTEND_REPO" "$rootdir/repos/pleroma-fe"
 -     git clone "$POSTACTIV_REPO" "$rootdir/repos/postactiv"
 -     git clone "$SHARINGS_REPO" "$rootdir/repos/sharings"
 -     git clone "$HTMLY_REPO" "$rootdir/repos/htmly"
 -     git clone "$HUBZILLA_REPO" "$rootdir/repos/hubzilla"
 -     git clone "$HUBZILLA_ADDONS_REPO" "$rootdir/repos/hubzilla-addons"
 -     git clone "$KOEL_REPO" "$rootdir/repos/koel"
 -     git clone "$LYCHEE_REPO" "$rootdir/repos/lychee"
 -     git clone "$MAILPILE_REPO" "$rootdir/repos/mailpile"
 -     git clone "$MATRIX_REPO" "$rootdir/repos/matrix"
 -     git clone "$MEDIAGOBLIN_REPO" "$rootdir/repos/mediagoblin"
 -     #git clone "$MOVIM_REPO" "$rootdir/repos/movim"
 -     git clone "$NEXTCLOUD_REPO" "$rootdir/repos/nextcloud"
 -     git clone "$PIHOLE_REPO" "$rootdir/repos/pihole"
 -     git clone "$PROFANITY_REPO" "$rootdir/repos/profanity"
 -     git clone "$LIBMESODE_REPO" "$rootdir/repos/libmesode"
 -     git clone "$PROFANITY_OMEMO_PLUGIN_REPO" "$rootdir/repos/profanity-omemo"
 -     git clone "$RSS_READER_REPO" "$rootdir/repos/rss"
 -     git clone "$RSS_MOBILE_READER_REPO" "$rootdir/repos/rss-mobile"
 -     git clone "$SEARX_REPO" "$rootdir/repos/searx"
 -     git clone "$TOXCORE_REPO" "$rootdir/repos/toxcore"
 -     git clone "$TOXID_REPO" "$rootdir/repos/toxid"
 -     git clone "$TOXIC_REPO" "$rootdir/repos/toxic"
 -     git clone "$TURTL_REPO" "$rootdir/repos/turtl"
 -     git clone "$KANBOARD_REPO" "$rootdir/repos/kanboard"
 -     git clone "$KEYSERVER_WEB_REPO" "$rootdir/repos/keyserverweb"
 -     git clone "$PEERTUBE_REPO" "$rootdir/repos/peertube"
 -     git clone "$PRIVATEBIN_REPO" "$rootdir/repos/privatebin"
 -     git clone "$EDITH_REPO" "$rootdir/repos/edith"
 -     git clone "$BDSMAIL_REPO" "$rootdir/repos/bdsmail"
 -     git clone "$SMOLRSS_REPO" "$rootdir/repos/smolrss"
 -     #git clone "$WEKAN_REPO" "$rootdir/repos/wekan"
 -     #git clone "$FLOW_ROUTER_REPO" "$rootdir/repos/flowrouter"
 -     #git clone "$ZERONET_REPO" "$rootdir/repos/zeronet"
 -     #git clone "$QTOX_REPO" "$rootdir/repos/qtox"
 - }
 - 
 - ##############################################################################
 - 
 - 
 - # Set to true/false to control if eatmydata is used during build
 - use_eatmydata=true
 - 
 - rootdir="$1"
 - fmdir="$(pwd)"
 - image="$fmdir"/"$2"
 - cd "$rootdir"
 - 
 - echo info: building "$MACHINE" for "$ARCHITECTURE"
 - 
 - export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
 - export LC_ALL=C LANGUAGE=C LANG=C
 - 
 - # Override libpam-tmpdir setting during build, as the directories
 - # are not created yet.
 - export TMP=/tmp/ TMPDIR=/tmp/
 - 
 - if [ ! "$MY_USERNAME" ]; then
 -     echo $'No username was specified'
 -     exit 52825
 - fi
 - username="$MY_USERNAME"
 - echo $"warning: creating initial user $username with well known password!"
 - password="$MY_PASSWORD"
 - chroot "$rootdir" /usr/bin/env -i \
 -     HOME=/root                    \
 -     PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
 - echo "export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:" >> "$rootdir/root/.bashrc"
 - chroot "$rootdir" adduser --gecos "$username" --disabled-password "$username"
 - echo "$username:$password" | chroot "$rootdir" /usr/sbin/chpasswd
 - chroot "$rootdir" adduser "$username" sudo
 - 
 - if [ ! "$DEBIAN_REPO" ]; then
 -     DEBIAN_REPO='ftp.de.debian.org'
 - fi
 - if [ ! "$DEBIAN_VERSION" ]; then
 -     DEBIAN_VERSION='stretch'
 - fi
 - 
 - set_apt_sources "$BUILD_MIRROR"
 - chroot "$rootdir" apt-get clean
 - chroot "$rootdir" /bin/rm -rf /var/lib/apt/lists/*
 - chroot "$rootdir" apt-get clean
 - set_apt_sources "$MIRROR"
 - configure_backports
 - configure_contrib_repo
 - chroot "$rootdir" apt-get update
 - chroot "$rootdir" apt-get install -y apt-utils
 - 
 - cat > "$rootdir/usr/sbin/policy-rc.d" <<EOF
 - #!/bin/sh
 - exit 101
 - EOF
 - chmod a+rx "$rootdir/usr/sbin/policy-rc.d"
 - 
 - if "$use_eatmydata" ; then
 -     enable_eatmydata_override
 - fi
 - 
 - if [ -n "$CUSTOM_SETUP" ]; then
 -     cp "$CUSTOM_SETUP" "$rootdir"/tmp
 -     chroot "$rootdir" apt-get install -y gdebi-core
 -     chroot "$rootdir" gdebi -n "/tmp/$(basename "$CUSTOM_SETUP")"
 - fi
 - 
 - if [[ "$VARIANT" != "mesh"* ]]; then
 -     chroot "$rootdir" apt-get install -y openssh-server
 - fi
 - chroot "$rootdir" apt-get install -y sudo git dialog build-essential
 - chroot "$rootdir" apt-get install -y avahi-daemon avahi-utils avahi-discover
 - chroot "$rootdir" apt-get install -y iptables dnsutils net-tools network-manager iputils-ping
 - chroot "$rootdir" apt-get install -y libnss-mdns libnss-myhostname libnss-gw-name nano man ntp
 - chroot "$rootdir" apt-get install -y locales locales-all debconf wireless-tools wpasupplicant usbutils
 - if [[ "$ARCHITECTURE" == 'qemu'* || "$ARCHITECTURE" == 'i386' || "$ARCHITECTURE" == 'i686' || "$ARCHITECTURE" == 'amd64' || "$ARCHITECTURE" == 'x86_64' ]]; then
 -     chroot "$rootdir" apt-get install -y cryptsetup zsh pinentry-curses iotop bc
 -     chroot "$rootdir" apt-get install -y grub2 hostapd lvm2
 - fi
 - 
 - sed -i "s|#host-name=.*|host-name=${LOCAL_NAME}|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|host-name=.*|host-name=${LOCAL_NAME}|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i 's|#domain-name=.*|domain-name=local|g' "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i 's|domain-name=.*|domain-name=local|g' "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|use-ipv4=.*|use-ipv4=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|use-ipv6=.*|use-ipv6=no|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|hosts:.*|hosts:          files mdns4_minimal dns mdns4 mdns|g" "$rootdir/etc/nsswitch.conf"
 - sed -i "s|#publish-domain=.*|publish-domain=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|publish-domain=.*|publish-domain=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|#publish-addresses=.*|publish-addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - sed -i "s|publish-addresses=.*|publish-addresses=yes|g" "$rootdir/etc/avahi/avahi-daemon.conf"
 - 
 - # Add an ssh avahi service
 - { echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->';
 -   echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">';
 -   echo '<service-group>';
 -   echo '  <name replace-wildcards="yes">%h SSH</name>';
 -   echo '  <service>';
 -   echo '    <type>_ssh._tcp</type>';
 -   echo "    <port>$SSH_PORT</port>";
 -   echo '  </service>';
 -   echo '</service-group>'; } > "$rootdir/etc/avahi/services/ssh.service"
 - 
 - # Ensure that the avahi daemon keeps running
 - WATCHDOG_SCRIPT_NAME="keepon"
 - { echo '#!/bin/bash';
 -   echo 'LOGFILE=/var/log/keepon.log';
 -   echo "CURRENT_DATE=\$(date)";
 -   echo '';
 -   echo "# keep avahi-daemon daemon running";
 -   echo "RUNNING=$(pgrep avahi-daemon > /dev/null && echo Running)";
 -   echo "if [ ! \$RUNNING ]; then";
 -   echo "  systemctl start avahi-daemon";
 -   echo "  echo -n \$CURRENT_DATE >> \$LOGFILE";
 -   echo "  echo \"avahi-daemon daemon restarted\" >> \$LOGFILE";
 -   echo 'fi';
 -   echo "# End of avahi-daemon"; } > "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
 - chmod +x "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
 - echo "*/1            * *   *   *   root /usr/bin/$WATCHDOG_SCRIPT_NAME" >> "$rootdir/etc/crontab"
 - 
 - chroot "$rootdir" /bin/bash -x <<EOF
 - git clone $PROJECT_REPO /root/$PROJECT_NAME
 - cd /root/$PROJECT_NAME
 - git checkout stretch
 - make install
 - cp image_build/bbb-4.9.0.tar.gz /boot/bbb.tar.gz
 - EOF
 - 
 - chroot "$rootdir" "${PROJECT_NAME}-image-hardware-setup" 2>&1 | \
 -     tee "$rootdir/var/log/${PROJECT_NAME}-image-hardware-setup.log"
 - 
 - rm "$rootdir/usr/sbin/policy-rc.d"
 - 
 - # Set up HRNG for systems known to have one
 - # Otherwise install haveged
 - if [[ "$MACHINE" != "beaglebone"* ]]; then
 -     # With some VMs, the hardware cycles counter is emulated and deterministic,
 -     # and thus predictible, so havege should not be used
 -     if [[ "$MACHINE" != "qemu"* ]]; then
 -         chroot "$rootdir" apt-get -yq install haveged
 -     fi
 - else
 -     chroot "$rootdir" apt-get -yq install rng-tools
 -     sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' "$rootdir/etc/default/rng-tools"
 - 
 - fi
 - 
 - # copy u-boot to beginning of image
 - case "$MACHINE" in
 -     beaglebone)
 -         dd if="$rootdir/usr/lib/u-boot/am335x_boneblack/MLO" of="$image" \
 -            count=1 seek=1 conv=notrunc bs=128k
 -         dd if="$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img" of="$image" \
 -            count=2 seek=1 conv=notrunc bs=384k
 -         ;;
 -     cubieboard2)
 -         dd if="$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin" of="$image" \
 -            seek=8 conv=notrunc bs=1k
 -         ;;
 -     a20-olinuxino-lime)
 -         dd if="$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin" \
 -            of="$image" seek=8 conv=notrunc bs=1k
 -         ;;
 - esac
 - 
 - if "$use_eatmydata" ; then
 -     disable_eatmydata_override
 - fi
 - 
 - configure_ssh
 - configure_networking
 - admin_user_sudo
 - create_generic_image
 - atheros_wifi
 - continue_installation
 - image_install_nodejs
 - initialise_mesh
 - configure_wifi
 - configure_user_interface
 - image_setup_utils
 - image_install_inadyn
 - image_install_pleroma
 - image_preinstall_repos
 - 
 - # remove downloaded packages
 - chroot "$rootdir" apt-get -y autoremove
 - chroot "$rootdir" apt-get clean
 - 
 - cd /
 - echo $"info: killing leftover processes in chroot"
 - fuser -mvk "$rootdir/." || true
 - 
 - exit 0
 
 
  |