diff options
Diffstat (limited to 'lib/_ak_ipfs')
-rwxr-xr-x | lib/_ak_ipfs | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/lib/_ak_ipfs b/lib/_ak_ipfs index f2e0629..07595ae 100755 --- a/lib/_ak_ipfs +++ b/lib/_ak_ipfs @@ -17,7 +17,9 @@ ### You should have received a copy of the GNU General Public License ### along with this program. If not, see <http://www.gnu.org/licenses/>. ### -source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_lib_load +_ak_lib_load _ak_log + AK_IPFS_REPO="$AK_WORKDIR/ipfsrepo" AK_IPFS_ARTIFACTS="$AK_WORKDIR/ipfs_artifacts" if [ ! -d $AK_IPFS_ARTIFACTS ] @@ -34,6 +36,15 @@ function _ak_ipfs(){ fi } +function _ak_ipfs_runner(){ + export IPFS_PATH=$AK_IPFS_REPO; kubo $* + if [ $? -ne 0 ] + then + _ak_log_error "Some error occured when running: kubo $*" + #exit 1 + fi +} + function _ak_ipfs_daemon(){ _ak_ipfs daemon --routing=dht --migrate & printf '%s' "$!" > $AK_WORKDIR/akipfsd.pid @@ -107,7 +118,7 @@ function _ak_ipfs_scanner(){ function _ak_ipfs_add(){ if [ -z $1 ] || [ ! -n "$1" ] then - _ak_log_error "no argument given" + _ak_log_error "_ak_ipfs_add: no argument given" exit 1 fi # Receives a file @@ -123,7 +134,7 @@ function _ak_ipfs_add(){ function _ak_ipfs_block_stat(){ if [ -z $1 ] || [ ! -n "$1" ] then - _ak_log_error "no argument given" + _ak_log_error "_ak_ipfs_block_stat: no argument given" exit 1 fi _ak_ipfs block stat "$1" @@ -247,7 +258,7 @@ function _ak_ipfs_get(){ function _ak_ipfs_cat(){ if [ -z $1 ] || [ ! -n "$1" ] then - _ak_log_error "no argument given" + _ak_log_error "_ak_ipfs_cat: no argument given" exit 1 fi if [ ! -f $AK_IPFS_ARTIFACTS/$1 ] @@ -449,7 +460,7 @@ function _ak_ipfs_init(){ } function _ak_ipfs_download(){ - _ak_log_info "Attempting to install IPFS..." + _ak_log_info "Figuring latest compatible version of kubo (IPFS)..." IPFS_VERSION="$(curl \ --connect-timeout 3 \ -s https://dist.ipfs.tech/kubo/versions | tail -1)" @@ -480,6 +491,43 @@ function _ak_ipfs_download(){ fi } +function _ak_ipfs_install(){ + _ak_log_info "Making temp files" + pwd > pwd + mktemp -d > tempassin + ak_curdir=$(cat pwd) + TEMPASSIN=$(cat tempassin) + cd $TEMPASSIN + tar xf $AK_ARCHIVESDIR/$IPFS_TARGET_FILE + cp kubo/ipfs $AK_BINDIR/kubo + cd $ak_curdir + rm -rf $TEMPASSIN + _ak_log_info "ipfs installed on $AK_BINDIR" +} + +function _ak_ipfs_check_and_install(){ + which kubo > /dev/null 2>&1 + if [ $? -ne 0 ] + then + _ak_ipfs_download + _ak_ipfs_install + _ak_ipfs init + _ak_ipfs_swarm_install + else + _ak_log_info "Found IPFS! Skipping downloading..." + _ak_ipfs_swarm_install + fi + if [ ! -d $AK_IPFS_REPO ] + then + _ak_ipfs init + _ak_ipfs_swarm_install + fi + if [ ! -f $AK_ZGENESIS ] + then + _ak_ipfs add -Q $AK_GENESIS > $AK_ZGENESIS + fi +} + function _ak_ipfs_cid_v0_check(){ if [ -z $1 ] || [ ! -n "$1" ] then @@ -518,3 +566,5 @@ function _ak_ipfs_swarm_install(){ function _ak_ipfs_get_config_ipns_key(){ _ak_ipfs_key_list_full | grep 'ak-config' | cut -d ' ' -f 1 } + +_ak_log_debug "_ak_ipfs loaded $(caller)" |