ipfs on mesh
This commit is contained in:
parent
3ea1b03436
commit
654ca16983
|
@ -39,6 +39,7 @@ IPFS_N_VERSION='2.1.4'
|
|||
IPFS_JS_VERSION='0.14.3'
|
||||
IPFS_JS_RONIN_VERSION='0.3.11'
|
||||
IPFS_KEY_LENGTH=2048
|
||||
IPFS_GO_VERSION=0.4.2
|
||||
|
||||
function reconfigure_ipfs {
|
||||
echo -n ''
|
||||
|
@ -378,51 +379,48 @@ function install_ipfs_js {
|
|||
}
|
||||
|
||||
function mesh_install_ipfs_go {
|
||||
chroot ${rootdir} apt-get -y install golang libpam0g-dev fuse
|
||||
chroot ${rootdir} apt-get -y install libpam0g-dev fuse wget
|
||||
|
||||
mesh_upgrade_golang
|
||||
|
||||
GOPATH=/home/go/go${GO_VERSION}
|
||||
IPFS_ARCH=
|
||||
IPFS_PATH=/usr/bin
|
||||
|
||||
cat <<EOF > ${rootdir}/root/install_ipfs_go.sh
|
||||
export GOPATH=$GOPATH
|
||||
export GOROOT=/home/go
|
||||
if [ ! -d $rootdir$INSTALL_DIR/ipfs ]; then
|
||||
mkdir -p $rootdir$INSTALL_DIR/ipfs
|
||||
fi
|
||||
cd $rootdir$INSTALL_DIR/ipfs
|
||||
|
||||
IPFS_PATH=$IPFS_PATH
|
||||
|
||||
echo "go get -u ${IPFS_GO_REPO_BASE}/cmd/ipfs"
|
||||
go get -u ${IPFS_GO_REPO_BASE}/cmd/ipfs
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 8242
|
||||
if [[ $ARCHITECTURE == *"386" ]]; then
|
||||
IPFS_ARCH=386
|
||||
fi
|
||||
if [[ $ARCHITECTURE == *"amd64" ]]; then
|
||||
IPFS_ARCH=amd64
|
||||
fi
|
||||
if [[ $ARCHITECTURE == *"arm"* ]]; then
|
||||
IPFS_ARCH=arm
|
||||
fi
|
||||
if [ ! $IPFS_ARCH ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -d $GOPATH/src/$IPFS_GO_REPO_BASE ]; then
|
||||
echo $'go get failed to get ipfs'
|
||||
exit 63923
|
||||
IPFS_FILE=go-ipfs_v${IPFS_GO_VERSION}_linux-${IPFS_ARCH}.tar.gz
|
||||
wget https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/v${IPFS_GO_VERSION}/${IPFS_FILE}
|
||||
if [ ! -f $rootdir$INSTALL_DIR/ipfs/${IPFS_FILE} ]; then
|
||||
echo $'IPFS package could not be downloaded'
|
||||
exit 63725
|
||||
fi
|
||||
|
||||
cd \$GOPATH/src/${IPFS_GO_REPO_BASE}
|
||||
git checkout $IPFS_COMMIT -b $IPFS_COMMIT
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 735639
|
||||
tar -xzvf ${IPFS_FILE}
|
||||
if [ ! -f $rootdir$INSTALL_DIR/ipfs/go-ipfs/ipfs ]; then
|
||||
echo $"ipfs was not found in downloaded package"
|
||||
exit 638235
|
||||
fi
|
||||
|
||||
make install
|
||||
if [ ! "$?" = "0" ]; then
|
||||
exit 6743895
|
||||
chroot "$rootdir" cp $INSTALL_DIR/ipfs/go-ipfs/ipfs $IPFS_PATH
|
||||
if [ ! -f $rootdir$IPFS_PATH/ipfs ]; then
|
||||
echo $'IPFS was not installed'
|
||||
exit 63722
|
||||
fi
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chroot ${rootdir} chmod +x /root/install_ipfs_go.sh
|
||||
chroot ${rootdir} bash /root/install_ipfs_go.sh
|
||||
if [ ! -f ${rootdir}$IPFS_PATH/ipfs ]; then
|
||||
echo 'IPFS was not installed'
|
||||
exit 73529
|
||||
fi
|
||||
chroot ${rootdir} rm -f /root/install_ipfs_go.sh
|
||||
|
||||
echo '[Unit]' > ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo 'Description=IPFS go daemon' >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo 'After=syslog.target' >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
|
@ -433,9 +431,9 @@ EOF
|
|||
echo "User=$MY_USERNAME" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo "Group=$MY_USERNAME" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo "WorkingDirectory=/home/$MY_USERNAME" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo "ExecStart=$IPFS_PATH/ipfs daemon --mount" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo "ExecStart=$IPFS_PATH/ipfs daemon" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo 'Restart=on-failure' >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\" \"GOPATH=$GOPATH\"" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\" \"GOPATH=/home/go/go${GO_VERSION}\"" >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo '' >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo '[Install]' >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
echo 'WantedBy=multi-user.target' >> ${rootdir}/etc/systemd/system/ipfs.service
|
||||
|
|
|
@ -557,7 +557,7 @@ initialise_mesh() {
|
|||
install_tomb
|
||||
#install_tahoelafs
|
||||
#install_librevault
|
||||
#install_ipfs
|
||||
install_ipfs
|
||||
install_tox
|
||||
install_web_server
|
||||
if [ $ENABLE_ZERONET ]; then
|
||||
|
|
|
@ -730,10 +730,6 @@ function setup_ipfs {
|
|||
rm -rf /home/$MY_USERNAME/.ipfs
|
||||
fi
|
||||
|
||||
if [ -f /home/git/gvm/bin/gvm ]; then
|
||||
/home/git/gvm/bin/gvm use go${GO_VERSION} --default
|
||||
fi
|
||||
|
||||
su -c "$IPFS_COMMAND init -b $IPFS_KEY_LENGTH" - $MY_USERNAME
|
||||
if [ ! -d /home/$MY_USERNAME/.ipfs ]; then
|
||||
echo "IPFS could not be initialised for user $MY_USERNAME" >> $INSTALL_LOG
|
||||
|
@ -754,6 +750,21 @@ function setup_ipfs {
|
|||
return
|
||||
fi
|
||||
|
||||
# directories to mount to
|
||||
if [ ! -d /ipfs ]; then
|
||||
mkdir /ipfs
|
||||
mkdir /ipns
|
||||
chown $MY_USERNAME:$MY_USERNAME /ipfs
|
||||
chown $MY_USERNAME:$MY_USERNAME /ipns
|
||||
fi
|
||||
|
||||
if [ -f /etc/fuse.conf ]; then
|
||||
chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf
|
||||
fi
|
||||
if [ -f /dev/fuse ]; then
|
||||
chown $MY_USERNAME:$MY_USERNAME /dev/fuse
|
||||
fi
|
||||
|
||||
# TODO in avahi service for ipfs replace IPFS_PEER_ID
|
||||
|
||||
echo 'IPFS installed with ID $IPFS_PEER_ID' >> $INSTALL_LOG
|
||||
|
|
Loading…
Reference in New Issue