#!/bin/bash
# This script does not download the package to install it.
# This is because I assume wget/curl might not work as proxy hasn't been set.

# Working from current directory having proxyman

TARGET_DIR="$HOME/.proxyman"


# verify if this is current directory
if [[ -f "main.sh" && -f "shellrc.sh" && -f "dropbox.sh" ]]; then
    :
else
    echo "please cd to the folder containing proxyman"
    exit 1
fi

# copy the contents to ~/.proxyman/
mkdir -p $TARGET_DIR
cp * $TARGET_DIR

# add to path
mkdir -p $HOME/.local/bin
cp proxyman $HOME/.local/bin
chmod +x $HOME/.local/bin/proxyman

which proxyman &> /dev/null
if [ "$?" != 0 ]; then
    echo "Failed to install :("
    echo "You can still use it > ./main.sh set"
    exit
fi

echo "Installed successfully."
