# delete server bin
[private]
server_clean:
    rm server

# delete client bin
[private]
client_clean:
    rm client

# delete binaries
clean: server_clean client_clean

# build server bin
server:
    go build server.go

# build client bin
client:
    go build client.go

# build both bins
build: client server

# delete binaries and make them again
rebuild: clean build

# install server
ins_server:
    #!/usr/bin/bash
    echo "enter port of server or leave blank to use default (1300)"
    read PORT
    if [[ $PORT -ne "" ]]; then
        sed -i -e "s/1300/$PORT/" server.go
    fi
    echo "go build -o ekho_server server.go"
    go build -o ekho_server server.go
    echo "mv ekho_server /usr/local/bin/"
    mv ekho_server /usr/local/bin/
    USER=($(users))
    sed -i -e "s/USER/${USER[0]}/" ekho.service
    echo "cp ekho.service /etc/systemd/system/"
    cp ekho.service /etc/systemd/system/
    mkdir -p ~/.config/ekho
    echo "ln -s -r ./list.q ~/.config/ekho/list.q"
    ln -s -r ./list.q ~/.config/ekho/list.q
    echo "systemctl daemon-reload"
    systemctl daemon-reload
    echo "systemctl enable ekho"
    systemctl enable ekho
    echo "systemctl start ekho"
    systemctl start ekho
    echo "systemctl status ekho"
    systemctl status ekho


# install client
ins_client:
    #!/usr/bin/bash
    echo "enter url or ip and port of server, 'aaa.bbb.ccc.ddd:port"
    read IP_PORT
    sed -i -e "s/:1300/$IP_PORT/" client.go
    echo "go build -o ekho client.go"
    go build -o ekho client.go
    sed -i -e "s/$IP_PORT/:1300/" client.go
    echo "mv ekho /usr/local/bin/"
    mv ekho /usr/local/bin/
    echo "add 'ekho' to shell config (config.fish, .bashrc, etc)"

