Bob Mottram 8 vuotta sitten
vanhempi
commit
654ca16983
3 muutettua tiedostoa jossa 52 lisäystä ja 43 poistoa
  1. 36
    38
      src/freedombone-app-ipfs
  2. 1
    1
      src/freedombone-image-customise
  3. 15
    4
      src/freedombone-image-mesh

+ 36
- 38
src/freedombone-app-ipfs Näytä tiedosto

@@ -39,6 +39,7 @@ IPFS_N_VERSION='2.1.4'
39 39
 IPFS_JS_VERSION='0.14.3'
40 40
 IPFS_JS_RONIN_VERSION='0.3.11'
41 41
 IPFS_KEY_LENGTH=2048
42
+IPFS_GO_VERSION=0.4.2
42 43
 
43 44
 function reconfigure_ipfs {
44 45
     echo -n ''
@@ -378,50 +379,47 @@ function install_ipfs_js {
378 379
 }
379 380
 
380 381
 function mesh_install_ipfs_go {
381
-    chroot ${rootdir} apt-get -y install golang libpam0g-dev fuse
382
+    chroot ${rootdir} apt-get -y install libpam0g-dev fuse wget
382 383
 
383 384
     mesh_upgrade_golang
384 385
 
385
-    GOPATH=/home/go/go${GO_VERSION}
386
+    IPFS_ARCH=
386 387
     IPFS_PATH=/usr/bin
387 388
 
388
-    cat <<EOF > ${rootdir}/root/install_ipfs_go.sh
389
-export GOPATH=$GOPATH
390
-export GOROOT=/home/go
391
-
392
-IPFS_PATH=$IPFS_PATH
393
-
394
-echo "go get -u ${IPFS_GO_REPO_BASE}/cmd/ipfs"
395
-go get -u ${IPFS_GO_REPO_BASE}/cmd/ipfs
396
-if [ ! "$?" = "0" ]; then
397
-    exit 8242
398
-fi
399
-
400
-if [ ! -d $GOPATH/src/$IPFS_GO_REPO_BASE ]; then
401
-    echo $'go get failed to get ipfs'
402
-    exit 63923
403
-fi
404
-
405
-cd \$GOPATH/src/${IPFS_GO_REPO_BASE}
406
-git checkout $IPFS_COMMIT -b $IPFS_COMMIT
407
-if [ ! "$?" = "0" ]; then
408
-    exit 735639
409
-fi
389
+    if [ ! -d $rootdir$INSTALL_DIR/ipfs ]; then
390
+        mkdir -p $rootdir$INSTALL_DIR/ipfs
391
+    fi
392
+    cd $rootdir$INSTALL_DIR/ipfs
410 393
 
411
-make install
412
-if [ ! "$?" = "0" ]; then
413
-    exit 6743895
414
-fi
394
+    if [[ $ARCHITECTURE == *"386" ]]; then
395
+        IPFS_ARCH=386
396
+    fi
397
+    if [[ $ARCHITECTURE == *"amd64" ]]; then
398
+        IPFS_ARCH=amd64
399
+    fi
400
+    if [[ $ARCHITECTURE == *"arm"* ]]; then
401
+        IPFS_ARCH=arm
402
+    fi
403
+    if [ ! $IPFS_ARCH ]; then
404
+        return
405
+    fi
415 406
 
416
-exit 0
417
-EOF
418
-    chroot ${rootdir} chmod +x /root/install_ipfs_go.sh
419
-    chroot ${rootdir} bash /root/install_ipfs_go.sh
420
-    if [ ! -f ${rootdir}$IPFS_PATH/ipfs ]; then
421
-        echo 'IPFS was not installed'
422
-        exit 73529
407
+    IPFS_FILE=go-ipfs_v${IPFS_GO_VERSION}_linux-${IPFS_ARCH}.tar.gz
408
+    wget https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/v${IPFS_GO_VERSION}/${IPFS_FILE}
409
+    if [ ! -f $rootdir$INSTALL_DIR/ipfs/${IPFS_FILE} ]; then
410
+        echo $'IPFS package could not be downloaded'
411
+        exit 63725
412
+    fi
413
+    tar -xzvf ${IPFS_FILE}
414
+    if [ ! -f $rootdir$INSTALL_DIR/ipfs/go-ipfs/ipfs ]; then
415
+        echo $"ipfs was not found in downloaded package"
416
+        exit 638235
417
+    fi
418
+    chroot "$rootdir" cp $INSTALL_DIR/ipfs/go-ipfs/ipfs $IPFS_PATH
419
+    if [ ! -f $rootdir$IPFS_PATH/ipfs ]; then
420
+        echo $'IPFS was not installed'
421
+        exit 63722
423 422
     fi
424
-    chroot ${rootdir} rm -f /root/install_ipfs_go.sh
425 423
 
426 424
     echo '[Unit]' > ${rootdir}/etc/systemd/system/ipfs.service
427 425
     echo 'Description=IPFS go daemon' >> ${rootdir}/etc/systemd/system/ipfs.service
@@ -433,9 +431,9 @@ EOF
433 431
     echo "User=$MY_USERNAME" >> ${rootdir}/etc/systemd/system/ipfs.service
434 432
     echo "Group=$MY_USERNAME" >> ${rootdir}/etc/systemd/system/ipfs.service
435 433
     echo "WorkingDirectory=/home/$MY_USERNAME" >> ${rootdir}/etc/systemd/system/ipfs.service
436
-    echo "ExecStart=$IPFS_PATH/ipfs daemon --mount" >> ${rootdir}/etc/systemd/system/ipfs.service
434
+    echo "ExecStart=$IPFS_PATH/ipfs daemon" >> ${rootdir}/etc/systemd/system/ipfs.service
437 435
     echo 'Restart=on-failure' >> ${rootdir}/etc/systemd/system/ipfs.service
438
-    echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\" \"GOPATH=$GOPATH\"" >> ${rootdir}/etc/systemd/system/ipfs.service
436
+    echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\" \"GOPATH=/home/go/go${GO_VERSION}\"" >> ${rootdir}/etc/systemd/system/ipfs.service
439 437
     echo '' >> ${rootdir}/etc/systemd/system/ipfs.service
440 438
     echo '[Install]' >> ${rootdir}/etc/systemd/system/ipfs.service
441 439
     echo 'WantedBy=multi-user.target' >> ${rootdir}/etc/systemd/system/ipfs.service

+ 1
- 1
src/freedombone-image-customise Näytä tiedosto

@@ -557,7 +557,7 @@ initialise_mesh() {
557 557
     install_tomb
558 558
     #install_tahoelafs
559 559
     #install_librevault
560
-    #install_ipfs
560
+    install_ipfs
561 561
     install_tox
562 562
     install_web_server
563 563
     if [ $ENABLE_ZERONET ]; then

+ 15
- 4
src/freedombone-image-mesh Näytä tiedosto

@@ -730,10 +730,6 @@ function setup_ipfs {
730 730
         rm -rf /home/$MY_USERNAME/.ipfs
731 731
     fi
732 732
 
733
-    if [ -f /home/git/gvm/bin/gvm ]; then
734
-        /home/git/gvm/bin/gvm use go${GO_VERSION} --default
735
-    fi
736
-
737 733
     su -c "$IPFS_COMMAND init -b $IPFS_KEY_LENGTH" - $MY_USERNAME
738 734
     if [ ! -d /home/$MY_USERNAME/.ipfs ]; then
739 735
         echo "IPFS could not be initialised for user $MY_USERNAME" >> $INSTALL_LOG
@@ -754,6 +750,21 @@ function setup_ipfs {
754 750
         return
755 751
     fi
756 752
 
753
+    # directories to mount to
754
+    if [ ! -d /ipfs ]; then
755
+        mkdir /ipfs
756
+        mkdir /ipns
757
+        chown $MY_USERNAME:$MY_USERNAME /ipfs
758
+        chown $MY_USERNAME:$MY_USERNAME /ipns
759
+    fi
760
+
761
+    if [ -f /etc/fuse.conf ]; then
762
+        chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf
763
+    fi
764
+    if [ -f /dev/fuse ]; then
765
+        chown $MY_USERNAME:$MY_USERNAME /dev/fuse
766
+    fi
767
+
757 768
     # TODO in avahi service for ipfs replace IPFS_PEER_ID
758 769
 
759 770
     echo 'IPFS installed with ID $IPFS_PEER_ID' >> $INSTALL_LOG