#!/bin/bash

mkdir /usr/local/ipinfo
cd /usr/local/ipinfo

git init
git pull https://github.com/ipinfo/cli.git

mkdir bin

for cli in $(ls -d **); do
    [[ $(file $cli) != *directory* ]] && continue
    ! [[ -f $cli/main.go ]] && continue

    go build -C $cli -o ../bin/$cli
done

echo "" >> /root/.bashrc
echo "" >> /root/.bashrc

cat << EOF >> /root/.bashrc
# IPInfo
export PATH="$(pwd)/bin:\$PATH"
EOF