| 
				
			 | 
			
			
				@@ -33,253 +33,388 @@ VARIANTS='mesh' 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				33
			 | 
			
			
				 IPFS_GO_REPO="https://github.com/ipfs/go-ipfs" 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				34
			 | 
			
			
				 IPFS_COMMIT='20b06a4cbce8884f5b194da6e98cb11f2c77f166' 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				35
			 | 
			
			
				 IPFS_PORT=4001 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+IPFS_NODE_VERSION='6.2.2' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+IPFS_JS_VERSION='0.14.3' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+IPFS_JS_RONIN_VERSION='0.3.11' 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				39
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				37
			 | 
			
				40
			 | 
			
			
				 function reconfigure_ipfs { 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				-	echo -n '' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+    echo -n '' 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				42
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				43
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-function upgrade_ipfs { 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				
			 | 
			
			
				-	if ! grep -Fxq "install_ipfs" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+function upgrade_ipfs_go { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+    if ! grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+    function_check select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+    select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+    function_check set_repo_commit 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+    set_repo_commit $GOPATH/src/github.com/ipfs/go-ipfs "ipfs commit" "$IPFS_COMMIT" $IPFS_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				55
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				46
			 | 
			
				
			 | 
			
			
				-	function_check select_go_version 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				
			 | 
			
			
				-	select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+function upgrade_ipfs_js { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+    if ! grep -Fxq "install_ipfs_js" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				60
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				-	function_check set_repo_commit 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-	set_repo_commit $GOPATH/src/github.com/ipfs/go-ipfs "ipfs commit" "$IPFS_COMMIT" $IPFS_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+    npm cache clean -f 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+    npm install -g n 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+    n ${IPFS_NODE_VERSION} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+    npm install ronin@${IPFS_JS_RONIN_VERSION} --global 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+    npm install ipfs@${IPFS_JS_VERSION} --global 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+function upgrade_ipfs { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+    upgrade_ipfs_js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+    upgrade_ipfs_go 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				71
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				72
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				53
			 | 
			
				73
			 | 
			
			
				 function backup_local_ipfs { 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				
			 | 
			
			
				-	if ! grep -q "Admin user" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-	ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-	source_directory=/home/$ADMIN_USERNAME/.ipfs 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-	if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-		dest_directory=ipfs 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-		echo $"Backing up $source_directory to $dest_directory" 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-		function_check backup_directory_to_usb 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-		backup_directory_to_usb $source_directory $dest_directory 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				-		echo $"Backup to $dest_directory complete" 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+    if ! grep -q "Admin user" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+    ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+    source_directory=/home/$ADMIN_USERNAME/.ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+    if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+        dest_directory=ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+        echo $"Backing up $source_directory to $dest_directory" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+        function_check backup_directory_to_usb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+        backup_directory_to_usb $source_directory $dest_directory 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+        echo $"Backup to $dest_directory complete" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				88
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				89
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				70
			 | 
			
				90
			 | 
			
			
				 function restore_local_ipfs { 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-	if ! grep -q "Admin user" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				-	if [ -d $USB_MOUNT/backup/ipfs ]; then 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				-		echo $"Restoring IPFS" 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-		temp_restore_dir=/root/tempipfs 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				-		function_check restore_directory_from_usb 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				-		restore_directory_from_usb $temp_restore_dir ipfs 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-		ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-		cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				-		if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-			rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-			function_check set_user_permissions 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				-			set_user_permissions 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				-			function_check backup_unmount_drive 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				-			backup_unmount_drive 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				-			exit 27627 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				
			 | 
			
			
				-		rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				
			 | 
			
			
				-		echo $"Restore of IPFS complete" 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+    if ! grep -q "Admin user" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+    if [ -d $USB_MOUNT/backup/ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+        echo $"Restoring IPFS" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+        temp_restore_dir=/root/tempipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+        function_check restore_directory_from_usb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+        restore_directory_from_usb $temp_restore_dir ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+        ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+        cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+            rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+            function_check set_user_permissions 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+            set_user_permissions 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+            function_check backup_unmount_drive 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+            backup_unmount_drive 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+            exit 27627 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+        rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+        echo $"Restore of IPFS complete" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				112
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				113
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				94
			 | 
			
				114
			 | 
			
			
				 function backup_remote_ipfs { 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				-	if ! grep -q "Admin user" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				-	ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				-	if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				-		echo $"Backing up IPFS" 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-		backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-		echo $"Backup of IPFS complete" 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+    if ! grep -q "Admin user" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+    ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				+    if [ -d /home/$ADMIN_USERNAME/.ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				+        echo $"Backing up IPFS" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+        backup_directory_to_friend /home/$ADMIN_USERNAME/.ipfs ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				+        echo $"Backup of IPFS complete" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				124
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				125
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				106
			 | 
			
				126
			 | 
			
			
				 function restore_remote_ipfs { 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				
			 | 
			
			
				-	if [ -d $SERVER_DIRECTORY/backup/ipfs ]; then 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				
			 | 
			
			
				-		echo $"Restoring IPFS" 
			 | 
		
	
		
			
			| 
				109
			 | 
			
				
			 | 
			
			
				-		temp_restore_dir=/root/tempipfs 
			 | 
		
	
		
			
			| 
				110
			 | 
			
				
			 | 
			
			
				-		function_check restore_directory_from_friend 
			 | 
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				-		restore_directory_from_friend $temp_restore_dir ipfs 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				-		cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				
			 | 
			
			
				-		if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				
			 | 
			
			
				-			function_check set_user_permissions 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				
			 | 
			
			
				-			set_user_permissions 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				
			 | 
			
			
				-			rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				117
			 | 
			
				
			 | 
			
			
				-			exit 276357 
			 | 
		
	
		
			
			| 
				118
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				
			 | 
			
			
				-		rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				
			 | 
			
			
				-		echo $"Restore of IPFS complete" 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				+    if [ -d $SERVER_DIRECTORY/backup/ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				+        echo $"Restoring IPFS" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				129
			 | 
			
			
				+        temp_restore_dir=/root/tempipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				130
			 | 
			
			
				+        function_check restore_directory_from_friend 
			 | 
		
	
		
			
			| 
				
			 | 
			
				131
			 | 
			
			
				+        restore_directory_from_friend $temp_restore_dir ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				+        cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				+        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				134
			 | 
			
			
				+            function_check set_user_permissions 
			 | 
		
	
		
			
			| 
				
			 | 
			
				135
			 | 
			
			
				+            set_user_permissions 
			 | 
		
	
		
			
			| 
				
			 | 
			
				136
			 | 
			
			
				+            rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				
			 | 
			
				137
			 | 
			
			
				+            exit 276357 
			 | 
		
	
		
			
			| 
				
			 | 
			
				138
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				139
			 | 
			
			
				+        rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				
			 | 
			
				140
			 | 
			
			
				+        echo $"Restore of IPFS complete" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				141
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				142
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				143
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				144
			 | 
			
			
				+function remove_ipfs_go { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				145
			 | 
			
			
				+    if ! grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				146
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				147
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				148
			 | 
			
			
				+    function_check select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				149
			 | 
			
			
				+    select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				150
			 | 
			
			
				+    systemctl stop ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				151
			 | 
			
			
				+    systemctl disable ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				152
			 | 
			
			
				+    systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				+    rm /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				154
			 | 
			
			
				+    rm -rf $GOPATH/src/github.com/ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				155
			 | 
			
			
				+    iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				+    function_check save_firewall_settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				+    save_firewall_settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				+    sed -i '/install_ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				159
			 | 
			
			
				+    sed -i '/ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				160
			 | 
			
			
				+    sed -i '/configure_firewall_for_ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				161
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				162
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				163
			 | 
			
			
				+function remove_ipfs_js { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				164
			 | 
			
			
				+    if ! grep -Fxq "install_ipfs_js" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				165
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				166
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				167
			 | 
			
			
				+    systemctl stop ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				168
			 | 
			
			
				+    systemctl disable ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				169
			 | 
			
			
				+    rm /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				170
			 | 
			
			
				+    systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				
			 | 
			
				171
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				172
			 | 
			
			
				+    npm uninstall ipfs --global 
			 | 
		
	
		
			
			| 
				
			 | 
			
				173
			 | 
			
			
				+    npm uninstall ronin --global 
			 | 
		
	
		
			
			| 
				
			 | 
			
				174
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				175
			 | 
			
			
				+    iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				176
			 | 
			
			
				+    function_check save_firewall_settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				177
			 | 
			
			
				+    save_firewall_settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				178
			 | 
			
			
				+    sed -i '/install_ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				179
			 | 
			
			
				+    sed -i '/ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				180
			 | 
			
			
				+    sed -i '/configure_firewall_for_ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				181
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				123
			 | 
			
				182
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				124
			 | 
			
				183
			 | 
			
			
				 function remove_ipfs { 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				
			 | 
			
			
				-	if ! grep -Fxq "install_ipfs" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				
			 | 
			
			
				-	function_check select_go_version 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				
			 | 
			
			
				-	select_go_version 
			 | 
		
	
		
			
			| 
				130
			 | 
			
				
			 | 
			
			
				-	systemctl stop ipfs 
			 | 
		
	
		
			
			| 
				131
			 | 
			
				
			 | 
			
			
				-	systemctl disable ipfs 
			 | 
		
	
		
			
			| 
				132
			 | 
			
				
			 | 
			
			
				-	systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				133
			 | 
			
				
			 | 
			
			
				-	rm /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				134
			 | 
			
				
			 | 
			
			
				-	rm -rf $GOPATH/src/github.com/ipfs 
			 | 
		
	
		
			
			| 
				135
			 | 
			
				
			 | 
			
			
				-	iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT 
			 | 
		
	
		
			
			| 
				136
			 | 
			
				
			 | 
			
			
				-	function_check save_firewall_settings 
			 | 
		
	
		
			
			| 
				137
			 | 
			
				
			 | 
			
			
				-	save_firewall_settings 
			 | 
		
	
		
			
			| 
				138
			 | 
			
				
			 | 
			
			
				-	sed -i '/install_ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				139
			 | 
			
				
			 | 
			
			
				-	sed -i '/ipfs /d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				140
			 | 
			
				
			 | 
			
			
				-	sed -i '/configure_firewall_for_ipfs/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				184
			 | 
			
			
				+    remove_ipfs_js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				185
			 | 
			
			
				+    remove_ipfs_go 
			 | 
		
	
		
			
			| 
				141
			 | 
			
				186
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				142
			 | 
			
				187
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				143
			 | 
			
				188
			 | 
			
			
				 function configure_firewall_for_ipfs { 
			 | 
		
	
		
			
			| 
				144
			 | 
			
				
			 | 
			
			
				-	if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				145
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				146
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				147
			 | 
			
				
			 | 
			
			
				-	if [[ $ONION_ONLY != "no" ]]; then 
			 | 
		
	
		
			
			| 
				148
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				149
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				150
			 | 
			
				
			 | 
			
			
				-	iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT 
			 | 
		
	
		
			
			| 
				151
			 | 
			
				
			 | 
			
			
				-	function_check save_firewall_settings 
			 | 
		
	
		
			
			| 
				152
			 | 
			
				
			 | 
			
			
				-	save_firewall_settings 
			 | 
		
	
		
			
			| 
				153
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				154
			 | 
			
				
			 | 
			
			
				-	OPEN_PORTS+=("IPFS     $IPFS_PORT") 
			 | 
		
	
		
			
			| 
				155
			 | 
			
				
			 | 
			
			
				-	echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				189
			 | 
			
			
				+    if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				190
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				191
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				192
			 | 
			
			
				+    if [[ $ONION_ONLY != "no" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				193
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				194
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				195
			 | 
			
			
				+    iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				196
			 | 
			
			
				+    function_check save_firewall_settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				197
			 | 
			
			
				+    save_firewall_settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				198
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				199
			 | 
			
			
				+    OPEN_PORTS+=("IPFS     $IPFS_PORT") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				200
			 | 
			
			
				+    echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				201
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				202
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				203
			 | 
			
			
				+function install_ipfs_js { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				204
			 | 
			
			
				+    if grep -Fxq "install_ipfs_js" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				205
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				206
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				207
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				208
			 | 
			
			
				+    apt-get -y install npm libpam0g-dev fuse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				209
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				210
			 | 
			
			
				+    npm cache clean -f 
			 | 
		
	
		
			
			| 
				
			 | 
			
				211
			 | 
			
			
				+    npm install -g n 
			 | 
		
	
		
			
			| 
				
			 | 
			
				212
			 | 
			
			
				+    n ${IPFS_NODE_VERSION} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				213
			 | 
			
			
				+    npm install ronin@${IPFS_JS_RONIN_VERSION} --global 
			 | 
		
	
		
			
			| 
				
			 | 
			
				214
			 | 
			
			
				+    npm install ipfs@${IPFS_JS_VERSION} --global 
			 | 
		
	
		
			
			| 
				
			 | 
			
				215
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				216
			 | 
			
			
				+    IPFS_PATH=/usr/local/bin 
			 | 
		
	
		
			
			| 
				
			 | 
			
				217
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				218
			 | 
			
			
				+    # initialise 
			 | 
		
	
		
			
			| 
				
			 | 
			
				219
			 | 
			
			
				+    su -c "$IPFS_PATH/ipfs init -b 4096" - $MY_USERNAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				220
			 | 
			
			
				+    if [ ! -d /home/$MY_USERNAME/.ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				221
			 | 
			
			
				+        echo "IPFS could not be initialised for user $MY_USERNAME" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				222
			 | 
			
			
				+        exit 7358 
			 | 
		
	
		
			
			| 
				
			 | 
			
				223
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				224
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				225
			 | 
			
			
				+    # directories to mount to 
			 | 
		
	
		
			
			| 
				
			 | 
			
				226
			 | 
			
			
				+    if [ ! -d /ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				227
			 | 
			
			
				+        mkdir /ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				228
			 | 
			
			
				+        mkdir /ipns 
			 | 
		
	
		
			
			| 
				
			 | 
			
				229
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				230
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /ipns 
			 | 
		
	
		
			
			| 
				
			 | 
			
				231
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				232
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				233
			 | 
			
			
				+    if [ -f /etc/fuse.conf ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				234
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf 
			 | 
		
	
		
			
			| 
				
			 | 
			
				235
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				236
			 | 
			
			
				+    if [ -f /dev/fuse ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				237
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /dev/fuse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				238
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				239
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				240
			 | 
			
			
				+    IPFS_DAEMON_NAME=ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				241
			 | 
			
			
				+    IPFS_DAEMON_FILE=/etc/systemd/system/${IPFS_DAEMON_NAME}.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				242
			 | 
			
			
				+    echo '[Unit]' > $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				243
			 | 
			
			
				+    echo 'Description=IPFS javascript daemon' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				244
			 | 
			
			
				+    echo 'After=syslog.target' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				245
			 | 
			
			
				+    echo 'After=network.target' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				246
			 | 
			
			
				+    echo '' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				247
			 | 
			
			
				+    echo '[Service]' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				248
			 | 
			
			
				+    echo 'Type=simple' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				249
			 | 
			
			
				+    echo "User=$MY_USERNAME" >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				250
			 | 
			
			
				+    echo "Group=$MY_USERNAME" >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				251
			 | 
			
			
				+    echo "WorkingDirectory=/home/$MY_USERNAME" >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				252
			 | 
			
			
				+    echo "ExecStart=${IPFS_PATH}/jsipfs daemon --mount" >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				253
			 | 
			
			
				+    echo 'Restart=on-failure' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				254
			 | 
			
			
				+    echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\"" >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				255
			 | 
			
			
				+    echo '' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				256
			 | 
			
			
				+    echo '[Install]' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				257
			 | 
			
			
				+    echo 'WantedBy=multi-user.target' >> $IPFS_DAEMON_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				258
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				259
			 | 
			
			
				+    systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				
			 | 
			
				260
			 | 
			
			
				+    systemctl enable ${IPFS_DAEMON_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				261
			 | 
			
			
				+    systemctl restart ${IPFS_DAEMON_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				262
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				263
			 | 
			
			
				+    if [ -d /etc/avahi ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				264
			 | 
			
			
				+        su -c "echo $($IPFS_PATH/ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > /tmp/ipfsid" - $MY_USERNAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				265
			 | 
			
			
				+        if [ ! -f /tmp/ipfsid ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				266
			 | 
			
			
				+            echo 'No IPFS identity was created' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				267
			 | 
			
			
				+            exit 37895 
			 | 
		
	
		
			
			| 
				
			 | 
			
				268
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				269
			 | 
			
			
				+        IPFS_PEER_ID=$(cat /tmp/ipfsid) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				270
			 | 
			
			
				+        if [ ${#IPFS_PEER_ID} -lt 10 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				271
			 | 
			
			
				+            echo 'Invalid IPFS peer ID' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				272
			 | 
			
			
				+            echo "$IPFS_PEER_ID" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				273
			 | 
			
			
				+            exit 74782 
			 | 
		
	
		
			
			| 
				
			 | 
			
				274
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				275
			 | 
			
			
				+        # Add an avahi service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				276
			 | 
			
			
				+        function_check create_avahi_service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				277
			 | 
			
			
				+        create_avahi_service ipfs "ipfs" udp $IPFS_PORT "$IPFS_PEER_ID" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				278
			 | 
			
			
				+        rm /tmp/ipfsid 
			 | 
		
	
		
			
			| 
				
			 | 
			
				279
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				280
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				281
			 | 
			
			
				+    function_check configure_firewall_for_ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				282
			 | 
			
			
				+    configure_firewall_for_ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				283
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				284
			 | 
			
			
				+    echo 'install_ipfs_js' >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				285
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				286
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				287
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				288
			 | 
			
			
				+function install_ipfs_go { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				289
			 | 
			
			
				+    if grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				290
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				291
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				292
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				293
			 | 
			
			
				+    function_check select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				294
			 | 
			
			
				+    select_go_version 
			 | 
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				296
			 | 
			
			
				+    apt-get -y install golang libpam0g-dev fuse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				297
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				298
			 | 
			
			
				+    if [ ! -d /home/git ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				+        # add a gogs user account 
			 | 
		
	
		
			
			| 
				
			 | 
			
				300
			 | 
			
			
				+        adduser --disabled-login --gecos 'Gogs' git 
			 | 
		
	
		
			
			| 
				
			 | 
			
				301
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				302
			 | 
			
			
				+        # install Go 
			 | 
		
	
		
			
			| 
				
			 | 
			
				303
			 | 
			
			
				+        if ! grep -q "export GOPATH=" ~/.bashrc; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				304
			 | 
			
			
				+            echo "export GOPATH=$GOPATH" >> ~/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				305
			 | 
			
			
				+        else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				+            sed -i "s|export GOPATH=.*|export GOPATH=$GOPATH|g" ~/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				307
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				308
			 | 
			
			
				+        systemctl set-environment GOPATH=$GOPATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				309
			 | 
			
			
				+        if ! grep -q "systemctl set-environment GOPATH=" ~/.bashrc; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				+            echo "systemctl set-environment GOPATH=$GOPATH" >> ~/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				+        else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				312
			 | 
			
			
				+            sed -i "s|systemctl set-environment GOPATH=.*|systemctl set-environment GOPATH=$GOPATH|g" ~/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				313
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				314
			 | 
			
			
				+        if [ ! -d $GOPATH ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				315
			 | 
			
			
				+            mkdir -p $GOPATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				316
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				317
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				318
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				319
			 | 
			
			
				+    IPFS_PATH=$GOPATH/bin 
			 | 
		
	
		
			
			| 
				
			 | 
			
				320
			 | 
			
			
				+    export PATH="$GOPATH/bin:$PATH:" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				321
			 | 
			
			
				+    if ! grep -q 'GOPATH/bin' ~/.bashrc; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				322
			 | 
			
			
				+        echo 'export PATH="$GOPATH/bin:$PATH:";' >> ~/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				323
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				324
			 | 
			
			
				+        sed -i "s|systemctl set-environment GOPATH=.*|systemctl set-environment GOPATH=$GOPATH|g" ~/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				325
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				326
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				327
			 | 
			
			
				+    # set gopath for the user 
			 | 
		
	
		
			
			| 
				
			 | 
			
				328
			 | 
			
			
				+    if ! grep -q "GOPATH=" /home/$MY_USERNAME/.bashrc; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				329
			 | 
			
			
				+        echo "export GOPATH=$GOPATH" >> /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				330
			 | 
			
			
				+        echo 'export PATH="$GOPATH/bin:$PATH:";' >> /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				331
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				332
			 | 
			
			
				+        sed -i "s|export GOPATH=.*|export GOPATH=$GOPATH|g" /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				333
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				334
			 | 
			
			
				+    chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				
			 | 
			
				335
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				336
			 | 
			
			
				+    IPFS_GO_REPO2=$(echo "$IPFS_GO_REPO" | sed 's|https://||g') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				337
			 | 
			
			
				+    go get -u ${IPFS_GO_REPO2}/cmd/ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				338
			 | 
			
			
				+    if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				339
			 | 
			
			
				+        exit 8242 
			 | 
		
	
		
			
			| 
				
			 | 
			
				340
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				341
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				342
			 | 
			
			
				+    cd $GOPATH/src/$IPFS_GO_REPO2 
			 | 
		
	
		
			
			| 
				
			 | 
			
				343
			 | 
			
			
				+    git checkout $IPFS_COMMIT -b $IPFS_COMMIT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				344
			 | 
			
			
				+    if ! grep -q "ipfs commit" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				345
			 | 
			
			
				+        echo "ipfs commit:$IPFS_COMMIT" >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				346
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				347
			 | 
			
			
				+        sed -i "s/ipfs commit.*/ipfs commit:$IPFS_COMMIT/g" $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				348
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				349
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				350
			 | 
			
			
				+    # initialise 
			 | 
		
	
		
			
			| 
				
			 | 
			
				351
			 | 
			
			
				+    su -c "$IPFS_PATH/ipfs init -b 4096" - $MY_USERNAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				352
			 | 
			
			
				+    if [ ! -d /home/$MY_USERNAME/.ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				353
			 | 
			
			
				+        echo "IPFS could not be initialised for user $MY_USERNAME" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				354
			 | 
			
			
				+        exit 7358 
			 | 
		
	
		
			
			| 
				
			 | 
			
				355
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				356
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				357
			 | 
			
			
				+    # directories to mount to 
			 | 
		
	
		
			
			| 
				
			 | 
			
				358
			 | 
			
			
				+    if [ ! -d /ipfs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				359
			 | 
			
			
				+        mkdir /ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				360
			 | 
			
			
				+        mkdir /ipns 
			 | 
		
	
		
			
			| 
				
			 | 
			
				361
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				362
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /ipns 
			 | 
		
	
		
			
			| 
				
			 | 
			
				363
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				364
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				365
			 | 
			
			
				+    if [ -f /etc/fuse.conf ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				366
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf 
			 | 
		
	
		
			
			| 
				
			 | 
			
				367
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				368
			 | 
			
			
				+    if [ -f /dev/fuse ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				369
			 | 
			
			
				+        chown $MY_USERNAME:$MY_USERNAME /dev/fuse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				370
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				371
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				372
			 | 
			
			
				+    echo '[Unit]' > /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				373
			 | 
			
			
				+    echo 'Description=IPFS go daemon' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				374
			 | 
			
			
				+    echo 'After=syslog.target' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				375
			 | 
			
			
				+    echo 'After=network.target' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				376
			 | 
			
			
				+    echo '' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				377
			 | 
			
			
				+    echo '[Service]' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				378
			 | 
			
			
				+    echo 'Type=simple' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				379
			 | 
			
			
				+    echo "User=$MY_USERNAME" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				380
			 | 
			
			
				+    echo "Group=$MY_USERNAME" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				381
			 | 
			
			
				+    echo "WorkingDirectory=/home/$MY_USERNAME" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				382
			 | 
			
			
				+    echo "ExecStart=$IPFS_PATH/ipfs daemon --mount" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				383
			 | 
			
			
				+    echo 'Restart=on-failure' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				384
			 | 
			
			
				+    echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\" \"GOPATH=$GOPATH\" \"GVM_ROOT=$GVM_HOME\"" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				385
			 | 
			
			
				+    echo '' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				386
			 | 
			
			
				+    echo '[Install]' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				387
			 | 
			
			
				+    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				388
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				389
			 | 
			
			
				+    systemctl enable ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				390
			 | 
			
			
				+    systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				
			 | 
			
				391
			 | 
			
			
				+    systemctl restart ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				392
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				393
			 | 
			
			
				+    if [ -d /etc/avahi ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				394
			 | 
			
			
				+        su -c "echo $($IPFS_PATH/ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > /tmp/ipfsid" - $MY_USERNAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				395
			 | 
			
			
				+        if [ ! -f /tmp/ipfsid ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				396
			 | 
			
			
				+            echo 'No IPFS identity was created' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				397
			 | 
			
			
				+            exit 37895 
			 | 
		
	
		
			
			| 
				
			 | 
			
				398
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				399
			 | 
			
			
				+        IPFS_PEER_ID=$(cat /tmp/ipfsid) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				400
			 | 
			
			
				+        if [ ${#IPFS_PEER_ID} -lt 10 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				401
			 | 
			
			
				+            echo 'Invalid IPFS peer ID' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				402
			 | 
			
			
				+            echo "$IPFS_PEER_ID" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				403
			 | 
			
			
				+            exit 74782 
			 | 
		
	
		
			
			| 
				
			 | 
			
				404
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				405
			 | 
			
			
				+        # Add an avahi service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				406
			 | 
			
			
				+        function_check create_avahi_service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				407
			 | 
			
			
				+        create_avahi_service ipfs "ipfs" udp $IPFS_PORT "$IPFS_PEER_ID" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				408
			 | 
			
			
				+        rm /tmp/ipfsid 
			 | 
		
	
		
			
			| 
				
			 | 
			
				409
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				410
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				411
			 | 
			
			
				+    function_check configure_firewall_for_ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				412
			 | 
			
			
				+    configure_firewall_for_ipfs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				413
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				414
			 | 
			
			
				+    echo 'install_ipfs_go' >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				156
			 | 
			
				415
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				157
			 | 
			
				416
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				158
			 | 
			
				417
			 | 
			
			
				 function install_ipfs { 
			 | 
		
	
		
			
			| 
				159
			 | 
			
				
			 | 
			
			
				-	if grep -Fxq "install_ipfs" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				160
			 | 
			
				
			 | 
			
			
				-		return 
			 | 
		
	
		
			
			| 
				161
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				162
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				163
			 | 
			
				
			 | 
			
			
				-	function_check select_go_version 
			 | 
		
	
		
			
			| 
				164
			 | 
			
				
			 | 
			
			
				-	select_go_version 
			 | 
		
	
		
			
			| 
				165
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				166
			 | 
			
				
			 | 
			
			
				-	apt-get -y install golang libpam0g-dev fuse 
			 | 
		
	
		
			
			| 
				167
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				168
			 | 
			
				
			 | 
			
			
				-	if [ ! -d /home/git ]; then 
			 | 
		
	
		
			
			| 
				169
			 | 
			
				
			 | 
			
			
				-		# add a gogs user account 
			 | 
		
	
		
			
			| 
				170
			 | 
			
				
			 | 
			
			
				-		adduser --disabled-login --gecos 'Gogs' git 
			 | 
		
	
		
			
			| 
				171
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				172
			 | 
			
				
			 | 
			
			
				-		# install Go 
			 | 
		
	
		
			
			| 
				173
			 | 
			
				
			 | 
			
			
				-		if ! grep -q "export GOPATH=" ~/.bashrc; then 
			 | 
		
	
		
			
			| 
				174
			 | 
			
				
			 | 
			
			
				-			echo "export GOPATH=$GOPATH" >> ~/.bashrc 
			 | 
		
	
		
			
			| 
				175
			 | 
			
				
			 | 
			
			
				-		else 
			 | 
		
	
		
			
			| 
				176
			 | 
			
				
			 | 
			
			
				-			sed -i "s|export GOPATH=.*|export GOPATH=$GOPATH|g" ~/.bashrc 
			 | 
		
	
		
			
			| 
				177
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				178
			 | 
			
				
			 | 
			
			
				-		systemctl set-environment GOPATH=$GOPATH 
			 | 
		
	
		
			
			| 
				179
			 | 
			
				
			 | 
			
			
				-		if ! grep -q "systemctl set-environment GOPATH=" ~/.bashrc; then 
			 | 
		
	
		
			
			| 
				180
			 | 
			
				
			 | 
			
			
				-			echo "systemctl set-environment GOPATH=$GOPATH" >> ~/.bashrc 
			 | 
		
	
		
			
			| 
				181
			 | 
			
				
			 | 
			
			
				-		else 
			 | 
		
	
		
			
			| 
				182
			 | 
			
				
			 | 
			
			
				-			sed -i "s|systemctl set-environment GOPATH=.*|systemctl set-environment GOPATH=$GOPATH|g" ~/.bashrc 
			 | 
		
	
		
			
			| 
				183
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				184
			 | 
			
				
			 | 
			
			
				-		if [ ! -d $GOPATH ]; then 
			 | 
		
	
		
			
			| 
				185
			 | 
			
				
			 | 
			
			
				-			mkdir -p $GOPATH 
			 | 
		
	
		
			
			| 
				186
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				187
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				188
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				189
			 | 
			
				
			 | 
			
			
				-	IPFS_PATH=$GOPATH/bin 
			 | 
		
	
		
			
			| 
				190
			 | 
			
				
			 | 
			
			
				-	export PATH="$GOPATH/bin:$PATH:" 
			 | 
		
	
		
			
			| 
				191
			 | 
			
				
			 | 
			
			
				-	if ! grep -q 'GOPATH/bin' ~/.bashrc; then 
			 | 
		
	
		
			
			| 
				192
			 | 
			
				
			 | 
			
			
				-		echo 'export PATH="$GOPATH/bin:$PATH:";' >> ~/.bashrc 
			 | 
		
	
		
			
			| 
				193
			 | 
			
				
			 | 
			
			
				-	else 
			 | 
		
	
		
			
			| 
				194
			 | 
			
				
			 | 
			
			
				-		sed -i "s|systemctl set-environment GOPATH=.*|systemctl set-environment GOPATH=$GOPATH|g" ~/.bashrc 
			 | 
		
	
		
			
			| 
				195
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				196
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				197
			 | 
			
				
			 | 
			
			
				-	# set gopath for the user 
			 | 
		
	
		
			
			| 
				198
			 | 
			
				
			 | 
			
			
				-	if ! grep -q "GOPATH=" /home/$MY_USERNAME/.bashrc; then 
			 | 
		
	
		
			
			| 
				199
			 | 
			
				
			 | 
			
			
				-		echo "export GOPATH=$GOPATH" >> /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				200
			 | 
			
				
			 | 
			
			
				-		echo 'export PATH="$GOPATH/bin:$PATH:";' >> /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				201
			 | 
			
				
			 | 
			
			
				-	else 
			 | 
		
	
		
			
			| 
				202
			 | 
			
				
			 | 
			
			
				-		sed -i "s|export GOPATH=.*|export GOPATH=$GOPATH|g" /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				203
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				204
			 | 
			
				
			 | 
			
			
				-	chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc 
			 | 
		
	
		
			
			| 
				205
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				206
			 | 
			
				
			 | 
			
			
				-	IPFS_GO_REPO2=$(echo "$IPFS_GO_REPO" | sed 's|https://||g') 
			 | 
		
	
		
			
			| 
				207
			 | 
			
				
			 | 
			
			
				-	go get -u ${IPFS_GO_REPO2}/cmd/ipfs 
			 | 
		
	
		
			
			| 
				208
			 | 
			
				
			 | 
			
			
				-	if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				209
			 | 
			
				
			 | 
			
			
				-		exit 8242 
			 | 
		
	
		
			
			| 
				210
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				211
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				212
			 | 
			
				
			 | 
			
			
				-	cd $GOPATH/src/$IPFS_GO_REPO2 
			 | 
		
	
		
			
			| 
				213
			 | 
			
				
			 | 
			
			
				-	git checkout $IPFS_COMMIT -b $IPFS_COMMIT 
			 | 
		
	
		
			
			| 
				214
			 | 
			
				
			 | 
			
			
				-	if ! grep -q "ipfs commit" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				215
			 | 
			
				
			 | 
			
			
				-		echo "ipfs commit:$IPFS_COMMIT" >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				216
			 | 
			
				
			 | 
			
			
				-	else 
			 | 
		
	
		
			
			| 
				217
			 | 
			
				
			 | 
			
			
				-		sed -i "s/ipfs commit.*/ipfs commit:$IPFS_COMMIT/g" $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				218
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				219
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				220
			 | 
			
				
			 | 
			
			
				-	# initialise 
			 | 
		
	
		
			
			| 
				221
			 | 
			
				
			 | 
			
			
				-	su -c "$IPFS_PATH/ipfs init -b 4096" - $MY_USERNAME 
			 | 
		
	
		
			
			| 
				222
			 | 
			
				
			 | 
			
			
				-	if [ ! -d /home/$MY_USERNAME/.ipfs ]; then 
			 | 
		
	
		
			
			| 
				223
			 | 
			
				
			 | 
			
			
				-		echo "IPFS could not be initialised for user $MY_USERNAME" 
			 | 
		
	
		
			
			| 
				224
			 | 
			
				
			 | 
			
			
				-		exit 7358 
			 | 
		
	
		
			
			| 
				225
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				226
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				227
			 | 
			
				
			 | 
			
			
				-	# directories to mount to 
			 | 
		
	
		
			
			| 
				228
			 | 
			
				
			 | 
			
			
				-	if [ ! -d /ipfs ]; then 
			 | 
		
	
		
			
			| 
				229
			 | 
			
				
			 | 
			
			
				-		mkdir /ipfs 
			 | 
		
	
		
			
			| 
				230
			 | 
			
				
			 | 
			
			
				-		mkdir /ipns 
			 | 
		
	
		
			
			| 
				231
			 | 
			
				
			 | 
			
			
				-		chown $MY_USERNAME:$MY_USERNAME /ipfs 
			 | 
		
	
		
			
			| 
				232
			 | 
			
				
			 | 
			
			
				-		chown $MY_USERNAME:$MY_USERNAME /ipns 
			 | 
		
	
		
			
			| 
				233
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				234
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				235
			 | 
			
				
			 | 
			
			
				-	if [ -f /etc/fuse.conf ]; then 
			 | 
		
	
		
			
			| 
				236
			 | 
			
				
			 | 
			
			
				-		chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf 
			 | 
		
	
		
			
			| 
				237
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				238
			 | 
			
				
			 | 
			
			
				-	if [ -f /dev/fuse ]; then 
			 | 
		
	
		
			
			| 
				239
			 | 
			
				
			 | 
			
			
				-		chown $MY_USERNAME:$MY_USERNAME /dev/fuse 
			 | 
		
	
		
			
			| 
				240
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				241
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				242
			 | 
			
				
			 | 
			
			
				-	echo '[Unit]' > /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				243
			 | 
			
				
			 | 
			
			
				-	echo 'Description=IPFS daemon' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				244
			 | 
			
				
			 | 
			
			
				-	echo 'After=syslog.target' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				245
			 | 
			
				
			 | 
			
			
				-	echo 'After=network.target' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				246
			 | 
			
				
			 | 
			
			
				-	echo '' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				247
			 | 
			
				
			 | 
			
			
				-	echo '[Service]' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				248
			 | 
			
				
			 | 
			
			
				-	echo 'Type=simple' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				249
			 | 
			
				
			 | 
			
			
				-	echo "User=$MY_USERNAME" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				250
			 | 
			
				
			 | 
			
			
				-	echo "Group=$MY_USERNAME" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				251
			 | 
			
				
			 | 
			
			
				-	echo "WorkingDirectory=/home/$MY_USERNAME" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				252
			 | 
			
				
			 | 
			
			
				-	echo "ExecStart=$IPFS_PATH/ipfs daemon --mount" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				253
			 | 
			
				
			 | 
			
			
				-	echo 'Restart=on-failure' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				254
			 | 
			
				
			 | 
			
			
				-	echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\" \"GOPATH=$GOPATH\" \"GVM_ROOT=$GVM_HOME\"" >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				255
			 | 
			
				
			 | 
			
			
				-	echo '' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				256
			 | 
			
				
			 | 
			
			
				-	echo '[Install]' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				257
			 | 
			
				
			 | 
			
			
				-	echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ipfs.service 
			 | 
		
	
		
			
			| 
				258
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				259
			 | 
			
				
			 | 
			
			
				-	systemctl enable ipfs 
			 | 
		
	
		
			
			| 
				260
			 | 
			
				
			 | 
			
			
				-	systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				261
			 | 
			
				
			 | 
			
			
				-	systemctl restart ipfs 
			 | 
		
	
		
			
			| 
				262
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				263
			 | 
			
				
			 | 
			
			
				-	if [ -d /etc/avahi ]; then 
			 | 
		
	
		
			
			| 
				264
			 | 
			
				
			 | 
			
			
				-		su -c "echo $($IPFS_PATH/ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > /tmp/ipfsid" - $MY_USERNAME 
			 | 
		
	
		
			
			| 
				265
			 | 
			
				
			 | 
			
			
				-		if [ ! -f /tmp/ipfsid ]; then 
			 | 
		
	
		
			
			| 
				266
			 | 
			
				
			 | 
			
			
				-			echo 'No IPFS identity was created' 
			 | 
		
	
		
			
			| 
				267
			 | 
			
				
			 | 
			
			
				-			exit 37895 
			 | 
		
	
		
			
			| 
				268
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				269
			 | 
			
				
			 | 
			
			
				-		IPFS_PEER_ID=$(cat /tmp/ipfsid) 
			 | 
		
	
		
			
			| 
				270
			 | 
			
				
			 | 
			
			
				-		if [ ${#IPFS_PEER_ID} -lt 10 ]; then 
			 | 
		
	
		
			
			| 
				271
			 | 
			
				
			 | 
			
			
				-			echo 'Invalid IPFS peer ID' 
			 | 
		
	
		
			
			| 
				272
			 | 
			
				
			 | 
			
			
				-			echo "$IPFS_PEER_ID" 
			 | 
		
	
		
			
			| 
				273
			 | 
			
				
			 | 
			
			
				-			exit 74782 
			 | 
		
	
		
			
			| 
				274
			 | 
			
				
			 | 
			
			
				-		fi 
			 | 
		
	
		
			
			| 
				275
			 | 
			
				
			 | 
			
			
				-		# Add an avahi service 
			 | 
		
	
		
			
			| 
				276
			 | 
			
				
			 | 
			
			
				-		function_check create_avahi_service 
			 | 
		
	
		
			
			| 
				277
			 | 
			
				
			 | 
			
			
				-		create_avahi_service ipfs "ipfs" udp $IPFS_PORT "$IPFS_PEER_ID" 
			 | 
		
	
		
			
			| 
				278
			 | 
			
				
			 | 
			
			
				-		rm /tmp/ipfsid 
			 | 
		
	
		
			
			| 
				279
			 | 
			
				
			 | 
			
			
				-	fi 
			 | 
		
	
		
			
			| 
				280
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				281
			 | 
			
				
			 | 
			
			
				-	function_check configure_firewall_for_ipfs 
			 | 
		
	
		
			
			| 
				282
			 | 
			
				
			 | 
			
			
				-	configure_firewall_for_ipfs 
			 | 
		
	
		
			
			| 
				283
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				284
			 | 
			
				
			 | 
			
			
				-	echo 'install_ipfs' >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				418
			 | 
			
			
				+    install_ipfs_js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				419
			 | 
			
			
				+    #install_ipfs_go 
			 | 
		
	
		
			
			| 
				285
			 | 
			
				420
			 | 
			
			
				 } 
			 |